mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-16 10:35:41 +01:00
[MIRROR] Refactor crew manifest in lobby and ghost actions (#4791)
* Refactor crew manifest in lobby, ghost and AI actions (#58275) Co-authored-by: celotajstg <celotajstg@ users.noreply.github.com> * Refactor crew manifest in lobby and ghost actions Co-authored-by: celotajstg <81999976+celotajstg@users.noreply.github.com> Co-authored-by: celotajstg <celotajstg@ users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/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)
|
||||
return (isnewplayer(user) || isobserver(user) || isAI(user) || ispAI(user)) ? 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.open()
|
||||
|
||||
/datum/crew_manifest/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
if (..())
|
||||
return
|
||||
|
||||
/datum/crew_manifest/ui_data(mob/user)
|
||||
var/list/positions = list(
|
||||
"Command" = 0,
|
||||
"Security" = 0,
|
||||
"Engineering" = 0,
|
||||
"Medical" = 0,
|
||||
"Science" = 0,
|
||||
"Supply" = 0,
|
||||
"Service" = 0,
|
||||
"Silicon" = 0
|
||||
)
|
||||
var/list/departments = list(
|
||||
list("flag" = DEPARTMENT_COMMAND, "name" = "Command"),
|
||||
list("flag" = DEPARTMENT_SECURITY, "name" = "Security"),
|
||||
list("flag" = DEPARTMENT_ENGINEERING, "name" = "Engineering"),
|
||||
list("flag" = DEPARTMENT_MEDICAL, "name" = "Medical"),
|
||||
list("flag" = DEPARTMENT_SCIENCE, "name" = "Science"),
|
||||
list("flag" = DEPARTMENT_CARGO, "name" = "Supply"),
|
||||
list("flag" = DEPARTMENT_SERVICE, "name" = "Service"),
|
||||
list("flag" = DEPARTMENT_SILICON, "name" = "Silicon")
|
||||
)
|
||||
|
||||
for(var/job in SSjob.occupations)
|
||||
for(var/department in departments)
|
||||
// Check if the job is part of a department using its flag
|
||||
// Will return true for Research Director if the department is Science or Command, for example
|
||||
if(job["departments"] & department["flag"])
|
||||
// Add open positions to current department
|
||||
positions[department["name"]] += (job["total_positions"] - job["current_positions"])
|
||||
|
||||
return list(
|
||||
"manifest" = GLOB.data_core.get_manifest(),
|
||||
"positions" = positions
|
||||
)
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
/mob/dead/new_player/Destroy()
|
||||
GLOB.new_player_list -= src
|
||||
|
||||
return ..()
|
||||
|
||||
/mob/dead/new_player/prepare_huds()
|
||||
@@ -489,11 +490,10 @@
|
||||
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()
|
||||
if(!GLOB.crew_manifest_tgui)
|
||||
GLOB.crew_manifest_tgui = new /datum/crew_manifest(src)
|
||||
|
||||
src << browse(dat, "window=manifest;size=387x420;can_close=1")
|
||||
GLOB.crew_manifest_tgui.ui_interact(src)
|
||||
|
||||
/mob/dead/new_player/Move()
|
||||
return 0
|
||||
|
||||
@@ -681,11 +681,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
return
|
||||
client.crew_manifest_delay = world.time + (1 SECONDS)
|
||||
|
||||
var/dat
|
||||
dat += "<h4>Crew Manifest</h4>"
|
||||
dat += GLOB.data_core.get_manifest_html()
|
||||
if(!GLOB.crew_manifest_tgui)
|
||||
GLOB.crew_manifest_tgui = new /datum/crew_manifest(src)
|
||||
|
||||
src << browse(dat, "window=manifest;size=387x420;can_close=1")
|
||||
GLOB.crew_manifest_tgui.ui_interact(src)
|
||||
|
||||
//this is called when a ghost is drag clicked to something.
|
||||
/mob/dead/observer/MouseDrop(atom/over)
|
||||
|
||||
Reference in New Issue
Block a user