mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 19:44:58 +01:00
tgui-next ntos card console (#48938)
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 /🆑
This commit is contained in:
@@ -1,26 +1,43 @@
|
||||
// /program/ files are executable programs that do things.
|
||||
/datum/computer_file/program
|
||||
filetype = "PRG"
|
||||
filename = "UnknownProgram" // File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
|
||||
var/required_access = null // List of required accesses to *run* the program.
|
||||
var/transfer_access = null // List of required access to download or file host the program
|
||||
var/program_state = PROGRAM_STATE_KILLED// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
|
||||
var/obj/item/modular_computer/computer // Device that runs this program.
|
||||
var/filedesc = "Unknown Program" // User-friendly name of this program.
|
||||
var/extended_desc = "N/A" // Short description of this program's function.
|
||||
var/program_icon_state = null // Program-specific screen icon state
|
||||
var/requires_ntnet = 0 // Set to 1 for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
|
||||
var/requires_ntnet_feature = 0 // Optional, if above is set to 1 checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
|
||||
var/ntnet_status = 1 // NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
|
||||
var/usage_flags = PROGRAM_ALL // Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
|
||||
var/network_destination = null // Optional string that describes what NTNet server/system this program connects to. Used in default logging.
|
||||
var/available_on_ntnet = 1 // Whether the program can be downloaded from NTNet. Set to 0 to disable.
|
||||
var/available_on_syndinet = 0 // Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
|
||||
var/tgui_id // ID of TGUI interface
|
||||
var/ui_style // ID of custom TGUI style (optional)
|
||||
var/ui_x = 575 // Default size of TGUI window, in pixels
|
||||
/// File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
|
||||
filename = "UnknownProgram"
|
||||
/// List of required accesses to *run* the program.
|
||||
var/required_access = null
|
||||
/// List of required access to download or file host the program
|
||||
var/transfer_access = null
|
||||
/// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
|
||||
var/program_state = PROGRAM_STATE_KILLED
|
||||
/// Device that runs this program.
|
||||
var/obj/item/modular_computer/computer
|
||||
/// User-friendly name of this program.
|
||||
var/filedesc = "Unknown Program"
|
||||
/// Short description of this program's function.
|
||||
var/extended_desc = "N/A"
|
||||
/// Program-specific screen icon state
|
||||
var/program_icon_state = null
|
||||
/// Set to 1 for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
|
||||
var/requires_ntnet = FALSE
|
||||
/// Optional, if above is set to 1 checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
|
||||
var/requires_ntnet_feature = 0
|
||||
/// NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
|
||||
var/ntnet_status = 1
|
||||
/// Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
|
||||
var/usage_flags = PROGRAM_ALL
|
||||
/// Optional string that describes what NTNet server/system this program connects to. Used in default logging.
|
||||
var/network_destination = null
|
||||
/// Whether the program can be downloaded from NTNet. Set to 0 to disable.
|
||||
var/available_on_ntnet = 1
|
||||
/// Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
|
||||
var/available_on_syndinet = 0
|
||||
/// ID of TGUI interface
|
||||
var/tgui_id
|
||||
/// Default size of TGUI window, in pixels
|
||||
var/ui_x = 575
|
||||
var/ui_y = 700
|
||||
var/ui_header = null // Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images are taken from /icons/program_icons. Be careful not to use too large images!
|
||||
/// Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images are taken from /icons/program_icons. Be careful not to use too large images!
|
||||
var/ui_header = null
|
||||
|
||||
/datum/computer_file/program/New(obj/item/modular_computer/comp = null)
|
||||
..()
|
||||
@@ -146,10 +163,6 @@
|
||||
assets.send(user)
|
||||
|
||||
ui = new(user, src, ui_key, tgui_id, filedesc, ui_x, ui_y, state = state)
|
||||
|
||||
if(ui_style)
|
||||
ui.set_style(ui_style)
|
||||
ui.set_autoupdate(state = 1)
|
||||
ui.open()
|
||||
|
||||
// CONVENTIONS, READ THIS WHEN CREATING NEW PROGRAM AND OVERRIDING THIS PROC:
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
unsendable = 1
|
||||
undeletable = 1
|
||||
tgui_id = "synd_contract"
|
||||
ui_style = "syndicate"
|
||||
ui_x = 500
|
||||
ui_y = 600
|
||||
var/error = ""
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
available_on_ntnet = 0
|
||||
available_on_syndinet = 1
|
||||
tgui_id = "ntos_net_dos"
|
||||
ui_style = "syndicate"
|
||||
ui_x = 400
|
||||
ui_y = 250
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
available_on_ntnet = 0
|
||||
available_on_syndinet = 1
|
||||
tgui_id = "ntos_revelation"
|
||||
ui_style = "syndicate"
|
||||
ui_x = 400
|
||||
ui_y = 250
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
#define CARDCON_DEPARTMENT_SERVICE "Service"
|
||||
#define CARDCON_DEPARTMENT_SECURITY "Security"
|
||||
#define CARDCON_DEPARTMENT_MEDICAL "Medical"
|
||||
#define CARDCON_DEPARTMENT_SUPPLY "Supply"
|
||||
#define CARDCON_DEPARTMENT_SCIENCE "Science"
|
||||
#define CARDCON_DEPARTMENT_ENGINEERING "Engineering"
|
||||
#define CARDCON_DEPARTMENT_COMMAND "Command"
|
||||
|
||||
/datum/computer_file/program/card_mod
|
||||
filename = "cardmod"
|
||||
filedesc = "ID Card Modification"
|
||||
@@ -7,96 +15,89 @@
|
||||
requires_ntnet = 0
|
||||
size = 8
|
||||
tgui_id = "ntos_card"
|
||||
ui_x = 600
|
||||
ui_y = 700
|
||||
ui_x = 450
|
||||
ui_y = 520
|
||||
|
||||
var/mod_mode = 1
|
||||
var/is_centcom = 0
|
||||
var/show_assignments = 0
|
||||
var/minor = 0
|
||||
var/authenticated = 0
|
||||
var/list/reg_ids = list()
|
||||
var/list/region_access = null
|
||||
var/list/head_subordinates = null
|
||||
var/target_dept = 0 //Which department this computer has access to. 0=all departments
|
||||
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")
|
||||
var/is_centcom = FALSE
|
||||
var/minor = FALSE
|
||||
var/authenticated = FALSE
|
||||
var/list/region_access
|
||||
var/list/head_subordinates
|
||||
///Which departments this computer has access to. Defined as access regions. null = all departments
|
||||
var/target_dept
|
||||
|
||||
//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
|
||||
//For some reason everything was exploding if this was static.
|
||||
var/list/sub_managers
|
||||
|
||||
//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/card_mod/New(obj/item/modular_computer/comp)
|
||||
. = ..()
|
||||
sub_managers = list(
|
||||
"[ACCESS_HOP]" = list(
|
||||
"department" = list(CARDCON_DEPARTMENT_SERVICE, CARDCON_DEPARTMENT_COMMAND),
|
||||
"region" = 1,
|
||||
"head" = "Head of Personnel"
|
||||
),
|
||||
"[ACCESS_HOS]" = list(
|
||||
"department" = CARDCON_DEPARTMENT_SECURITY,
|
||||
"region" = 2,
|
||||
"head" = "Head of Security"
|
||||
),
|
||||
"[ACCESS_CMO]" = list(
|
||||
"department" = CARDCON_DEPARTMENT_MEDICAL,
|
||||
"region" = 3,
|
||||
"head" = "Chief Medical Officer"
|
||||
),
|
||||
"[ACCESS_RD]" = list(
|
||||
"department" = CARDCON_DEPARTMENT_SCIENCE,
|
||||
"region" = 4,
|
||||
"head" = "Research Director"
|
||||
),
|
||||
"[ACCESS_CE]" = list(
|
||||
"department" = CARDCON_DEPARTMENT_ENGINEERING,
|
||||
"region" = 5,
|
||||
"head" = "Chief Engineer"
|
||||
)
|
||||
)
|
||||
|
||||
/datum/computer_file/program/card_mod/New()
|
||||
..()
|
||||
addtimer(CALLBACK(src, .proc/SetConfigCooldown), 0)
|
||||
/datum/computer_file/program/card_mod/proc/authenticate(mob/user, obj/item/card/id/id_card)
|
||||
if(!id_card)
|
||||
return
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/SetConfigCooldown()
|
||||
change_position_cooldown = CONFIG_GET(number/id_console_jobslot_delay)
|
||||
region_access = list()
|
||||
if(!target_dept && (ACCESS_CHANGE_IDS in id_card.access))
|
||||
minor = FALSE
|
||||
authenticated = TRUE
|
||||
update_static_data(user)
|
||||
return TRUE
|
||||
|
||||
/datum/computer_file/program/card_mod/event_idremoved(background, slot)
|
||||
if(!slot || slot == 2)// slot being false means both are removed
|
||||
minor = 0
|
||||
authenticated = 0
|
||||
head_subordinates = null
|
||||
region_access = null
|
||||
var/list/head_types = list()
|
||||
for(var/access_text in sub_managers)
|
||||
var/list/info = sub_managers[access_text]
|
||||
var/access = text2num(access_text)
|
||||
if((access in id_card.access) && ((info["region"] in target_dept) || !length(target_dept)))
|
||||
region_access += info["region"]
|
||||
//I don't even know what I'm doing anymore
|
||||
head_types += info["head"]
|
||||
|
||||
head_subordinates = list()
|
||||
if(length(head_types))
|
||||
for(var/j in SSjob.occupations)
|
||||
var/datum/job/job = j
|
||||
for(var/head in head_types)//god why
|
||||
if(head in job.department_head)
|
||||
head_subordinates += job.title
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/job_blacklisted(jobtitle)
|
||||
return (jobtitle in blacklisted)
|
||||
if(length(region_access))
|
||||
minor = TRUE
|
||||
authenticated = TRUE
|
||||
update_static_data(user)
|
||||
return TRUE
|
||||
|
||||
|
||||
//Logic check for if you can open the job
|
||||
/datum/computer_file/program/card_mod/proc/can_open_job(datum/job/job)
|
||||
if(job)
|
||||
if(!job_blacklisted(job.title))
|
||||
if((job.total_positions <= GLOB.player_list.len * (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 1
|
||||
return -2
|
||||
return 0
|
||||
return 0
|
||||
|
||||
//Logic check for if you can close the job
|
||||
/datum/computer_file/program/card_mod/proc/can_close_job(datum/job/job)
|
||||
if(job)
|
||||
if(!job_blacklisted(job.title))
|
||||
if(job.total_positions > job.current_positions)
|
||||
var/delta = (world.time / 10) - GLOB.time_last_changed_position
|
||||
if((change_position_cooldown < delta) || (opened_positions[job.title] > 0))
|
||||
return 1
|
||||
return -2
|
||||
return 0
|
||||
return 0
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/format_jobs(list/jobs)
|
||||
var/obj/item/computer_hardware/card_slot/card_slot = computer.all_components[MC_CARD]
|
||||
var/obj/item/card/id/id_card = card_slot.stored_card
|
||||
var/list/formatted = list()
|
||||
for(var/job in jobs)
|
||||
formatted.Add(list(list(
|
||||
"display_name" = replacetext(job, " ", " "),
|
||||
"target_rank" = id_card && id_card.assignment ? id_card.assignment : "Unassigned",
|
||||
"job" = job)))
|
||||
|
||||
return formatted
|
||||
return FALSE
|
||||
|
||||
/datum/computer_file/program/card_mod/ui_act(action, params)
|
||||
if(..())
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
var/obj/item/computer_hardware/card_slot/card_slot
|
||||
var/obj/item/computer_hardware/printer/printer
|
||||
@@ -106,192 +107,220 @@
|
||||
if(!card_slot)
|
||||
return
|
||||
|
||||
var/obj/item/card/id/user_id_card = null
|
||||
var/mob/user = usr
|
||||
var/obj/item/card/id/user_id_card = user.get_idcard(FALSE)
|
||||
|
||||
var/obj/item/card/id/id_card = card_slot.stored_card
|
||||
var/obj/item/card/id/auth_card = card_slot.stored_card2
|
||||
|
||||
if(auth_card)
|
||||
user_id_card = auth_card
|
||||
else
|
||||
if(ishuman(user))
|
||||
var/mob/living/carbon/human/h = user
|
||||
user_id_card = h.get_idcard(TRUE)
|
||||
|
||||
switch(action)
|
||||
if("PRG_switchm")
|
||||
if(params["target"] == "mod")
|
||||
mod_mode = 1
|
||||
else if (params["target"] == "manifest")
|
||||
mod_mode = 0
|
||||
else if (params["target"] == "manage")
|
||||
mod_mode = 2
|
||||
if("PRG_togglea")
|
||||
if(show_assignments)
|
||||
show_assignments = 0
|
||||
else
|
||||
show_assignments = 1
|
||||
if("PRG_authenticate")
|
||||
if(!computer || !user_id_card)
|
||||
playsound(computer, 'sound/machines/terminal_prompt_deny.ogg', 50, FALSE)
|
||||
return
|
||||
if(authenticate(user, user_id_card))
|
||||
playsound(computer, 'sound/machines/terminal_on.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_logout")
|
||||
authenticated = FALSE
|
||||
playsound(computer, 'sound/machines/terminal_off.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_print")
|
||||
if(computer && printer) //This option should never be called if there is no printer
|
||||
if(mod_mode)
|
||||
if(authorized())
|
||||
var/contents = {"<h4>Access Report</h4>
|
||||
<u>Prepared By:</u> [user_id_card && user_id_card.registered_name ? user_id_card.registered_name : "Unknown"]<br>
|
||||
<u>For:</u> [id_card.registered_name ? id_card.registered_name : "Unregistered"]<br>
|
||||
<hr>
|
||||
<u>Assignment:</u> [id_card.assignment]<br>
|
||||
<u>Access:</u><br>
|
||||
"}
|
||||
if(!computer || !printer)
|
||||
return
|
||||
if(!authenticated)
|
||||
return
|
||||
var/contents = {"<h4>Access Report</h4>
|
||||
<u>Prepared By:</u> [user_id_card && user_id_card.registered_name ? user_id_card.registered_name : "Unknown"]<br>
|
||||
<u>For:</u> [id_card.registered_name ? id_card.registered_name : "Unregistered"]<br>
|
||||
<hr>
|
||||
<u>Assignment:</u> [id_card.assignment]<br>
|
||||
<u>Access:</u><br>
|
||||
"}
|
||||
|
||||
var/known_access_rights = get_all_accesses()
|
||||
for(var/A in id_card.access)
|
||||
if(A in known_access_rights)
|
||||
contents += " [get_access_desc(A)]"
|
||||
var/known_access_rights = get_all_accesses()
|
||||
for(var/A in id_card.access)
|
||||
if(A in known_access_rights)
|
||||
contents += " [get_access_desc(A)]"
|
||||
|
||||
if(!printer.print_text(contents,"access report"))
|
||||
to_chat(usr, "<span class='notice'>Hardware error: Printer was unable to print the file. It may be out of paper.</span>")
|
||||
return
|
||||
else
|
||||
computer.visible_message("<span class='notice'>\The [computer] prints out paper.</span>")
|
||||
else
|
||||
var/contents = {"<h4>Crew Manifest</h4>
|
||||
<br>
|
||||
[GLOB.data_core ? GLOB.data_core.get_manifest(0) : ""]
|
||||
"}
|
||||
if(!printer.print_text(contents,text("crew manifest ([])", station_time_timestamp())))
|
||||
to_chat(usr, "<span class='notice'>Hardware error: Printer was unable to print the file. It may be out of paper.</span>")
|
||||
return
|
||||
else
|
||||
computer.visible_message("<span class='notice'>\The [computer] prints out paper.</span>")
|
||||
if("PRG_eject")
|
||||
if(computer && card_slot)
|
||||
var/select = params["target"]
|
||||
switch(select)
|
||||
if("id")
|
||||
if(id_card)
|
||||
GLOB.data_core.manifest_modify(id_card.registered_name, id_card.assignment)
|
||||
card_slot.try_eject(1, user)
|
||||
else
|
||||
var/obj/item/I = usr.get_active_held_item()
|
||||
if (istype(I, /obj/item/card/id))
|
||||
if(!usr.transferItemToLoc(I, computer))
|
||||
return
|
||||
card_slot.stored_card = I
|
||||
if("auth")
|
||||
if(auth_card)
|
||||
if(id_card)
|
||||
GLOB.data_core.manifest_modify(id_card.registered_name, id_card.assignment)
|
||||
head_subordinates = null
|
||||
region_access = null
|
||||
authenticated = 0
|
||||
minor = 0
|
||||
card_slot.try_eject(2, user)
|
||||
else
|
||||
var/obj/item/I = usr.get_active_held_item()
|
||||
if (istype(I, /obj/item/card/id))
|
||||
if(!usr.transferItemToLoc(I, computer))
|
||||
return
|
||||
card_slot.stored_card2 = I
|
||||
if("PRG_terminate")
|
||||
if(computer && ((id_card.assignment in head_subordinates) || id_card.assignment == "Assistant"))
|
||||
id_card.assignment = "Unassigned"
|
||||
remove_nt_access(id_card)
|
||||
id_card.update_label()
|
||||
|
||||
if("PRG_edit")
|
||||
if(computer && authorized())
|
||||
if(params["name"])
|
||||
var/temp_name = reject_bad_name(input("Enter name.", "Name", id_card.registered_name))
|
||||
if(temp_name)
|
||||
id_card.registered_name = temp_name
|
||||
id_card.update_label()
|
||||
else
|
||||
computer.visible_message("<span class='notice'>[computer] buzzes rudely.</span>")
|
||||
//else if(params["account"])
|
||||
// var/account_num = text2num(input("Enter account number.", "Account", id_card.associated_account_number))
|
||||
// id_card.associated_account_number = account_num
|
||||
if("PRG_assign")
|
||||
if(computer && authorized() && id_card)
|
||||
var/t1 = params["assign_target"]
|
||||
if(t1 == "Custom")
|
||||
var/temp_t = reject_bad_text(input("Enter a custom job assignment.","Assignment", id_card.assignment), 45)
|
||||
//let custom jobs function as an impromptu alt title, mainly for sechuds
|
||||
if(temp_t)
|
||||
id_card.assignment = temp_t
|
||||
else
|
||||
var/list/access = list()
|
||||
if(is_centcom)
|
||||
access = get_centcom_access(t1)
|
||||
else
|
||||
var/datum/job/jobdatum
|
||||
for(var/jobtype in typesof(/datum/job))
|
||||
var/datum/job/J = new jobtype
|
||||
if(ckey(J.title) == ckey(t1))
|
||||
jobdatum = J
|
||||
break
|
||||
if(!jobdatum)
|
||||
to_chat(usr, "<span class='warning'>No log exists for this job: [t1]</span>")
|
||||
return
|
||||
|
||||
access = jobdatum.get_access()
|
||||
|
||||
remove_nt_access(id_card)
|
||||
apply_access(id_card, access)
|
||||
id_card.assignment = t1
|
||||
id_card.update_label()
|
||||
|
||||
if("PRG_access")
|
||||
if(params["allowed"] && computer && authorized())
|
||||
var/access_type = text2num(params["access_target"])
|
||||
var/access_allowed = text2num(params["allowed"])
|
||||
if(access_type in (is_centcom ? get_all_centcom_access() : get_all_accesses()))
|
||||
id_card.access -= access_type
|
||||
if(!access_allowed)
|
||||
id_card.access += access_type
|
||||
if("PRG_open_job")
|
||||
var/edit_job_target = params["target"]
|
||||
var/datum/job/j = SSjob.GetJob(edit_job_target)
|
||||
if(!j)
|
||||
return 0
|
||||
if(can_open_job(j) != 1)
|
||||
return 0
|
||||
if(opened_positions[edit_job_target] >= 0)
|
||||
GLOB.time_last_changed_position = world.time / 10
|
||||
j.total_positions++
|
||||
opened_positions[edit_job_target]++
|
||||
if("PRG_close_job")
|
||||
var/edit_job_target = params["target"]
|
||||
var/datum/job/j = SSjob.GetJob(edit_job_target)
|
||||
if(!j)
|
||||
return 0
|
||||
if(can_close_job(j) != 1)
|
||||
return 0
|
||||
//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]--
|
||||
if("PRG_regsel")
|
||||
if(!reg_ids)
|
||||
reg_ids = list()
|
||||
var/regsel = text2num(params["region"])
|
||||
if(regsel in reg_ids)
|
||||
reg_ids -= regsel
|
||||
if(!printer.print_text(contents,"access report"))
|
||||
to_chat(usr, "<span class='notice'>Hardware error: Printer was unable to print the file. It may be out of paper.</span>")
|
||||
return
|
||||
else
|
||||
reg_ids += regsel
|
||||
playsound(computer, 'sound/machines/terminal_on.ogg', 50, FALSE)
|
||||
computer.visible_message("<span class='notice'>\The [computer] prints out a paper.</span>")
|
||||
return TRUE
|
||||
if("PRG_eject")
|
||||
if(!computer || !card_slot)
|
||||
return
|
||||
if(id_card)
|
||||
GLOB.data_core.manifest_modify(id_card.registered_name, id_card.assignment)
|
||||
card_slot.try_eject(TRUE, user)
|
||||
else
|
||||
var/obj/item/I = user.get_active_held_item()
|
||||
if(istype(I, /obj/item/card/id))
|
||||
if(!user.transferItemToLoc(I, computer))
|
||||
return
|
||||
card_slot.stored_card = I
|
||||
playsound(computer, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_terminate")
|
||||
if(!computer || !authenticated)
|
||||
return
|
||||
if(minor)
|
||||
if(!(id_card.assignment in head_subordinates) && id_card.assignment != "Assistant")
|
||||
return
|
||||
|
||||
return 1
|
||||
id_card.access -= get_all_centcom_access() + get_all_accesses()
|
||||
id_card.assignment = "Unassigned"
|
||||
id_card.update_label()
|
||||
playsound(computer, 'sound/machines/terminal_prompt_deny.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_edit")
|
||||
if(!computer || !authenticated || !id_card)
|
||||
return
|
||||
var/new_name = params["name"]
|
||||
if(!new_name)
|
||||
return
|
||||
id_card.registered_name = new_name
|
||||
id_card.update_label()
|
||||
playsound(computer, "terminal_type", 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_assign")
|
||||
if(!computer || !authenticated || !id_card)
|
||||
return
|
||||
var/target = params["assign_target"]
|
||||
if(!target)
|
||||
return
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/remove_nt_access(obj/item/card/id/id_card)
|
||||
id_card.access -= get_all_accesses()
|
||||
id_card.access -= get_all_centcom_access()
|
||||
if(target == "Custom")
|
||||
var/custom_name = params["custom_name"]
|
||||
if(custom_name)
|
||||
id_card.assignment = custom_name
|
||||
id_card.update_label()
|
||||
else
|
||||
if(minor && !(target in head_subordinates))
|
||||
return
|
||||
var/list/new_access = list()
|
||||
if(is_centcom)
|
||||
new_access = get_centcom_access(target)
|
||||
else
|
||||
var/datum/job/job
|
||||
for(var/jobtype in subtypesof(/datum/job))
|
||||
var/datum/job/J = new jobtype
|
||||
if(J.title == target)
|
||||
job = J
|
||||
break
|
||||
if(!job)
|
||||
to_chat(user, "<span class='warning'>No class exists for this job: [target]</span>")
|
||||
return
|
||||
new_access = job.get_access()
|
||||
id_card.access -= get_all_centcom_access() + get_all_accesses()
|
||||
id_card.access |= new_access
|
||||
id_card.assignment = target
|
||||
id_card.update_label()
|
||||
playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_access")
|
||||
if(!computer || !authenticated)
|
||||
return
|
||||
var/access_type = text2num(params["access_target"])
|
||||
if(access_type in (is_centcom ? get_all_centcom_access() : get_all_accesses()))
|
||||
if(access_type in id_card.access)
|
||||
id_card.access -= access_type
|
||||
else
|
||||
id_card.access |= access_type
|
||||
playsound(computer, "terminal_type", 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_grantall")
|
||||
if(!computer || !authenticated)
|
||||
return
|
||||
id_card.access |= (is_centcom ? get_all_centcom_access() : get_all_accesses())
|
||||
playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_denyall")
|
||||
if(!computer || !authenticated)
|
||||
return
|
||||
id_card.access.Cut()
|
||||
playsound(computer, 'sound/machines/terminal_prompt_deny.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_grantregion")
|
||||
if(!computer || !authenticated)
|
||||
return
|
||||
var/region = text2num(params["region"])
|
||||
if(isnull(region))
|
||||
return
|
||||
id_card.access |= get_region_accesses(region)
|
||||
playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
if("PRG_denyregion")
|
||||
if(!computer || !authenticated)
|
||||
return
|
||||
var/region = text2num(params["region"])
|
||||
if(isnull(region))
|
||||
return
|
||||
id_card.access -= get_region_accesses(region)
|
||||
playsound(computer, 'sound/machines/terminal_prompt_deny.ogg', 50, FALSE)
|
||||
return TRUE
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/apply_access(obj/item/card/id/id_card, list/accesses)
|
||||
id_card.access |= accesses
|
||||
|
||||
|
||||
/datum/computer_file/program/card_mod/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["station_name"] = station_name()
|
||||
data["centcom_access"] = is_centcom
|
||||
data["minor"] = target_dept || minor ? TRUE : FALSE
|
||||
|
||||
var/list/departments = target_dept
|
||||
if(is_centcom)
|
||||
departments = list("Centcom" = get_all_centcom_jobs())
|
||||
else if(isnull(departments))
|
||||
departments = list(
|
||||
CARDCON_DEPARTMENT_COMMAND = list("Captain"),//lol
|
||||
CARDCON_DEPARTMENT_ENGINEERING = GLOB.engineering_positions,
|
||||
CARDCON_DEPARTMENT_MEDICAL = GLOB.medical_positions,
|
||||
CARDCON_DEPARTMENT_SCIENCE = GLOB.science_positions,
|
||||
CARDCON_DEPARTMENT_SECURITY = GLOB.security_positions,
|
||||
CARDCON_DEPARTMENT_SUPPLY = GLOB.supply_positions,
|
||||
CARDCON_DEPARTMENT_SERVICE = GLOB.civilian_positions
|
||||
)
|
||||
data["jobs"] = list()
|
||||
for(var/department in departments)
|
||||
var/list/job_list = departments[department]
|
||||
var/list/department_jobs = list()
|
||||
for(var/job in job_list)
|
||||
if(minor && !(job in head_subordinates))
|
||||
continue
|
||||
department_jobs += list(list(
|
||||
"display_name" = replacetext(job, " ", " "),
|
||||
"job" = job
|
||||
))
|
||||
if(length(department_jobs))
|
||||
data["jobs"][department] = department_jobs
|
||||
|
||||
var/list/regions = list()
|
||||
for(var/i in 1 to 7)
|
||||
if((minor || target_dept) && !(i in region_access))
|
||||
continue
|
||||
|
||||
var/list/accesses = list()
|
||||
for(var/access in get_region_accesses(i))
|
||||
if (get_access_desc(access))
|
||||
accesses += list(list(
|
||||
"desc" = replacetext(get_access_desc(access), " ", " "),
|
||||
"ref" = access,
|
||||
))
|
||||
|
||||
regions += list(list(
|
||||
"name" = get_region_accesses_name(i),
|
||||
"regid" = i,
|
||||
"accesses" = accesses
|
||||
))
|
||||
|
||||
data["regions"] = regions
|
||||
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/card_mod/ui_data(mob/user)
|
||||
|
||||
var/list/data = get_header_data()
|
||||
|
||||
var/obj/item/computer_hardware/card_slot/card_slot
|
||||
@@ -301,181 +330,34 @@
|
||||
card_slot = computer.all_components[MC_CARD]
|
||||
printer = computer.all_components[MC_PRINT]
|
||||
|
||||
data["mmode"] = mod_mode
|
||||
|
||||
var/authed = 0
|
||||
if(computer)
|
||||
if(card_slot)
|
||||
var/obj/item/card/id/auth_card = card_slot.stored_card2
|
||||
data["auth_name"] = auth_card ? strip_html_simple(auth_card.name) : "-----"
|
||||
authed = authorized()
|
||||
|
||||
|
||||
if(mod_mode == 2)
|
||||
data["slots"] = list()
|
||||
var/list/pos = list()
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
if(job.title in blacklisted)
|
||||
continue
|
||||
|
||||
var/list/status_open = build_manage(job,1)
|
||||
var/list/status_close = build_manage(job,0)
|
||||
|
||||
pos.Add(list(list(
|
||||
"title" = job.title,
|
||||
"current" = job.current_positions,
|
||||
"total" = job.total_positions,
|
||||
"status_open" = (authed && !minor) ? status_open["enable"]: 0,
|
||||
"status_close" = (authed && !minor) ? status_close["enable"] : 0,
|
||||
"desc_open" = status_open["desc"],
|
||||
"desc_close" = status_close["desc"])))
|
||||
data["slots"] = pos
|
||||
|
||||
data["src"] = "[REF(src)]"
|
||||
data["station_name"] = station_name()
|
||||
|
||||
|
||||
if(!mod_mode)
|
||||
data["manifest"] = list()
|
||||
var/list/crew = list()
|
||||
for(var/datum/data/record/t in sortRecord(GLOB.data_core.general))
|
||||
crew.Add(list(list(
|
||||
"name" = t.fields["name"],
|
||||
"rank" = t.fields["rank"])))
|
||||
|
||||
data["manifest"] = crew
|
||||
data["assignments"] = show_assignments
|
||||
if(computer)
|
||||
data["have_id_slot"] = !!card_slot
|
||||
data["have_printer"] = !!printer
|
||||
if(!card_slot && mod_mode == 1)
|
||||
mod_mode = 0 //We can't modify IDs when there is no card reader
|
||||
else
|
||||
data["have_id_slot"] = 0
|
||||
data["have_printer"] = 0
|
||||
data["have_id_slot"] = FALSE
|
||||
data["have_printer"] = FALSE
|
||||
|
||||
data["centcom_access"] = is_centcom
|
||||
|
||||
|
||||
data["authenticated"] = authed
|
||||
|
||||
|
||||
if(mod_mode == 1 && computer)
|
||||
if(card_slot)
|
||||
var/obj/item/card/id/id_card = card_slot.stored_card
|
||||
|
||||
data["has_id"] = !!id_card
|
||||
data["id_rank"] = id_card && id_card.assignment ? html_encode(id_card.assignment) : "Unassigned"
|
||||
data["id_owner"] = id_card && id_card.registered_name ? html_encode(id_card.registered_name) : "-----"
|
||||
data["id_name"] = id_card ? strip_html_simple(id_card.name) : "-----"
|
||||
|
||||
if(show_assignments)
|
||||
data["engineering_jobs"] = format_jobs(GLOB.engineering_positions)
|
||||
data["medical_jobs"] = format_jobs(GLOB.medical_positions)
|
||||
data["science_jobs"] = format_jobs(GLOB.science_positions)
|
||||
data["security_jobs"] = format_jobs(GLOB.security_positions)
|
||||
data["cargo_jobs"] = format_jobs(GLOB.supply_positions)
|
||||
data["civilian_jobs"] = format_jobs(GLOB.civilian_positions)
|
||||
data["centcom_jobs"] = format_jobs(get_all_centcom_jobs())
|
||||
|
||||
|
||||
if(card_slot.stored_card)
|
||||
var/obj/item/card/id/id_card = card_slot.stored_card
|
||||
if(is_centcom)
|
||||
var/list/all_centcom_access = list()
|
||||
for(var/access in get_all_centcom_access())
|
||||
all_centcom_access.Add(list(list(
|
||||
"desc" = replacetext(get_centcom_access_desc(access), " ", " "),
|
||||
"ref" = access,
|
||||
"allowed" = (access in id_card.access) ? 1 : 0)))
|
||||
data["all_centcom_access"] = all_centcom_access
|
||||
else
|
||||
var/list/regions = list()
|
||||
for(var/i = 1; i <= 7; i++)
|
||||
if((minor || target_dept) && !(i in region_access))
|
||||
continue
|
||||
|
||||
var/list/accesses = list()
|
||||
if(i in reg_ids)
|
||||
for(var/access in get_region_accesses(i))
|
||||
if (get_access_desc(access))
|
||||
accesses.Add(list(list(
|
||||
"desc" = replacetext(get_access_desc(access), " ", " "),
|
||||
"ref" = access,
|
||||
"allowed" = (access in id_card.access) ? 1 : 0)))
|
||||
|
||||
regions.Add(list(list(
|
||||
"name" = get_region_accesses_name(i),
|
||||
"regid" = i,
|
||||
"selected" = (i in reg_ids) ? 1 : null,
|
||||
"accesses" = accesses)))
|
||||
data["regions"] = regions
|
||||
|
||||
data["minor"] = target_dept || minor ? 1 : 0
|
||||
data["authenticated"] = authenticated
|
||||
|
||||
if(computer)
|
||||
var/obj/item/card/id/id_card = card_slot.stored_card
|
||||
data["has_id"] = !!id_card
|
||||
data["id_name"] = id_card ? id_card.name : "-----"
|
||||
if(id_card)
|
||||
data["id_rank"] = id_card.assignment ? id_card.assignment : "Unassigned"
|
||||
data["id_owner"] = id_card.registered_name ? id_card.registered_name : "-----"
|
||||
data["access_on_card"] = id_card.access
|
||||
|
||||
return data
|
||||
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/build_manage(datum/job,open = FALSE)
|
||||
var/out = "Denied"
|
||||
var/can_change= 0
|
||||
if(open)
|
||||
can_change = can_open_job(job)
|
||||
else
|
||||
can_change = can_close_job(job)
|
||||
var/enable = 0
|
||||
if(can_change == 1)
|
||||
out = "[open ? "Open Position" : "Close Position"]"
|
||||
enable = 1
|
||||
else if(can_change == -2)
|
||||
var/time_to_wait = round(change_position_cooldown - ((world.time / 10) - GLOB.time_last_changed_position), 1)
|
||||
var/mins = round(time_to_wait / 60)
|
||||
var/seconds = time_to_wait - (60*mins)
|
||||
out = "Cooldown ongoing: [mins]:[(seconds < 10) ? "0[seconds]" : "[seconds]"]"
|
||||
else
|
||||
out = "Denied"
|
||||
|
||||
return list("enable" = enable, "desc" = out)
|
||||
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/authorized()
|
||||
if(!authenticated && computer)
|
||||
var/obj/item/computer_hardware/card_slot/card_slot = computer.all_components[MC_CARD]
|
||||
if(card_slot)
|
||||
var/obj/item/card/id/auth_card = card_slot.stored_card2
|
||||
if(auth_card)
|
||||
region_access = list()
|
||||
if(ACCESS_CHANGE_IDS in auth_card.GetAccess())
|
||||
minor = 0
|
||||
authenticated = 1
|
||||
return 1
|
||||
else
|
||||
if((ACCESS_HOP in auth_card.access) && ((target_dept==1) || !target_dept))
|
||||
region_access |= 1
|
||||
region_access |= 6
|
||||
get_subordinates("Head of Personnel")
|
||||
if((ACCESS_HOS in auth_card.access) && ((target_dept==2) || !target_dept))
|
||||
region_access |= 2
|
||||
get_subordinates("Head of Security")
|
||||
if((ACCESS_CMO in auth_card.access) && ((target_dept==3) || !target_dept))
|
||||
region_access |= 3
|
||||
get_subordinates("Chief Medical Officer")
|
||||
if((ACCESS_RD in auth_card.access) && ((target_dept==4) || !target_dept))
|
||||
region_access |= 4
|
||||
get_subordinates("Research Director")
|
||||
if((ACCESS_CE in auth_card.access) && ((target_dept==5) || !target_dept))
|
||||
region_access |= 5
|
||||
get_subordinates("Chief Engineer")
|
||||
if(region_access.len)
|
||||
minor = 1
|
||||
authenticated = 1
|
||||
return 1
|
||||
else
|
||||
return authenticated
|
||||
|
||||
/datum/computer_file/program/card_mod/proc/get_subordinates(rank)
|
||||
head_subordinates = list()
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
if(rank in job.department_head)
|
||||
head_subordinates += job.title
|
||||
#undef CARDCON_DEPARTMENT_SERVICE
|
||||
#undef CARDCON_DEPARTMENT_SECURITY
|
||||
#undef CARDCON_DEPARTMENT_MEDICAL
|
||||
#undef CARDCON_DEPARTMENT_SCIENCE
|
||||
#undef CARDCON_DEPARTMENT_SUPPLY
|
||||
#undef CARDCON_DEPARTMENT_ENGINEERING
|
||||
#undef CARDCON_DEPARTMENT_COMMAND
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/datum/computer_file/program/crew_manifest
|
||||
filename = "crewmani"
|
||||
filedesc = "Crew Manifest"
|
||||
program_icon_state = "id"
|
||||
extended_desc = "Program for viewing and printing the current crew manifest"
|
||||
transfer_access = ACCESS_HEADS
|
||||
requires_ntnet = FALSE
|
||||
size = 4
|
||||
tgui_id = "ntos_crew_manifest"
|
||||
ui_x = 400
|
||||
ui_y = 480
|
||||
|
||||
/datum/computer_file/program/crew_manifest/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["manifest"] = GLOB.data_core.get_manifest()
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/crew_manifest/ui_data(mob/user)
|
||||
var/list/data = get_header_data()
|
||||
|
||||
var/obj/item/computer_hardware/printer/printer
|
||||
if(computer)
|
||||
printer = computer.all_components[MC_PRINT]
|
||||
|
||||
if(computer)
|
||||
data["have_printer"] = !!printer
|
||||
else
|
||||
data["have_printer"] = FALSE
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/crew_manifest/ui_act(action, params, datum/tgui/ui)
|
||||
if(..())
|
||||
return
|
||||
|
||||
var/obj/item/computer_hardware/printer/printer
|
||||
if(computer)
|
||||
printer = computer.all_components[MC_PRINT]
|
||||
|
||||
switch(action)
|
||||
if("PRG_print")
|
||||
if(computer && printer) //This option should never be called if there is no printer
|
||||
var/contents = {"<h4>Crew Manifest</h4>
|
||||
<br>
|
||||
[GLOB.data_core ? GLOB.data_core.get_manifest_html(0) : ""]
|
||||
"}
|
||||
if(!printer.print_text(contents,text("crew manifest ([])", station_time_timestamp())))
|
||||
to_chat(usr, "<span class='notice'>Hardware error: Printer was unable to print the file. It may be out of paper.</span>")
|
||||
return
|
||||
else
|
||||
computer.visible_message("<span class='notice'>\The [computer] prints out a paper.</span>")
|
||||
@@ -0,0 +1,141 @@
|
||||
/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
|
||||
|
||||
Reference in New Issue
Block a user