From 4eefadc8b4cde7646ea5417192e6aec676c646e7 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Sat, 27 Nov 2021 22:18:45 -0500 Subject: [PATCH] Alternative job titles in the Occupations screen actually used in-game (#9420) * Added alt jobs names actually doing something. * Also add late join announcements. * Fix custom roles showing up first in crew monitor * Cleanup to match upstream changes * Updates from review, also improve both tgui manifests * Compromise for Skyrat edit notes vs JSX vs linter * Compromise for optimization vs not making a horrible mess of passing client around * Follow module rules * Revert no longer true changed to customization readme * Update dme * Fixed comments for alt titles --- code/controllers/subsystem/job.dm | 12 ++++++-- code/datums/datacore.dm | 12 ++++++-- code/modules/admin/verbs/admingame.dm | 2 +- code/modules/jobs/job_types/_job.dm | 9 +++--- .../modules/mob/dead/new_player/new_player.dm | 9 ++++-- .../alternative_job_titles/code/job.dm | 27 ++++++++++++++++++ .../modules/alternative_job_titles/readme.md | 28 +++++++++++++++++++ tgstation.dme | 1 + tgui/packages/tgui/interfaces/CrewManifest.js | 10 ++++--- .../tgui/interfaces/NtosCrewManifest.js | 13 +++++++-- 10 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 modular_skyrat/modules/alternative_job_titles/code/job.dm create mode 100644 modular_skyrat/modules/alternative_job_titles/readme.md diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm index 4e451b544a1..4fd276c1aa7 100644 --- a/code/controllers/subsystem/job.dm +++ b/code/controllers/subsystem/job.dm @@ -516,17 +516,22 @@ SUBSYSTEM_DEF(job) //Gives the player the stuff he should have with his rank /datum/controller/subsystem/job/proc/EquipRank(mob/living/equipping, datum/job/job, client/player_client) + // SKYRAT EDIT ADDITION BEGIN - ALTERNATIVE_JOB_TITLES + // The alt job title, if user picked one, or the default + var/chosen_title = player_client?.prefs.alt_job_titles[job.title] || job.title + // SKYRAT EDIT ADDITION END - ALTERNATIVE_JOB_TITLES + equipping.job = job.title SEND_SIGNAL(equipping, COMSIG_JOB_RECEIVED, job) equipping.mind?.set_assigned_role(job) if(player_client) - to_chat(player_client, span_infoplain("You are the [job.title].")) + to_chat(player_client, span_infoplain("You are the [chosen_title].")) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: to_chat(player_client, span_infoplain("You are the [job.title].")) equipping.on_job_equipping(job, player_client?.prefs) //SKYRAT EDIT CHANGE - job.announce_job(equipping) + job.announce_job(equipping, chosen_title) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: job.announce_job(equipping) if(player_client?.holder) if(CONFIG_GET(flag/auto_deadmin_players) || (player_client.prefs?.toggles & DEADMIN_ALWAYS)) @@ -536,7 +541,7 @@ SUBSYSTEM_DEF(job) if(player_client) - to_chat(player_client, span_infoplain("As the [job.title] you answer directly to [job.supervisors]. Special circumstances may change this.")) // SKYRAT EDIT ORIGINAL + to_chat(player_client, span_infoplain("As the [chosen_title == job.title ? chosen_title : "[chosen_title] ([job.title])"] you answer directly to [job.supervisors]. Special circumstances may change this.")) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: to_chat(player_client, span_infoplain("As the [job.title] you answer directly to [job.supervisors]. Special circumstances may change this.")) job.radio_help_message(equipping) @@ -554,6 +559,7 @@ SUBSYSTEM_DEF(job) var/mob/living/carbon/human/wageslave = equipping wageslave.mind.add_memory(MEMORY_ACCOUNT, list(DETAIL_ACCOUNT_ID = wageslave.account_id), story_value = STORY_VALUE_SHIT, memory_flags = MEMORY_FLAG_NOLOCATION) + setup_alt_job_items(wageslave, job, player_client) // SKYRAT EDIT ADDITION - ALTERNATIVE_JOB_TITLES job.after_spawn(equipping, player_client) diff --git a/code/datums/datacore.dm b/code/datums/datacore.dm index 16d3ceb63b5..6665e967931 100644 --- a/code/datums/datacore.dm +++ b/code/datums/datacore.dm @@ -162,6 +162,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new) misc_list[++misc_list.len] = list( "name" = name, "rank" = rank, + "trim" = trim, // SKYRAT CHANGE ADDITION - ALTERNATIVE_JOB_TITLES ) continue for(var/department_type as anything in job.departments_list) @@ -172,6 +173,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new) var/list/entry = list( "name" = name, "rank" = rank, + "trim" = trim, // SKYRAT CHANGE ADDITION - ALTERNATIVE_JOB_TITLES ) var/list/department_list = manifest_out[department.department_name] if(istype(job, department.department_head)) @@ -208,7 +210,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new) var/even = FALSE for(var/entry in entries) var/list/entry_list = entry - dat += "[entry_list["name"]][entry_list["rank"]]" + dat += "[entry_list["name"]][entry_list["rank"] == entry_list["trim"] ? entry_list["rank"] : "[entry_list["rank"]] ([entry_list["trim"]])"]" // SKYRAT CHANGE EDIT - ALTERNATIVE_JOB_TITLES - Original: dat += "[entry_list["name"]][entry_list["rank"]]" even = !even dat += "" @@ -222,6 +224,10 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new) var/static/list/show_directions = list(SOUTH, WEST) if(H.mind?.assigned_role.job_flags & JOB_CREW_MANIFEST) var/assignment = H.mind.assigned_role.title + // SKYRAT EDIT ADDITION BEGIN - ALTERNATIVE_JOB_TITLES + // The alt job title, if user picked one, or the default + var/chosen_assignment = C?.prefs.alt_job_titles[assignment] || assignment + // SKYRAT EDIT ADDITION END - ALTERNATIVE_JOB_TITLES var/static/record_id_num = 1001 var/id = num2hex(record_id_num++,6) @@ -244,7 +250,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new) var/datum/data/record/G = new() G.fields["id"] = id G.fields["name"] = H.real_name - G.fields["rank"] = assignment + G.fields["rank"] = chosen_assignment // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: G.fields["rank"] = assignment G.fields["trim"] = assignment G.fields["initial_rank"] = assignment G.fields["age"] = H.age @@ -315,7 +321,7 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new) var/datum/data/record/L = new() L.fields["id"] = md5("[H.real_name][assignment]") //surely this should just be id, like the others? L.fields["name"] = H.real_name - L.fields["rank"] = assignment + L.fields["rank"] = chosen_assignment // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: L.fields["rank"] = assignment L.fields["trim"] = assignment G.fields["initial_rank"] = assignment L.fields["age"] = H.age diff --git a/code/modules/admin/verbs/admingame.dm b/code/modules/admin/verbs/admingame.dm index 2152160993d..06a6dc4f6a8 100644 --- a/code/modules/admin/verbs/admingame.dm +++ b/code/modules/admin/verbs/admingame.dm @@ -315,7 +315,7 @@ Traitors and the like can also be revived with the previous role mostly intact. if(!record_found && (new_character.mind.assigned_role.job_flags & JOB_CREW_MEMBER)) //Power to the user! if(tgui_alert(new_character,"Warning: No data core entry detected. Would you like to announce the arrival of this character by adding them to various databases, such as medical records?",,list("No","Yes"))=="Yes") - GLOB.data_core.manifest_inject(new_character) + GLOB.data_core.manifest_inject(new_character, src) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: GLOB.data_core.manifest_inject(new_character) if(tgui_alert(new_character,"Would you like an active AI to announce this character?",,list("No","Yes"))=="Yes") announce_arrival(new_character, new_character.mind.assigned_role.title) diff --git a/code/modules/jobs/job_types/_job.dm b/code/modules/jobs/job_types/_job.dm index ed04ff14088..f0b50cd1ae0 100644 --- a/code/modules/jobs/job_types/_job.dm +++ b/code/modules/jobs/job_types/_job.dm @@ -169,9 +169,9 @@ experiencer.mind.adjust_experience(i, roundstart_experience[i], TRUE) -/datum/job/proc/announce_job(mob/living/joining_mob) +/datum/job/proc/announce_job(mob/living/joining_mob, job_title) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: /datum/job/proc/announce_job(mob/living/joining_mob) if(head_announce) - announce_head(joining_mob, head_announce) + announce_head(joining_mob, head_announce, job_title) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: announce_head(joining_mob, head_announce) //Used for a special check of whether to allow a client to latejoin as this job. @@ -197,10 +197,11 @@ dna.species.pre_equip_species_outfit(equipping, src, visual_only) equip_outfit_and_loadout(equipping.outfit, used_pref, visual_only, equipping) //SKYRAT EDIT CHANGE -/datum/job/proc/announce_head(mob/living/carbon/human/H, channels) //tells the given channel that the given mob is the new department head. See communications.dm for valid channels. +/// tells the given channel that the given mob is the new department head. See communications.dm for valid channels. +/datum/job/proc/announce_head(mob/living/carbon/human/H, channels, job_title) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: /datum/job/proc/announce_head(mob/living/carbon/human/H, channels) if(H && GLOB.announcement_systems.len) //timer because these should come after the captain announcement - SSticker.OnRoundstart(CALLBACK(GLOBAL_PROC, .proc/_addtimer, CALLBACK(pick(GLOB.announcement_systems), /obj/machinery/announcement_system/proc/announce, "NEWHEAD", H.real_name, H.job, channels), 1)) + SSticker.OnRoundstart(CALLBACK(GLOBAL_PROC, .proc/_addtimer, CALLBACK(pick(GLOB.announcement_systems), /obj/machinery/announcement_system/proc/announce, "NEWHEAD", H.real_name, job_title, channels), 1)) // SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES - Original: SSticker.OnRoundstart(CALLBACK(GLOBAL_PROC, .proc/_addtimer, CALLBACK(pick(GLOB.announcement_systems), /obj/machinery/announcement_system/proc/announce, "NEWHEAD", H.real_name, H.job, channels), 1)) //If the configuration option is set to require players to be logged as old enough to play certain jobs, then this proc checks that they are, otherwise it just returns 1 /datum/job/proc/player_old_enough(client/C) diff --git a/code/modules/mob/dead/new_player/new_player.dm b/code/modules/mob/dead/new_player/new_player.dm index f23105ce885..cb3b84cddc2 100644 --- a/code/modules/mob/dead/new_player/new_player.dm +++ b/code/modules/mob/dead/new_player/new_player.dm @@ -259,11 +259,14 @@ humanc = character //Let's retypecast the var to be human, if(humanc) //These procs all expect humans - GLOB.data_core.manifest_inject(humanc) + // BEGIN SKYRAT EDIT CHANGE - ALTERNATIVE_JOB_TITLES + var/chosen_rank = humanc.client?.prefs.alt_job_titles[rank] || rank + GLOB.data_core.manifest_inject(humanc, humanc.client) if(SSshuttle.arrivals) - SSshuttle.arrivals.QueueAnnounce(humanc, rank) + SSshuttle.arrivals.QueueAnnounce(humanc, chosen_rank) else - announce_arrival(humanc, rank) + announce_arrival(humanc, chosen_rank) + // END SKYRAT EDIT CHANGE - customization AddEmploymentContract(humanc) humanc.increment_scar_slot() diff --git a/modular_skyrat/modules/alternative_job_titles/code/job.dm b/modular_skyrat/modules/alternative_job_titles/code/job.dm new file mode 100644 index 00000000000..67f7540cf67 --- /dev/null +++ b/modular_skyrat/modules/alternative_job_titles/code/job.dm @@ -0,0 +1,27 @@ +// ALTERNATIVE_JOB_TITLES + +/** + * Shows a list of all current and future polls and buttons to edit or delete them or create a new poll. + * + * All extra functionality to run on new player mobs, in a place where we actually have the client, + * and haven't called COMSIG_GLOB_JOB_AFTER_SPAWN yet, so we are running before the wallet trait, + * and other things that rely on items already being settled. + */ +/datum/controller/subsystem/job/proc/setup_alt_job_items(mob/living/carbon/human/equipping, datum/job/job, client/player_client) + if(!player_client) + return + + var/chosen_title = player_client.prefs.alt_job_titles[job.title] || job.title + + var/obj/item/card/id/card = equipping.wear_id + if(istype(card)) + card.assignment = chosen_title + card.update_label() + + // Look for PDA in belt or L pocket + var/obj/item/pda/pda = equipping.belt + if(!istype(pda)) + pda = equipping.l_store + if(istype(pda)) + pda.ownjob = chosen_title + pda.update_label() diff --git a/modular_skyrat/modules/alternative_job_titles/readme.md b/modular_skyrat/modules/alternative_job_titles/readme.md new file mode 100644 index 00000000000..bef1745ec6b --- /dev/null +++ b/modular_skyrat/modules/alternative_job_titles/readme.md @@ -0,0 +1,28 @@ +## Title: Alternative Job Titles + +MODULE ID: ALTERNATIVE_JOB_TITLES + +### Description: + +Adds functionality to custom job titles, making them show up in manifests, ID's and announcements. +Unfortunately, all 3 of the categories are not set up to be very modular, so this almost entirely consists of TG proc changes. + +### TG Proc Changes: + +- ./code/controllers/subsystem/job.dm > /datum/controller/subsystem/job/proc/EquipRank() +- ./code/datums/datacore.dm > /datum/datacore/proc/get_manifest(), /datum/datacore/proc/get_manifest_html(), /datum/datacore/proc/manifest_inject() +- ./code/modules/admin/verbs/admingame.dm > /client/proc/respawn_character() +- ./code/modules/jobs/job_types/_job.dm > /datum/job/proc/announce_job(), /datum/job/proc/announce_head() +- ./code/modules/mob/dead/new_player/new_player.dm > /mob/dead/new_player/proc/AttemptLateSpawn() + +### Defines: + +- N/A + +### Included files that are not contained in this module: + +- ./tgui/packages/tgui/interfaces/CrewManifest.js +- ./tgui/packages/tgui/interfaces/NtosCrewManifest.js + +### Credits: +Tastyfish diff --git a/tgstation.dme b/tgstation.dme index 258499b58f9..5fd5563507d 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -4305,6 +4305,7 @@ #include "modular_skyrat\modules\altborgs\code\robot_modules.dm" #include "modular_skyrat\modules\altborgs\code\robot_upgrade.dm" #include "modular_skyrat\modules\altborgs\code\update_icons.dm" +#include "modular_skyrat\modules\alternative_job_titles\code\job.dm" #include "modular_skyrat\modules\ambitions\code\ambition.dm" #include "modular_skyrat\modules\ambitions\code\ambition_templates.dm" #include "modular_skyrat\modules\ambitions\code\antag_datums.dm" diff --git a/tgui/packages/tgui/interfaces/CrewManifest.js b/tgui/packages/tgui/interfaces/CrewManifest.js index 3befc185012..a2ee498f903 100644 --- a/tgui/packages/tgui/interfaces/CrewManifest.js +++ b/tgui/packages/tgui/interfaces/CrewManifest.js @@ -11,6 +11,8 @@ const commandJobs = [ "Chief Medical Officer", ]; +// SKYRAT EDIT CHANGE BEGIN - ALTERNATIVE_JOB_TITLES +// Any instance of crewMember.trim was originally crewMember.rank export const CrewManifest = (props, context) => { const { data: { manifest, positions } } = useBackend(context); @@ -39,8 +41,7 @@ export const CrewManifest = (props, context) => { ])} collapsing > - {positions[dept].exceptions.includes(crewMember.rank) && ( - + {positions[dept].exceptions.includes(crewMember.trim) && ( { )} - {crewMember.rank === "Captain" && ( + {crewMember.trim === "Captain" && ( { /> )} - {commandJobs.includes(crewMember.rank) && ( + {commandJobs.includes(crewMember.trim) && ( { ); }; +// SKYRAT EDIT CHANGE END - ALTERNATIVE_JOB_TITLES diff --git a/tgui/packages/tgui/interfaces/NtosCrewManifest.js b/tgui/packages/tgui/interfaces/NtosCrewManifest.js index 2ad97ab3a94..54fc74a4c31 100644 --- a/tgui/packages/tgui/interfaces/NtosCrewManifest.js +++ b/tgui/packages/tgui/interfaces/NtosCrewManifest.js @@ -3,6 +3,12 @@ import { useBackend } from '../backend'; import { Button, Section, Table } from '../components'; import { NtosWindow } from '../layouts'; +// SKYRAT EDIT BEGIN - ALTERNATIVE_JOB_TITLES +// +// width={500} - Original: width={400} +// +// {entry.rank === entry.trim ? entry.rank : <>{entry.rank} ({entry.trim})} +// - Original: entry.rank export const NtosCrewManifest = (props, context) => { const { act, data } = useBackend(context); const { @@ -11,7 +17,7 @@ export const NtosCrewManifest = (props, context) => { } = data; return (
{ {entry.name} - ({entry.rank}) + {entry.rank === entry.trim + ? entry.rank + : <>{entry.rank} ({entry.trim})} ))} @@ -49,3 +57,4 @@ export const NtosCrewManifest = (props, context) => { ); }; +// SKYRAT EDIT END - ALTERNATIVE_JOB_TITLES