From b251af5b7b608e82417c98d3d91d6dcf04ee7290 Mon Sep 17 00:00:00 2001 From: DreamySkrell <107256943+DreamySkrell@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:27:22 +0100 Subject: [PATCH] Ghost spawner UI improvements (#18398) * 4yehdgfjh45uhjt * 342twgrse * 5euyhtd --------- Co-authored-by: DreamySkrell <> --- code/controllers/subsystems/ghostroles.dm | 12 ++ code/modules/ghostroles/spawner/base.dm | 3 - .../DreamySkrell-spawner-color-loc.yml | 9 + .../packages/tgui/interfaces/GhostSpawner.tsx | 182 +++++++++++------- 4 files changed, 129 insertions(+), 77 deletions(-) create mode 100644 html/changelogs/DreamySkrell-spawner-color-loc.yml diff --git a/code/controllers/subsystems/ghostroles.dm b/code/controllers/subsystems/ghostroles.dm index a5c7a6ef65a..793d6b7d2cf 100644 --- a/code/controllers/subsystems/ghostroles.dm +++ b/code/controllers/subsystems/ghostroles.dm @@ -119,13 +119,24 @@ SUBSYSTEM_DEF(ghostroles) var/datum/ghostspawner/G = spawners[s] if(G.cant_see(user)) continue + var/cant_spawn = G.cant_spawn(user) + var/list/manifest = list() if(LAZYLEN(G.spawned_mobs)) for(var/datum/weakref/mob_ref in G.spawned_mobs) var/mob/spawned_mob = mob_ref.resolve() if(spawned_mob) manifest += spawned_mob.real_name + + var/atom/spawn_overmap_location = null + if(SSatlas.current_map.use_overmap) + var/atom/spawner = G.select_spawnlocation(FALSE) + if(istype(spawner)) + var/obj/effect/overmap/visitable/sector = GLOB.map_sectors["[spawner.z]"] + if(istype(sector)) + spawn_overmap_location = sector.name + var/list/spawner = list( "short_name" = G.short_name, "name" = G.name, @@ -137,6 +148,7 @@ SUBSYSTEM_DEF(ghostroles) "enabled" = G.enabled, "count" = G.count, "spawn_atoms" = length(G.spawn_atoms), + "spawn_overmap_location" = spawn_overmap_location, "max_count" = G.max_count, "tags" = G.tags, "spawnpoints" = G.spawnpoints, diff --git a/code/modules/ghostroles/spawner/base.dm b/code/modules/ghostroles/spawner/base.dm index 7cd67351218..13f989e4096 100644 --- a/code/modules/ghostroles/spawner/base.dm +++ b/code/modules/ghostroles/spawner/base.dm @@ -61,9 +61,6 @@ if(!enabled && !can_edit(user)) //If its not enabled and the user cant edit it, dont show it return "Currently Disabled" - if(loc_type == GS_LOC_ATOM && !length(spawn_atoms)) - return "No spawn atoms available" - var/ban_reason = jobban_isbanned(user,jobban_job) if(jobban_job && ban_reason) return "[ban_reason]" diff --git a/html/changelogs/DreamySkrell-spawner-color-loc.yml b/html/changelogs/DreamySkrell-spawner-color-loc.yml new file mode 100644 index 00000000000..51561f805cf --- /dev/null +++ b/html/changelogs/DreamySkrell-spawner-color-loc.yml @@ -0,0 +1,9 @@ + +author: DreamySkrell + +delete-after: True + +changes: + - rscadd: "Ghost spawners show the location of the spawner." + - tweak: "Ghost spawners are shown in the list even if full." + - tweak: "Ghost spawners are grayed out if visible, but cannot use them for whatever reason." diff --git a/tgui/packages/tgui/interfaces/GhostSpawner.tsx b/tgui/packages/tgui/interfaces/GhostSpawner.tsx index 21b0ab23bfa..c12219b4e2a 100644 --- a/tgui/packages/tgui/interfaces/GhostSpawner.tsx +++ b/tgui/packages/tgui/interfaces/GhostSpawner.tsx @@ -22,6 +22,7 @@ type Spawner = { count: number; max_count: number; spawn_atoms: any; + spawn_overmap_location: string; tags: string[]; spawnpoints: string[]; manifest: string[]; @@ -78,6 +79,7 @@ const ManifestTable = function (act, spawner: Spawner) { export const GhostSpawner = (props, context) => { const { act, data } = useBackend(context); + const [tab, setTab] = useLocalState(context, 'tab', 'All'); const [searchTerm, setSearchTerm] = useLocalState( context, @@ -85,6 +87,35 @@ export const GhostSpawner = (props, context) => { `` ); + const spawners = data.spawners.filter( + (S) => S.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1 + ); + + const colors = [ + 'blue', + 'purple', + 'maroon', + 'olive', + 'orange', + 'cyan', + 'red', + 'green', + 'yellow', + ]; + + let loc_to_color: Map = new Map(); + + paginate( + Array.from( + new Set( + spawners + .filter((s) => s.spawn_overmap_location) + .map((s) => s.spawn_overmap_location) + ) + ), + colors.length + ).map((p) => p.map((l, i) => (loc_to_color[l] = colors[i % colors.length]))); + return ( @@ -119,93 +150,96 @@ export const GhostSpawner = (props, context) => { Name + Location Description Available Slots Actions - {data.spawners - .filter( - (S) => - S.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1 - ) - .map( - (spawner) => - (spawner.tags.indexOf(tab) > -1 || tab === 'All') && ( - - {spawner.name} - - - {spawner.desc} - {spawner.manifest.length > 0 ? ( - - - Manifest - - {ManifestTable(act, spawner)} + {spawners.map( + (spawner) => + (spawner.tags.indexOf(tab) > -1 || tab === 'All') && ( + + {spawner.name} + + {spawner.spawn_overmap_location} + + + + {spawner.desc} + {spawner.manifest.length > 0 ? ( + + + Manifest - ) : null} - - - - {spawner.max_count > 0 - ? spawner.max_count - - spawner.count + - ' / ' + - spawner.max_count - : spawner.spawn_atoms} - - + {ManifestTable(act, spawner)} + + ) : null} + + + + {spawner.max_count > 0 + ? spawner.max_count - + spawner.count + + ' / ' + + spawner.max_count + : spawner.spawn_atoms} + + +