Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TGUI Crew Manifest: Shion Edition #9836

Merged
merged 16 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
7 changes: 7 additions & 0 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -768,3 +768,10 @@
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

/proc/list_to_assoc_index(list/input)
Absolucy marked this conversation as resolved.
Show resolved Hide resolved
. = 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(
Absolucy marked this conversation as resolved.
Show resolved Hide resolved
// 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
))
42 changes: 14 additions & 28 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,42 +186,28 @@

/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 = rank == JOB_NAME_CAPTAIN || (department != DEPT_COMMAND && heads[rank])
Absolucy marked this conversation as resolved.
Show resolved Hide resolved
Absolucy marked this conversation as resolved.
Show resolved Hide resolved
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
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
34 changes: 34 additions & 0 deletions code/modules/mob/dead/crew_manifest.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
GLOBAL_DATUM_INIT(crew_manifest_tgui, /datum/crew_manifest, new)

/datum/crew_manifest

/datum/crew_manifest/ui_state(mob/user)
return GLOB.always_state

/datum/crew_manifest/ui_status(mob/user, datum/ui_state/state)
var/static/list/allowed_mobs_typecache = typecacheof(list(/mob/dead, /mob/living/silicon))
return is_type_in_typecache(user, allowed_mobs_typecache) ? UI_INTERACTIVE : UI_CLOSE

/datum/crew_manifest/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "CrewManifest")
ui.set_autoupdate(TRUE)
Absolucy marked this conversation as resolved.
Show resolved Hide resolved
ui.open()

/datum/crew_manifest/ui_static_data(mob/user)
var/static/list/ordering = list_to_assoc_index(flatten_list(GLOB.id_to_hud))
return list(
"command" = list(
"huds" = GLOB.command_huds,
"jobs" = GLOB.command_positions,
"order" = SSjob.chain_of_command
),
"order" = ordering,
)

/datum/crew_manifest/ui_data(mob/user)
return list("manifest" = GLOB.data_core.get_manifest(), "generic" = isdead(user))
Absolucy marked this conversation as resolved.
Show resolved Hide resolved

/datum/crew_manifest/ui_assets(mob/user)
return list(get_asset_datum(/datum/asset/spritesheet/job_icons))
13 changes: 3 additions & 10 deletions code/modules/mob/dead/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,10 @@
qdel(src)

/mob/dead/new_player/proc/ViewManifest()
if(!client)
return
if(world.time < client.crew_manifest_delay)
if(!client || !COOLDOWN_FINISHED(client, crew_manifest_delay))
return
client.crew_manifest_delay = world.time + (1 SECONDS)

var/dat = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head><body>"
dat += "<h4>Crew Manifest</h4>"
dat += GLOB.data_core.get_manifest_html()

src << browse(dat, "window=manifest;size=387x420;can_close=1")
COOLDOWN_START(client, crew_manifest_delay, 1 SECONDS)
GLOB.crew_manifest_tgui.ui_interact(src)

/mob/dead/new_player/Move()
return 0
Expand Down
Loading