From c7d0d5ef28ffdbfec0835572e2b60ae62a88bdbb Mon Sep 17 00:00:00 2001 From: CHOMPStation2 <58959929+CHOMPStation2@users.noreply.github.com> Date: Sat, 12 Oct 2024 08:10:35 -0700 Subject: [PATCH] [MIRROR] Unify TGUI crew manifest across lobby and ghosts, make it a true table (#9223) Co-authored-by: ShadowLarkens Co-authored-by: CHOMPStation2 --- code/modules/mob/dead/observer/observer.dm | 7 +- code/modules/mob/new_player/new_player.dm | 9 +-- code/modules/tgui/modules/crew_manifest.dm | 12 ++- .../packages/tgui/interfaces/CrewManifest.tsx | 79 ++++++++++++------- 4 files changed, 64 insertions(+), 43 deletions(-) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index fcbe9e6835..c46e62be12 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -717,11 +717,8 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp set name = "Show Crew Manifest" set category = "Ghost.Game" //CHOMPEdit - var/dat - dat += "

Crew Manifest

" - dat += data_core.get_manifest() - - src << browse(dat, "window=manifest;size=370x420;can_close=1") + var/datum/tgui_module/crew_manifest/self_deleting/S = new(src) + S.tgui_interact(src) //This is called when a ghost is drag clicked to something. /mob/observer/dead/MouseDrop(atom/over) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index f96536c6a7..6ce07541bf 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -777,13 +777,8 @@ return new_character /mob/new_player/proc/ViewManifest() - var/dat = "
" - dat += data_core.get_manifest(OOC = 1) - - //src << browse(dat, "window=manifest;size=370x420;can_close=1") - var/datum/browser/popup = new(src, "Crew Manifest", "Crew Manifest", 370, 420, src) - popup.set_content(dat) - popup.open() + var/datum/tgui_module/crew_manifest/self_deleting/S = new(src) + S.tgui_interact(src) /mob/new_player/Move() return 0 diff --git a/code/modules/tgui/modules/crew_manifest.dm b/code/modules/tgui/modules/crew_manifest.dm index 7c4daf7f2a..695e81191a 100644 --- a/code/modules/tgui/modules/crew_manifest.dm +++ b/code/modules/tgui/modules/crew_manifest.dm @@ -11,4 +11,14 @@ /datum/tgui_module/crew_manifest/robot /datum/tgui_module/crew_manifest/robot/tgui_state(mob/user) - return GLOB.tgui_self_state \ No newline at end of file + return GLOB.tgui_self_state + +// Module that deletes itself when it's closed +/datum/tgui_module/crew_manifest/self_deleting + +/datum/tgui_module/crew_manifest/self_deleting/tgui_close(mob/user) + . = ..() + qdel(src) + +/datum/tgui_module/crew_manifest/self_deleting/tgui_state(mob/user) + return GLOB.tgui_always_state diff --git a/tgui/packages/tgui/interfaces/CrewManifest.tsx b/tgui/packages/tgui/interfaces/CrewManifest.tsx index d814f14510..33cb57b42a 100644 --- a/tgui/packages/tgui/interfaces/CrewManifest.tsx +++ b/tgui/packages/tgui/interfaces/CrewManifest.tsx @@ -1,9 +1,8 @@ import { decodeHtmlEntities } from 'common/string'; - -import { useBackend } from '../backend'; -import { Box, Section, Table } from '../components'; -import { COLORS } from '../constants'; -import { Window } from '../layouts'; +import { useBackend } from 'tgui/backend'; +import { COLORS } from 'tgui/constants'; +import { Window } from 'tgui/layouts'; +import { Box, Section, Table } from 'tgui-core/components'; /* * Shared by the following templates (and used individually too) @@ -40,43 +39,63 @@ export const CrewManifestContent = (props) => { const { manifest } = data; + if (manifest.length === 0) { + return No Manifest Data; + } + + let crew_count = manifest + .map((val) => val.elems.length) + .reduce((a, c) => a + c, 0); + if (!crew_count) { + return No Crew Detected; + } + return ( -
- {manifest.map( - (cat) => - !!cat.elems.length && ( -
- - {cat.cat} - - - } - key={cat.cat} - > - +
+
+ {manifest.map( + (department) => + !!department.elems.length && ( + <> + + + + {department.cat} + + {/* This uses style={{ height }} to avoid being turned into REM and causing rounding errors */} + +   + + + Name Rank Active - {cat.elems.map((person) => ( + {department.elems.map((person) => ( {decodeHtmlEntities(person.name)} {person.rank} {person.active} ))} -
-
- ), - )} + + ), + )} +
); };