Central Command crew monitoring consoles can now see across all sectors. (#22140)

* advanced crew monitor (for CC)

* dont run on new, im dumb

* fixed

* oops... dont forget that.
This commit is contained in:
Contrabang
2023-09-14 18:26:37 +01:00
committed by GitHub
parent 752ef068c7
commit e0d75a9b45
6 changed files with 82 additions and 30 deletions
+2 -2
View File
@@ -6444,7 +6444,7 @@
/turf/simulated/floor/plasteel/dark,
/area/centcom/control)
"xe" = (
/obj/machinery/computer/crew,
/obj/machinery/computer/crew/advanced,
/turf/simulated/floor/plasteel,
/area/admin)
"xf" = (
@@ -12384,7 +12384,7 @@
/turf/simulated/floor/plasteel,
/area/admin)
"Wu" = (
/obj/machinery/computer/crew{
/obj/machinery/computer/crew/advanced{
dir = 4
},
/turf/simulated/floor/wood,
+4 -4
View File
@@ -7,12 +7,12 @@ GLOBAL_DATUM_INIT(crew_repository, /datum/repository/crew, new())
cache_data = list()
..()
/datum/repository/crew/proc/health_data(turf/T)
/datum/repository/crew/proc/health_data(z)
var/list/crewmembers = list()
if(!T)
if(!z)
return crewmembers
var/z_level = "[T.z]"
var/z_level = "[z]"
var/datum/cache_entry/cache_entry = cache_data[z_level]
if(!cache_entry)
cache_entry = new/datum/cache_entry
@@ -34,7 +34,7 @@ GLOBAL_DATUM_INIT(crew_repository, /datum/repository/crew, new())
if(!C || C.sensor_mode == SUIT_SENSOR_OFF || !C.has_sensor)
continue
var/turf/pos = get_turf(C)
if(!istype(pos) || !T || pos.z != T.z)
if(!istype(pos) || pos.z != z)
continue
var/list/crewmemberData = list("dead"=0, "oxy"=-1, "tox"=-1, "fire"=-1, "brute"=-1, "area"="", "x"=-1, "y"=-1, "ref" = "\ref[H]")
@@ -31,3 +31,11 @@
/obj/machinery/computer/crew/interact(mob/user)
crew_monitor.ui_interact(user)
/obj/machinery/computer/crew/advanced
name = "advanced crew monitoring computer"
desc = "Used to monitor active health sensors built into most of the crew's uniforms across multiple sectors."
/obj/machinery/computer/crew/advanced/Initialize()
. = ..()
crew_monitor.is_advanced = TRUE
+34 -7
View File
@@ -1,14 +1,19 @@
/datum/ui_module/crew_monitor
name = "Crew monitor"
var/is_advanced = FALSE
var/viewing_current_z_level
/datum/ui_module/crew_monitor/ui_act(action, params)
if(..())
return TRUE
var/turf/T = get_turf(ui_host())
if(!T || !is_level_reachable(T.z))
to_chat(usr, "<span class='warning'><b>Unable to establish a connection</b>: You're too far away from the station!</span>")
return FALSE
if(!is_advanced)
var/turf/T = get_turf(ui_host())
if(!T || !is_level_reachable(T.z))
to_chat(usr, "<span class='warning'><b>Unable to establish a connection</b>: You're too far away from the station!</span>")
return FALSE
. = TRUE
switch(action)
if("track")
@@ -17,7 +22,11 @@
var/mob/living/carbon/human/H = locate(params["track"]) in GLOB.human_list
if(hassensorlevel(H, SUIT_SENSOR_TRACKING))
AI.ai_actual_track(H)
return TRUE
if("switch_level")
if(!is_advanced)
return
viewing_current_z_level = text2num(params["new_level"])
/datum/ui_module/crew_monitor/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
@@ -34,10 +43,28 @@
/datum/ui_module/crew_monitor/ui_data(mob/user)
var/list/data = list()
var/turf/T = get_turf(ui_host())
if(!is_advanced) // Advanced, allow viewing across multiple z-levels, but controlled by ui_act
var/turf/T = get_turf(ui_host())
viewing_current_z_level = T.z
if(!viewing_current_z_level)
viewing_current_z_level = level_name_to_num(MAIN_STATION) // by default, set it to the station
data["viewing_current_z_level"] = viewing_current_z_level
data["isAI"] = isAI(user)
data["crewmembers"] = GLOB.crew_repository.health_data(T)
data["crewmembers"] = GLOB.crew_repository.health_data(viewing_current_z_level)
data["critThreshold"] = HEALTH_THRESHOLD_CRIT
return data
/datum/ui_module/crew_monitor/ui_static_data(mob/user)
var/list/data = list()
data["is_advanced"] = is_advanced
data["possible_levels"] = list()
for(var/z in 1 to world.maxz)
data["possible_levels"] |= z
return data
+32 -15
View File
@@ -1,10 +1,11 @@
import { sortBy } from 'common/collections';
import { createSearch } from 'common/string';
import { useBackend, useLocalState } from '../backend';
import { Box, Button, Icon, Input, NanoMap, Table, Tabs } from '../components';
import { Box, Button, Dropdown, Flex, Icon, Input, NanoMap, Table, Tabs } from '../components';
import { TableCell } from '../components/Table';
import { COLORS } from '../constants.js';
import { Window } from '../layouts';
import { FlexItem } from '../components/Flex';
const getStatText = (cm, critThreshold) => {
if (cm.dead) {
@@ -38,6 +39,7 @@ const getStatColor = (cm, critThreshold) => {
export const CrewMonitor = (props, context) => {
const { act, data } = useBackend(context);
const { possible_levels, viewing_current_z_level, is_advanced } = data;
const [tabIndex, setTabIndex] = useLocalState(context, 'tabIndex', 0);
const decideTab = (index) => {
switch (index) {
@@ -55,20 +57,35 @@ export const CrewMonitor = (props, context) => {
<Window.Content>
<Box fillPositionedParent>
<Tabs>
<Tabs.Tab
key="DataView"
selected={0 === tabIndex}
onClick={() => setTabIndex(0)}
>
<Icon name="table" /> Data View
</Tabs.Tab>
<Tabs.Tab
key="MapView"
selected={1 === tabIndex}
onClick={() => setTabIndex(1)}
>
<Icon name="map-marked-alt" /> Map View
</Tabs.Tab>
<Flex>
<FlexItem grow basis={100}>
<Tabs.Tab
key="DataView"
selected={0 === tabIndex}
onClick={() => setTabIndex(0)}
>
<Icon name="table" /> Data View
</Tabs.Tab>
<Tabs.Tab
key="MapView"
selected={1 === tabIndex}
onClick={() => setTabIndex(1)}
>
<Icon name="map-marked-alt" /> Map View
</Tabs.Tab>
</FlexItem>
{is_advanced ? (
<FlexItem>
<Dropdown
options={possible_levels}
selected={viewing_current_z_level}
onSelected={(val) => act("switch_level", {new_level: val})}
/>
</FlexItem>
) : (
null
)}
</Flex>
</Tabs>
{decideTab(tabIndex)}
</Box>
File diff suppressed because one or more lines are too long