62d1a3941c
About The Pull Request A PR now several weeks in the making that spiraled ridiculously out of control for something not many even use. What else is new in NTOS hell? I spent several days doing nothing but playing escape from tarkov so this took longer than expected I valiantly spent all night and day working on this, and barely finished it before The Deadline the card ntos program was split into three programs, manifest, job management, and id card modification. It didn't make much sense for them all to be the same program imo, and made the project a bit more managable. Airlock electronics saw some improvements as well since it uses this new access control section as well. Yet again some new functionality and improvements to core components. Buttons now have an "altSelected" feature where instead of changing the color it adds a small white marker, among some other things. There were a couple of small changes in inconsequential ways in other places, and datacore was refactored a tiny bit. Probably some other stuff I don't remember. I would replace the old card console with a modular computer right now, but I know a few people actually use this program and want a bit of time to iron out bugs and inconsistencies before replacing the main job console with it. Changelog 🆑 add: tgui-next NTOS card console, job manager, and crew manifest tweak: airlock electronics interface is a little fancier /🆑
142 lines
4.3 KiB
Plaintext
142 lines
4.3 KiB
Plaintext
/datum/computer_file/program/job_management
|
|
filename = "job_manage"
|
|
filedesc = "Job Manager"
|
|
program_icon_state = "id"
|
|
extended_desc = "Program for viewing and changing job slot avalibility."
|
|
transfer_access = ACCESS_HEADS
|
|
requires_ntnet = 0
|
|
size = 4
|
|
tgui_id = "ntos_job_manager"
|
|
ui_x = 400
|
|
ui_y = 620
|
|
|
|
var/change_position_cooldown = 30
|
|
//Jobs you cannot open new positions for
|
|
var/list/blacklisted = list(
|
|
"AI",
|
|
"Assistant",
|
|
"Cyborg",
|
|
"Captain",
|
|
"Head of Personnel",
|
|
"Head of Security",
|
|
"Chief Engineer",
|
|
"Research Director",
|
|
"Chief Medical Officer")
|
|
|
|
//The scaling factor of max total positions in relation to the total amount of people on board the station in %
|
|
var/max_relative_positions = 30 //30%: Seems reasonable, limit of 6 @ 20 players
|
|
|
|
//This is used to keep track of opened positions for jobs to allow instant closing
|
|
//Assoc array: "JobName" = (int)<Opened Positions>
|
|
var/list/opened_positions = list()
|
|
|
|
/datum/computer_file/program/job_management/New()
|
|
..()
|
|
change_position_cooldown = CONFIG_GET(number/id_console_jobslot_delay)
|
|
|
|
/datum/computer_file/program/job_management/proc/can_open_job(datum/job/job)
|
|
if(!(job?.title in blacklisted))
|
|
if((job.total_positions <= length(GLOB.player_list) * (max_relative_positions / 100)))
|
|
var/delta = (world.time / 10) - GLOB.time_last_changed_position
|
|
if((change_position_cooldown < delta) || (opened_positions[job.title] < 0))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/datum/computer_file/program/job_management/proc/can_close_job(datum/job/job)
|
|
if(!(job?.title in blacklisted))
|
|
if(job.total_positions > length(GLOB.player_list) * (max_relative_positions / 100))
|
|
var/delta = (world.time / 10) - GLOB.time_last_changed_position
|
|
if((change_position_cooldown < delta) || (opened_positions[job.title] > 0))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/datum/computer_file/program/job_management/ui_act(action, params, datum/tgui/ui)
|
|
if(..())
|
|
return
|
|
|
|
var/authed = FALSE
|
|
var/mob/user = usr
|
|
var/obj/item/card/id/user_id = user.get_idcard()
|
|
if(user_id)
|
|
if(ACCESS_CHANGE_IDS in user_id.access)
|
|
authed = TRUE
|
|
|
|
if(!authed)
|
|
return
|
|
|
|
switch(action)
|
|
if("PRG_open_job")
|
|
var/edit_job_target = params["target"]
|
|
var/datum/job/j = SSjob.GetJob(edit_job_target)
|
|
if(!j || !can_open_job(j))
|
|
return
|
|
if(opened_positions[edit_job_target] >= 0)
|
|
GLOB.time_last_changed_position = world.time / 10
|
|
j.total_positions++
|
|
opened_positions[edit_job_target]++
|
|
playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
|
|
return TRUE
|
|
if("PRG_close_job")
|
|
var/edit_job_target = params["target"]
|
|
var/datum/job/j = SSjob.GetJob(edit_job_target)
|
|
if(!j || !can_close_job(j))
|
|
return
|
|
//Allow instant closing without cooldown if a position has been opened before
|
|
if(opened_positions[edit_job_target] <= 0)
|
|
GLOB.time_last_changed_position = world.time / 10
|
|
j.total_positions--
|
|
opened_positions[edit_job_target]--
|
|
playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
|
|
return TRUE
|
|
if("PRG_priority")
|
|
if(length(SSjob.prioritized_jobs) >= 5)
|
|
return
|
|
var/priority_target = params["target"]
|
|
var/datum/job/j = SSjob.GetJob(priority_target)
|
|
if(!j)
|
|
return
|
|
if(j.total_positions <= j.current_positions)
|
|
return
|
|
if(j in SSjob.prioritized_jobs)
|
|
SSjob.prioritized_jobs -= j
|
|
else
|
|
SSjob.prioritized_jobs += j
|
|
playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
|
|
return TRUE
|
|
|
|
|
|
/datum/computer_file/program/job_management/ui_data(mob/user)
|
|
var/list/data = get_header_data()
|
|
|
|
var/authed = FALSE
|
|
var/obj/item/card/id/user_id = user.get_idcard(FALSE)
|
|
if(user_id)
|
|
if(ACCESS_CHANGE_IDS in user_id.access)
|
|
authed = TRUE
|
|
|
|
data["authed"] = authed
|
|
|
|
var/list/pos = list()
|
|
for(var/j in SSjob.occupations)
|
|
var/datum/job/job = j
|
|
if(job.title in blacklisted)
|
|
continue
|
|
|
|
pos += list(list(
|
|
"title" = job.title,
|
|
"current" = job.current_positions,
|
|
"total" = job.total_positions,
|
|
"status_open" = authed ? can_open_job(job) : FALSE,
|
|
"status_close" = authed ? can_close_job(job) : FALSE,
|
|
))
|
|
data["slots"] = pos
|
|
var/delta = round(change_position_cooldown - ((world.time / 10) - GLOB.time_last_changed_position), 1)
|
|
data["cooldown"] = delta < 0 ? 0 : delta
|
|
var/list/priority = list()
|
|
for(var/j in SSjob.prioritized_jobs)
|
|
var/datum/job/job = j
|
|
priority += job.title
|
|
data["prioritized"] = priority
|
|
return data
|
|
|