Skip to content

Commit

Permalink
TGUI Crew Manifest: Shion Edition (#9836)
Browse files Browse the repository at this point in the history
* TGUI Crew Manifest: Shion Edition

* Merge department color SCSS

* fixy

* Some improvements.

* More tweaks to satisfy reviews

* Remove unused typedefs

* And an unused import

* Address reviews

* That looks less ugly...

* Candystripe

* No more autoupdate

* Address reviews
  • Loading branch information
Absolucy authored Sep 22, 2023
1 parent 62cdc57 commit dfd2910
Show file tree
Hide file tree
Showing 17 changed files with 374 additions and 162 deletions.
2 changes: 2 additions & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
#include "code\_globalvars\lists\ambience.dm"
#include "code\_globalvars\lists\client.dm"
#include "code\_globalvars\lists\flavor_misc.dm"
#include "code\_globalvars\lists\jobs.dm"
#include "code\_globalvars\lists\maintenance_loot.dm"
#include "code\_globalvars\lists\mapping.dm"
#include "code\_globalvars\lists\mobs.dm"
Expand Down Expand Up @@ -2846,6 +2847,7 @@
#include "code\modules\mob\transform_procs.dm"
#include "code\modules\mob\update_icons.dm"
#include "code\modules\mob\camera\camera.dm"
#include "code\modules\mob\dead\crew_manifest.dm"
#include "code\modules\mob\dead\dead.dm"
#include "code\modules\mob\dead\new_player\login.dm"
#include "code\modules\mob\dead\new_player\logout.dm"
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/signals_global.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@
#define COMSIG_GLOB_POST_START "!post_start"
/// Called when the parallax background changes colour. (new_colour, transition_time)
#define COMSIG_GLOB_STARLIGHT_COLOUR_CHANGE "!starlight_colour_change"
/// Called whenever the crew manifest is updated
#define COMSIG_GLOB_CREW_MANIFEST_UPDATE "!crew_manifest_update"
16 changes: 0 additions & 16 deletions code/__DEFINES/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,6 @@
#define DEPT_BITFLAG_CAPTAIN (1<<10)
#define DEPT_BITFLAG_ASSISTANT (1<<11)

/// For use in the preferences menu.
GLOBAL_LIST_INIT(dept_bitflag_to_name, list(
"[DEPT_BITFLAG_COM]" = "Command",
"[DEPT_BITFLAG_CIV]" = "Civilian",
"[DEPT_BITFLAG_SRV]" = "Service",
"[DEPT_BITFLAG_CAR]" = "Cargo",
"[DEPT_BITFLAG_SCI]" = "Science",
"[DEPT_BITFLAG_ENG]" = "Engineering",
"[DEPT_BITFLAG_MED]" = "Medical",
"[DEPT_BITFLAG_SEC]" = "Security",
"[DEPT_BITFLAG_VIP]" = "Very Important People",
"[DEPT_BITFLAG_SILICON]" = "Silicon",
"[DEPT_BITFLAG_CAPTAIN]" = "Captain",
"[DEPT_BITFLAG_ASSISTANT]" = "Assistant"
))

// should check the ones in `\_DEFINES\economy.dm`
// It's true that bitflags shouldn't be separated in two DEFINES if these are same, but just in case the system can be devided, it's remained separated.

Expand Down
12 changes: 12 additions & 0 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -768,3 +768,15 @@
stack_trace("[name] is not sorted. value at [index] ([value]) is in the wrong place compared to the previous value of [last_value] (when compared to by [cmp])")

last_value = value

/**
* Converts a normal array list to an associated list, with the keys being the original values, and the value being the index of the value in the original list.
* All keys are converted to strings.
* Example: list("a", "b", 1, 2, 3) -> list("a" = 1, "b" = 2, "1" = 3, "2" = 4, "3" = 5)
*/
/proc/list_to_assoc_index(list/input)
. = list()
for(var/i = 1 to length(input))
var/key = "[input[i]]"
if(isnull(.[key]))
.[key] = i
166 changes: 94 additions & 72 deletions code/__HELPERS/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,88 +74,101 @@
)
return id_style[jobname] || "noname" // default: a card with no shape

// This returns a hud icon (from `hud.dmi`) by given job name.
// Some custom title is from `PDApainter.dm`. You neec to check it if you're going to remove custom job.
/proc/get_hud_by_jobname(jobname, returns_unknown=TRUE)
if(!jobname)
CRASH("The proc has taken a null value")
// You really shouldn't use this directly.
// Use get_hud_by_jobname unless you NEED direct access to this, i.e for the crew manifest tgui data
GLOBAL_LIST_INIT(id_to_hud, list(
// Command
JOB_NAME_CAPTAIN = JOB_HUD_CAPTAIN,
"Acting Captain" = JOB_HUD_ACTINGCAPTAIN ,
"Command (Custom)" = JOB_HUD_RAWCOMMAND,

var/static/id_to_hud = list(
// Command
"Command (Custom)" = JOB_HUD_RAWCOMMAND,
JOB_NAME_CAPTAIN = JOB_HUD_CAPTAIN,
"Acting Captain" = JOB_HUD_ACTINGCAPTAIN ,
// Service
JOB_NAME_HEADOFPERSONNEL = JOB_HUD_HEADOFPERSONNEL,
JOB_NAME_ASSISTANT = JOB_HUD_ASSISTANT,
JOB_NAME_BARTENDER = JOB_HUD_BARTENDER,
JOB_NAME_COOK = JOB_HUD_COOK,
JOB_NAME_BOTANIST = JOB_HUD_BOTANIST,
JOB_NAME_CURATOR = JOB_HUD_CURATOR,
JOB_NAME_CHAPLAIN = JOB_HUD_CHAPLAIN,
JOB_NAME_JANITOR = JOB_HUD_JANITOR,
JOB_NAME_LAWYER = JOB_HUD_LAWYER,
JOB_NAME_MIME = JOB_HUD_MIME,
JOB_NAME_CLOWN = JOB_HUD_CLOWN,
JOB_NAME_STAGEMAGICIAN = JOB_HUD_STAGEMAGICIAN,
JOB_NAME_BARBER = JOB_HUD_BARBER,
"Service (Custom)" = JOB_HUD_RAWSERVICE,

// Service
"Service (Custom)" = JOB_HUD_RAWSERVICE,
JOB_NAME_HEADOFPERSONNEL = JOB_HUD_HEADOFPERSONNEL,
JOB_NAME_ASSISTANT = JOB_HUD_ASSISTANT,
JOB_NAME_BARTENDER = JOB_HUD_BARTENDER,
JOB_NAME_COOK = JOB_HUD_COOK,
JOB_NAME_BOTANIST = JOB_HUD_BOTANIST,
JOB_NAME_CURATOR = JOB_HUD_CURATOR,
JOB_NAME_CHAPLAIN = JOB_HUD_CHAPLAIN,
JOB_NAME_JANITOR = JOB_HUD_JANITOR,
JOB_NAME_LAWYER = JOB_HUD_LAWYER,
JOB_NAME_MIME = JOB_HUD_MIME,
JOB_NAME_CLOWN = JOB_HUD_CLOWN,
JOB_NAME_STAGEMAGICIAN = JOB_HUD_STAGEMAGICIAN,
JOB_NAME_BARBER = JOB_HUD_BARBER,
// Cargo
JOB_NAME_QUARTERMASTER = JOB_HUD_QUARTERMASTER,
JOB_NAME_CARGOTECHNICIAN = JOB_HUD_CARGOTECHNICIAN,
JOB_NAME_SHAFTMINER = JOB_HUD_SHAFTMINER,
"Cargo (Custom)" = JOB_HUD_RAWCARGO,

// Cargo
"Cargo (Custom)" = JOB_HUD_RAWCARGO,
JOB_NAME_QUARTERMASTER = JOB_HUD_QUARTERMASTER,
JOB_NAME_CARGOTECHNICIAN = JOB_HUD_CARGOTECHNICIAN,
JOB_NAME_SHAFTMINER = JOB_HUD_SHAFTMINER,
// R&D
JOB_NAME_RESEARCHDIRECTOR = JOB_HUD_RESEARCHDIRECTOR,
JOB_NAME_SCIENTIST = JOB_HUD_SCIENTIST,
JOB_NAME_ROBOTICIST = JOB_HUD_ROBOTICIST,
JOB_NAME_EXPLORATIONCREW = JOB_HUD_EXPLORATIONCREW,
"Science (Custom)" = JOB_HUD_RAWSCIENCE,

// R&D
"Science (Custom)" = JOB_HUD_RAWSCIENCE,
JOB_NAME_RESEARCHDIRECTOR = JOB_HUD_RESEARCHDIRECTOR,
JOB_NAME_SCIENTIST = JOB_HUD_SCIENTIST,
JOB_NAME_ROBOTICIST = JOB_HUD_ROBOTICIST,
JOB_NAME_EXPLORATIONCREW = JOB_HUD_EXPLORATIONCREW,
// Engineering
JOB_NAME_CHIEFENGINEER = JOB_HUD_CHIEFENGINEER,
JOB_NAME_STATIONENGINEER = JOB_HUD_STATIONENGINEER,
JOB_NAME_ATMOSPHERICTECHNICIAN = JOB_HUD_ATMOSPHERICTECHNICIAN,
"Engineering (Custom)" = JOB_HUD_RAWENGINEERING,

// Engineering
"Engineering (Custom)" = JOB_HUD_RAWENGINEERING,
JOB_NAME_CHIEFENGINEER = JOB_HUD_CHIEFENGINEER,
JOB_NAME_STATIONENGINEER = JOB_HUD_STATIONENGINEER,
JOB_NAME_ATMOSPHERICTECHNICIAN = JOB_HUD_ATMOSPHERICTECHNICIAN,
// Medical
JOB_NAME_CHIEFMEDICALOFFICER = JOB_HUD_CHEIFMEDICALOFFICIER,
JOB_NAME_MEDICALDOCTOR = JOB_HUD_MEDICALDOCTOR,
JOB_NAME_PARAMEDIC = JOB_HUD_PARAMEDIC,
JOB_NAME_VIROLOGIST = JOB_HUD_VIROLOGIST,
JOB_NAME_CHEMIST = JOB_HUD_CHEMIST,
JOB_NAME_GENETICIST = JOB_HUD_GENETICIST,
JOB_NAME_PSYCHIATRIST = JOB_HUD_PSYCHIATRIST,
"Medical (Custom)" = JOB_HUD_RAWMEDICAL,

// Medical
"Medical (Custom)" = JOB_HUD_RAWMEDICAL,
JOB_NAME_CHIEFMEDICALOFFICER = JOB_HUD_CHEIFMEDICALOFFICIER,
JOB_NAME_MEDICALDOCTOR = JOB_HUD_MEDICALDOCTOR,
JOB_NAME_PARAMEDIC = JOB_HUD_PARAMEDIC,
JOB_NAME_VIROLOGIST = JOB_HUD_VIROLOGIST,
JOB_NAME_CHEMIST = JOB_HUD_CHEMIST,
JOB_NAME_GENETICIST = JOB_HUD_GENETICIST,
JOB_NAME_PSYCHIATRIST = JOB_HUD_PSYCHIATRIST,
// Security
JOB_NAME_HEADOFSECURITY = JOB_HUD_HEADOFSECURITY,
JOB_NAME_SECURITYOFFICER = JOB_HUD_SECURITYOFFICER,
JOB_NAME_WARDEN = JOB_HUD_WARDEN,
JOB_NAME_DETECTIVE = JOB_HUD_DETECTIVE,
JOB_NAME_BRIGPHYSICIAN = JOB_HUD_BRIGPHYSICIAN,
JOB_NAME_DEPUTY = JOB_HUD_DEPUTY,
"Security (Custom)" = JOB_HUD_RAWSECURITY,

// Security
"Security (Custom)" = JOB_HUD_RAWSECURITY,
JOB_NAME_HEADOFSECURITY = JOB_HUD_HEADOFSECURITY,
JOB_NAME_SECURITYOFFICER = JOB_HUD_SECURITYOFFICER,
JOB_NAME_WARDEN = JOB_HUD_WARDEN,
JOB_NAME_DETECTIVE = JOB_HUD_DETECTIVE,
JOB_NAME_BRIGPHYSICIAN = JOB_HUD_BRIGPHYSICIAN,
JOB_NAME_DEPUTY = JOB_HUD_DEPUTY,
// CentCom
"CentCom" = JOB_HUD_CENTCOM,
"ERT" = JOB_HUD_CENTCOM,
"CentCom (Custom)" = JOB_HUD_RAWCENTCOM,

// CentCom
"CentCom (Custom)" = JOB_HUD_RAWCENTCOM,
"CentCom" = JOB_HUD_CENTCOM,
"ERT" = JOB_HUD_CENTCOM,
// ETC
JOB_NAME_VIP = JOB_HUD_VIP,
JOB_NAME_KING = JOB_HUD_KING,
"Syndicate Agent" = JOB_HUD_SYNDICATE,
"Clown Operative" = JOB_HUD_SYNDICATE,
"Unassigned" = JOB_HUD_UNKNOWN,
JOB_NAME_PRISONER = JOB_HUD_PRISONER
))

// ETC
JOB_NAME_VIP = JOB_HUD_VIP,
JOB_NAME_KING = JOB_HUD_KING,
"Syndicate Agent" = JOB_HUD_SYNDICATE,
"Clown Operative" = JOB_HUD_SYNDICATE,
"Unassigned" = JOB_HUD_UNKNOWN,
JOB_NAME_PRISONER = JOB_HUD_PRISONER
)
GLOBAL_LIST_INIT(command_huds, list(
JOB_HUD_CAPTAIN,
JOB_HUD_ACTINGCAPTAIN,
JOB_HUD_RAWCOMMAND,
JOB_HUD_HEADOFPERSONNEL,
JOB_HUD_RESEARCHDIRECTOR,
JOB_HUD_CHIEFENGINEER,
JOB_HUD_CHEIFMEDICALOFFICIER,
JOB_HUD_HEADOFSECURITY
))

// This returns a hud icon (from `hud.dmi`) by given job name.
// Some custom title is from `PDApainter.dm`. You neec to check it if you're going to remove custom job.
/proc/get_hud_by_jobname(jobname, returns_unknown=TRUE)
if(!jobname)
CRASH("The proc has taken a null value")
if(returns_unknown)
return id_to_hud[jobname] || JOB_HUD_UNKNOWN // default: a grey unknown hud
return id_to_hud[jobname] // this will return null
return GLOB.id_to_hud[jobname] || JOB_HUD_UNKNOWN // default: a grey unknown hud
return GLOB.id_to_hud[jobname] // this will return null

// used to determine chat color by HUD in `chatmessage.dm`
// Note: custom colors are what I really didn't put much attention into. feel free to change its color when you feel off.
Expand Down Expand Up @@ -237,3 +250,12 @@
)
return hud_to_chatcolor[jobname] || JOB_CHATCOLOR_UNKNOWN

/proc/get_job_departments(field)
. = list()
for(var/flag in GLOB.bitflags)
var/key = "[flag]"
var/department = GLOB.dept_bitflag_to_name[key]
if(!department || !GLOB.departments[department])
continue
if(CHECK_BITFIELD(field, flag))
. += department
30 changes: 30 additions & 0 deletions code/_globalvars/lists/jobs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// A list of each bitflag and the name of its associated department. For use in the preferences menu.
GLOBAL_LIST_INIT(dept_bitflag_to_name, list(
"[DEPT_BITFLAG_COM]" = "Command",
"[DEPT_BITFLAG_CIV]" = "Civilian",
"[DEPT_BITFLAG_SRV]" = "Service",
"[DEPT_BITFLAG_CAR]" = "Cargo",
"[DEPT_BITFLAG_SCI]" = "Science",
"[DEPT_BITFLAG_ENG]" = "Engineering",
"[DEPT_BITFLAG_MED]" = "Medical",
"[DEPT_BITFLAG_SEC]" = "Security",
"[DEPT_BITFLAG_VIP]" = "Very Important People",
"[DEPT_BITFLAG_SILICON]" = "Silicon",
"[DEPT_BITFLAG_CAPTAIN]" = "Captain",
"[DEPT_BITFLAG_ASSISTANT]" = "Assistant"
))

/// A list of each department and its associated bitflag.
GLOBAL_LIST_INIT(departments, list(
"Command" = DEPT_BITFLAG_COM,
"Very Important People" = DEPT_BITFLAG_VIP,
"Security" = DEPT_BITFLAG_SEC,
"Engineering" = DEPT_BITFLAG_ENG,
"Medical" = DEPT_BITFLAG_MED,
"Science" = DEPT_BITFLAG_SCI,
"Supply" = DEPT_BITFLAG_CAR,
"Cargo" = DEPT_BITFLAG_CAR, // code seems to switch between calling it Supply and Cargo. not going to fix that today, let's just split the difference.
"Service" = DEPT_BITFLAG_SRV,
"Civilian" = DEPT_BITFLAG_CIV,
"Silicon" = DEPT_BITFLAG_SILICON
))
50 changes: 20 additions & 30 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -175,53 +175,41 @@
if(N.new_character)
log_manifest(N.ckey,N.new_character.mind,N.new_character)
if(ishuman(N.new_character))
manifest_inject(N.new_character)
manifest_inject(N.new_character, send_signal = FALSE)
CHECK_TICK
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CREW_MANIFEST_UPDATE)

/datum/datacore/proc/manifest_modify(name, assignment, hudstate)
var/datum/data/record/foundrecord = find_record("name", name, GLOB.data_core.general)
if(foundrecord)
foundrecord.fields["rank"] = assignment
foundrecord.fields["hud"] = hudstate
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CREW_MANIFEST_UPDATE)

/datum/datacore/proc/get_manifest()
var/list/manifest_out = list()
var/list/dept_list = list(
"Command" = DEPT_BITFLAG_COM,
"Very Important People" = DEPT_BITFLAG_VIP,
"Security" = DEPT_BITFLAG_SEC,
"Engineering" = DEPT_BITFLAG_ENG,
"Medical" = DEPT_BITFLAG_MED,
"Science" = DEPT_BITFLAG_SCI,
"Supply" = DEPT_BITFLAG_CAR,
"Service" = DEPT_BITFLAG_SRV,
"Civilian" = DEPT_BITFLAG_CIV,
"Silicon" = DEPT_BITFLAG_SILICON
)
var/static/list/heads = make_associative(GLOB.command_positions)

for(var/datum/data/record/t in GLOB.data_core.general)
var/name = t.fields["name"]
var/rank = t.fields["rank"]
var/hud = t.fields["hud"]
var/dept_bitflags = t.fields["active_dept"]
var/has_department = FALSE
for(var/department in dept_list)
if(dept_bitflags & dept_list[department])
if(!manifest_out[department])
manifest_out[department] = list()
manifest_out[department] += list(list(
"name" = name,
"rank" = rank
))
has_department = TRUE
var/entry = list("name" = name, "rank" = rank, "hud" = hud)
for(var/department in get_job_departments(dept_bitflags))
var/list/department_manifest = manifest_out[department]
if(!department_manifest)
manifest_out[department] = department_manifest = list()
// Append to beginning of list if captain or department head
var/put_at_top = hud == JOB_HUD_CAPTAIN || hud == JOB_HUD_ACTINGCAPTAIN || (department != DEPT_COMMAND && heads[rank])
department_manifest.Insert(put_at_top, list(entry))
has_department = TRUE
if(!has_department)
if(!manifest_out["Misc"])
manifest_out["Misc"] = list()
manifest_out["Misc"] += list(list(
"name" = name,
"rank" = rank
))
LAZYADDASSOCLIST(manifest_out, "Misc", entry)
//Sort the list by 'departments' primarily so command is on top.
var/list/sorted_out = list()
for(var/department in (dept_list += "Misc"))
for(var/department in (assoc_to_keys(GLOB.departments) + "Misc"))
if(!isnull(manifest_out[department]))
sorted_out[department] = manifest_out[department]
return sorted_out
Expand Down Expand Up @@ -255,7 +243,7 @@
return dat


/datum/datacore/proc/manifest_inject(mob/living/carbon/human/H)
/datum/datacore/proc/manifest_inject(mob/living/carbon/human/H, send_signal = TRUE)
set waitfor = FALSE
var/static/list/show_directions = list(SOUTH, WEST)
if(H.mind && (H.mind.assigned_role != H.mind.special_role))
Expand Down Expand Up @@ -340,6 +328,8 @@
L.fields["character_appearance"] = character_appearance
L.fields["mindref"] = H.mind
locked += L
if(send_signal)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CREW_MANIFEST_UPDATE)
return

/**
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/client_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
var/last_completed_asset_job = 0

/// rate limiting for the crew manifest
var/crew_manifest_delay
COOLDOWN_DECLARE(crew_manifest_delay)

//Tick when ghost roles are useable again
var/next_ghost_role_tick = 0
Expand Down
Loading

0 comments on commit dfd2910

Please sign in to comment.