[MIRROR] Convert occupation bay prefs to TG (#12732)

Co-authored-by: Aura Dusklight <46622484+NovaDusklight@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2026-05-03 16:40:44 -07:00
committed by GitHub
parent 9252f1e6d6
commit ff988d2502
8 changed files with 563 additions and 37 deletions
-17
View File
@@ -58,22 +58,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
"PMHjiggle" = "character_preview_map:102,7:107",
)
//Jobs, uses bitflags
var/job_civilian_high = 0
var/job_civilian_med = 0
var/job_civilian_low = 0
var/job_medsci_high = 0
var/job_medsci_med = 0
var/job_medsci_low = 0
var/job_engsec_high = 0
var/job_engsec_med = 0
var/job_engsec_low = 0
//Keeps track of preferrence for not getting any wanted jobs
var/alternate_option = 1
//character preferences
var/slot_randomized //keeps track of round-to-round randomization of the character slot, prevents overwriting
@@ -81,7 +65,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
// maps each organ to either null(intact), "cyborg" or "amputated"
// will probably not be able to do this for head and torso ;)
var/list/player_alt_titles = new() // the default name of a job like JOB_MEDICAL_DOCTOR
var/list/body_markings = list() // "name" = "#rgbcolor" //VOREStation Edit: "name" = list(BP_HEAD = list("on" = <enabled>, "color" = "#rgbcolor"), BP_TORSO = ...)
@@ -0,0 +1,545 @@
// Occupation preferences
// Stores job priority bitflags, alt titles, and bay UI bridge.
// Job bitflag preferences (0-65535)
/datum/preference/numeric/human/job_civilian_high
savefile_key = "job_civilian_high"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_civilian_high/create_default_value()
return 0
/datum/preference/numeric/human/job_civilian_high/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_civilian_med
savefile_key = "job_civilian_med"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_civilian_med/create_default_value()
return 0
/datum/preference/numeric/human/job_civilian_med/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_civilian_low
savefile_key = "job_civilian_low"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_civilian_low/create_default_value()
return 0
/datum/preference/numeric/human/job_civilian_low/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_medsci_high
savefile_key = "job_medsci_high"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_medsci_high/create_default_value()
return 0
/datum/preference/numeric/human/job_medsci_high/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_medsci_med
savefile_key = "job_medsci_med"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_medsci_med/create_default_value()
return 0
/datum/preference/numeric/human/job_medsci_med/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_medsci_low
savefile_key = "job_medsci_low"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_medsci_low/create_default_value()
return 0
/datum/preference/numeric/human/job_medsci_low/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_engsec_high
savefile_key = "job_engsec_high"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_engsec_high/create_default_value()
return 0
/datum/preference/numeric/human/job_engsec_high/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_engsec_med
savefile_key = "job_engsec_med"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_engsec_med/create_default_value()
return 0
/datum/preference/numeric/human/job_engsec_med/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_engsec_low
savefile_key = "job_engsec_low"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_engsec_low/create_default_value()
return 0
/datum/preference/numeric/human/job_engsec_low/apply_to_human(mob/living/carbon/human/target, value)
return
// VOREStation Add - Talon job bitflags
/datum/preference/numeric/human/job_talon_high
savefile_key = "job_talon_high"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_talon_high/create_default_value()
return 0
/datum/preference/numeric/human/job_talon_high/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_talon_med
savefile_key = "job_talon_med"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_talon_med/create_default_value()
return 0
/datum/preference/numeric/human/job_talon_med/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/job_talon_low
savefile_key = "job_talon_low"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 65535
/datum/preference/numeric/human/job_talon_low/create_default_value()
return 0
/datum/preference/numeric/human/job_talon_low/apply_to_human(mob/living/carbon/human/target, value)
return
// VOREStation Add End
// Alternate option preference (0-2)
/datum/preference/numeric/human/alternate_option
savefile_key = "alternate_option"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
minimum = 0
maximum = 2
/datum/preference/numeric/human/alternate_option/create_default_value()
return 1
/datum/preference/numeric/human/alternate_option/apply_to_human(mob/living/carbon/human/target, value)
return
// Player alt titles preference (assoc list)
/datum/preference/player_alt_titles
savefile_key = "player_alt_titles"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
can_randomize = FALSE
/datum/preference/player_alt_titles/create_default_value()
return list()
/datum/preference/player_alt_titles/pref_deserialize(input, datum/preferences/preferences)
if(!islist(input))
return list()
return input
/datum/preference/player_alt_titles/pref_serialize(input)
if(!islist(input))
return list()
return check_list_copy(input)
/datum/preference/player_alt_titles/is_valid(value)
return islist(value)
/datum/preference/player_alt_titles/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/player_alt_titles/apply_to_living(mob/living/target, value)
return
/datum/preference/player_alt_titles/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/player_alt_titles/apply_to_animal(mob/living/simple_mob/target, value)
return
// ---- Bay UI Bridge ----
/datum/category_item/player_setup_item/occupation
name = "Occupation"
sort_order = 1
/datum/category_item/player_setup_item/occupation/load_character(list/save_data)
return // Handled by TG preference system
/datum/category_item/player_setup_item/occupation/save_character(list/save_data)
return // Handled by TG preference system
/datum/category_item/player_setup_item/occupation/sanitize_character()
return // Handled by TG preference system
/datum/category_item/player_setup_item/occupation/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
var/list/data = ..()
var/list/jobs_data = list()
var/list/all_valid_jobs = list()
for(var/D in SSjob.department_datums)
var/datum/department/department = SSjob.department_datums[D]
if(department.centcom_only) // No joining as a centcom role, if any are ever added.
continue
for(var/J in department.primary_jobs)
all_valid_jobs += department.jobs[J]
jobs_data[department.name] = list()
for(var/datum/job/job in all_valid_jobs)
if(job.latejoin_only)
continue
var/datum/department/current_department = SSjob.get_primary_department_of_job(job)
// for the is_job_whitelisted check..
usr = user
var/list/job_data = list(
"title" = job.title,
"ref" = REF(job),
"selection_color" = job.selection_color,
// reasons you can't select it
"banned" = !!jobban_isbanned(user, job.title),
"denylist_days" = !job.player_old_enough(user.client),
"available_in_days" = job.available_in_days(user.client),
"denylist_playtime" = !job.player_has_enough_playtime(user.client),
"available_in_hours" = job.available_in_playhours(user.client),
"denylist_whitelist" = !is_job_whitelisted(user, job.title),
// tigercat2000 - these shouldn't exist >:(
"denylist_character_age" = FALSE,
"min_age" = job.get_min_age(pref.read_preference(/datum/preference/choiced/species), pref.read_preference(/datum/preference/organ_data)?[O_BRAIN]),
"special_color" = "",
"selected" = 0,
"selected_title" = "",
"alt_titles" = list(),
)
if((job.minimum_character_age || job.min_age_by_species) && user.client && (user.read_preference(/datum/preference/numeric/human/age) < job.get_min_age(user.client.prefs.read_preference(/datum/preference/choiced/species), user.client.prefs.read_preference(/datum/preference/organ_data)?[O_BRAIN])))
job_data["denylist_character_age"] = TRUE
if((pref.read_preference(/datum/preference/numeric/human/job_civilian_low) & ASSISTANT) && job.type != /datum/job/assistant)
job_data["special_color"] = "gray"
if((job.title in SSjob.get_job_titles_in_department(DEPARTMENT_COMMAND) ) || (job.title == JOB_AI))//Bold head jobs
job_data["special_color"] = "bold"
if(job.type == /datum/job/assistant)//Assistant is special
if(pref.read_preference(/datum/preference/numeric/human/job_civilian_low) & ASSISTANT)
job_data["selected"] = 4
else
job_data["selected"] = 0
else if(pref.GetJobDepartment(job, 1) & job.flag)
job_data["selected"] = 3
else if(pref.GetJobDepartment(job, 2) & job.flag)
job_data["selected"] = 2
else if(pref.GetJobDepartment(job, 3) & job.flag)
job_data["selected"] = 1
else
job_data["selected"] = 0
job_data["selected_title"] = pref.GetPlayerAltTitle(job)
for(var/title in job.alt_titles)
job_data["alt_titles"] += title
UNTYPED_LIST_ADD(jobs_data[current_department.name], job_data)
data["jobs"] = jobs_data
data["alternate_option"] = pref.read_preference(/datum/preference/numeric/human/alternate_option)
return data
/datum/category_item/player_setup_item/occupation/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
. = ..()
if(.)
return
var/mob/user = ui.user
switch(action)
if("reset_jobs")
ResetJobs()
return TOPIC_REFRESH_UPDATE_PREVIEW
if("job_alternative")
var/current = pref.read_preference(/datum/preference/numeric/human/alternate_option)
if(current == GET_RANDOM_JOB || current == BE_ASSISTANT)
pref.write_preference_by_type(/datum/preference/numeric/human/alternate_option, current + 1)
else if(current == RETURN_TO_LOBBY)
pref.write_preference_by_type(/datum/preference/numeric/human/alternate_option, 0)
return TOPIC_REFRESH
if("select_alt_title")
var/datum/job/J = locate(params["job"])
if(istype(J))
var/choices = list(J.title) + J.alt_titles
var/choice = tgui_input_list(user, "Choose a title for [J.title].", "Choose Title", choices, pref.GetPlayerAltTitle(J))
if(choice)
SetPlayerAltTitle(J, choice)
return TOPIC_REFRESH_UPDATE_PREVIEW
if("set_job")
if(SetJob(user, params["set_job"], text2num(params["level"])))
return TOPIC_REFRESH_UPDATE_PREVIEW
return TOPIC_HANDLED
if("job_info")
var/rank = params["rank"]
var/datum/job/job = SSjob.get_job(rank)
if(!istype(job))
return TOPIC_NOACTION
var/dat = list()
dat += "<p style='background-color: [job.selection_color]'><br><br><p>"
if(job.alt_titles)
dat += span_italics(span_bold("Alternate titles:") + " [english_list(job.alt_titles)].")
send_rsc(user, job.get_job_icon(), "job[ckey(rank)].png")
dat += "<img src=job[ckey(rank)].png width=96 height=96 style='float:left;'>"
if(job.departments)
dat += span_bold("Departments:") + " [english_list(job.departments)]."
if(LAZYLEN(job.departments_managed))
dat += "You manage these departments: [english_list(job.departments_managed)]"
dat += "You answer to " + span_bold("[job.supervisors]") + " normally."
dat += "<hr style='clear:left;'>"
if(CONFIG_GET(string/wikiurl))
dat += "<a href='byond://?src=\ref[src];job_wiki=[rank]'>Open wiki page in browser</a>"
var/alt_title = pref.GetPlayerAltTitle(job)
var/list/description = job.get_description_blurb(alt_title)
if(LAZYLEN(description))
dat += html_encode(description[1])
if(description.len > 1)
if(!isnull(description[2]))
dat += "<br>"
dat += html_encode(description[2])
var/datum/browser/popup = new(user, "Job Info", "[capitalize(rank)]", 430, 520, src)
popup.set_content(jointext(dat,"<br>"))
popup.open()
return TOPIC_HANDLED
// must stay for job popup to work
/datum/category_item/player_setup_item/occupation/OnTopic(href, href_list, user)
if(href_list["job_wiki"])
var/rank = href_list["job_wiki"]
open_link(user,"[CONFIG_GET(string/wikiurl)][rank]")
return ..()
// ---- Helper Procs ----
/datum/category_item/player_setup_item/occupation/proc/SetPlayerAltTitle(datum/job/job, new_title)
var/list/alt_titles = pref.read_preference(/datum/preference/player_alt_titles)
if(!islist(alt_titles))
alt_titles = list()
// remove existing entry
alt_titles -= job.title
// add one if it's not default
if(job.title != new_title)
alt_titles[job.title] = new_title
pref.write_preference_by_type(/datum/preference/player_alt_titles, alt_titles)
/datum/category_item/player_setup_item/occupation/proc/SetJob(mob/user, role, level)
var/datum/job/job = SSjob.get_job(role)
if(!job)
return 0
if(job.type == /datum/job/assistant)
var/current = pref.read_preference(/datum/preference/numeric/human/job_civilian_low)
if(current & job.flag)
pref.write_preference_by_type(/datum/preference/numeric/human/job_civilian_low, current & ~job.flag)
else
pref.write_preference_by_type(/datum/preference/numeric/human/job_civilian_low, current | job.flag)
return 1
SetJobDepartment(job, level)
return 1
/datum/category_item/player_setup_item/occupation/proc/reset_jobhigh()
pref.write_preference_by_type(/datum/preference/numeric/human/job_civilian_med, pref.read_preference(/datum/preference/numeric/human/job_civilian_med) | pref.read_preference(/datum/preference/numeric/human/job_civilian_high))
pref.write_preference_by_type(/datum/preference/numeric/human/job_medsci_med, pref.read_preference(/datum/preference/numeric/human/job_medsci_med) | pref.read_preference(/datum/preference/numeric/human/job_medsci_high))
pref.write_preference_by_type(/datum/preference/numeric/human/job_engsec_med, pref.read_preference(/datum/preference/numeric/human/job_engsec_med) | pref.read_preference(/datum/preference/numeric/human/job_engsec_high))
pref.write_preference_by_type(/datum/preference/numeric/human/job_talon_med, pref.read_preference(/datum/preference/numeric/human/job_talon_med) | pref.read_preference(/datum/preference/numeric/human/job_talon_high)) //VOREStation Add
pref.write_preference_by_type(/datum/preference/numeric/human/job_civilian_high, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_medsci_high, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_engsec_high, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_talon_high, 0) //VOREStation Add
// Level is equal to the desired new level of the job. So for a value of 4, we want to disable the job.
/datum/category_item/player_setup_item/occupation/proc/SetJobDepartment(var/datum/job/job, var/level)
if(!job || !level)
return 0
var/high_type
var/med_type
var/low_type
switch(job.department_flag)
if(CIVILIAN)
high_type = /datum/preference/numeric/human/job_civilian_high
med_type = /datum/preference/numeric/human/job_civilian_med
low_type = /datum/preference/numeric/human/job_civilian_low
if(MEDSCI)
high_type = /datum/preference/numeric/human/job_medsci_high
med_type = /datum/preference/numeric/human/job_medsci_med
low_type = /datum/preference/numeric/human/job_medsci_low
if(ENGSEC)
high_type = /datum/preference/numeric/human/job_engsec_high
med_type = /datum/preference/numeric/human/job_engsec_med
low_type = /datum/preference/numeric/human/job_engsec_low
//VOREStation Add
if(TALON)
high_type = /datum/preference/numeric/human/job_talon_high
med_type = /datum/preference/numeric/human/job_talon_med
low_type = /datum/preference/numeric/human/job_talon_low
//VOREStation Add End
else
return 0
// Clear the job flag from all levels
pref.write_preference_by_type(low_type, pref.read_preference(low_type) & ~job.flag)
pref.write_preference_by_type(med_type, pref.read_preference(med_type) & ~job.flag)
pref.write_preference_by_type(high_type, pref.read_preference(high_type) & ~job.flag)
switch(level)
if(1)
reset_jobhigh()
pref.write_preference_by_type(high_type, job.flag)
if(2)
pref.write_preference_by_type(med_type, pref.read_preference(med_type) | job.flag)
if(3)
pref.write_preference_by_type(low_type, pref.read_preference(low_type) | job.flag)
return 1
/datum/category_item/player_setup_item/occupation/proc/ResetJobs()
pref.write_preference_by_type(/datum/preference/numeric/human/job_civilian_high, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_civilian_med, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_civilian_low, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_medsci_high, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_medsci_med, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_medsci_low, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_engsec_high, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_engsec_med, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_engsec_low, 0)
//VOREStation Add
pref.write_preference_by_type(/datum/preference/numeric/human/job_talon_high, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_talon_med, 0)
pref.write_preference_by_type(/datum/preference/numeric/human/job_talon_low, 0)
//VOREStation Add End
pref.write_preference_by_type(/datum/preference/player_alt_titles, list())
/datum/preferences/proc/GetPlayerAltTitle(datum/job/job)
var/list/alt_titles = read_preference(/datum/preference/player_alt_titles)
return (islist(alt_titles) && (job.title in alt_titles)) ? alt_titles[job.title] : job.title
/datum/preferences/proc/GetJobDepartment(var/datum/job/job, var/level)
if(!job || !level) return 0
switch(job.department_flag)
if(CIVILIAN)
switch(level)
if(1)
return read_preference(/datum/preference/numeric/human/job_civilian_high)
if(2)
return read_preference(/datum/preference/numeric/human/job_civilian_med)
if(3)
return read_preference(/datum/preference/numeric/human/job_civilian_low)
if(MEDSCI)
switch(level)
if(1)
return read_preference(/datum/preference/numeric/human/job_medsci_high)
if(2)
return read_preference(/datum/preference/numeric/human/job_medsci_med)
if(3)
return read_preference(/datum/preference/numeric/human/job_medsci_low)
if(ENGSEC)
switch(level)
if(1)
return read_preference(/datum/preference/numeric/human/job_engsec_high)
if(2)
return read_preference(/datum/preference/numeric/human/job_engsec_med)
if(3)
return read_preference(/datum/preference/numeric/human/job_engsec_low)
//VOREStation Add
if(TALON)
switch(level)
if(1)
return read_preference(/datum/preference/numeric/human/job_talon_high)
if(2)
return read_preference(/datum/preference/numeric/human/job_talon_med)
if(3)
return read_preference(/datum/preference/numeric/human/job_talon_low)
//VOREStation Add End
return 0
-4
View File
@@ -10,10 +10,6 @@
var/auto_backup_implant = FALSE //Whether someone starts with a backup implant or not.
var/borg_petting = TRUE //Whether someone can be petted as a borg or not.
var/job_talon_high = 0
var/job_talon_med = 0
var/job_talon_low = 0
//Why weren't these in game toggles already?
/client/verb/toggle_capture_crystal()
set name = "Toggle Catchable"