From 3ba84da40a05eeab6c066ec323fae6f99696f899 Mon Sep 17 00:00:00 2001 From: PowerfulBacon <26465327+PowerfulBacon@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:13:00 +0100 Subject: [PATCH] Revert "[Port] Crew monitoring console sorting (#11363)" This reverts commit 7429631f4bab55e54e24e055bf3b960549462378. --- tgui/packages/tgui/constants.js | 1 - tgui/packages/tgui/interfaces/CrewConsole.js | 139 ++++++++++ tgui/packages/tgui/interfaces/CrewConsole.tsx | 258 ------------------ 3 files changed, 139 insertions(+), 259 deletions(-) create mode 100644 tgui/packages/tgui/interfaces/CrewConsole.js delete mode 100644 tgui/packages/tgui/interfaces/CrewConsole.tsx diff --git a/tgui/packages/tgui/constants.js b/tgui/packages/tgui/constants.js index 182bcd0634c7a..4caf607c13261 100644 --- a/tgui/packages/tgui/constants.js +++ b/tgui/packages/tgui/constants.js @@ -20,7 +20,6 @@ export const COLORS = { science: '#9b59b6', engineering: '#f1c40f', cargo: '#f39c12', - service: '#7cc46a', centcom: '#00c100', other: '#c38312', }, diff --git a/tgui/packages/tgui/interfaces/CrewConsole.js b/tgui/packages/tgui/interfaces/CrewConsole.js new file mode 100644 index 0000000000000..bf72fad4e327a --- /dev/null +++ b/tgui/packages/tgui/interfaces/CrewConsole.js @@ -0,0 +1,139 @@ +import { useBackend } from '../backend'; +import { Box, Button, ColorBox, Section, Table } from '../components'; +import { COLORS } from '../constants'; +import { Window } from '../layouts'; +import { sortBy } from 'common/collections'; + +export const HEALTH_COLOR_BY_LEVEL = ['#17d568', '#2ecc71', '#e67e22', '#ed5100', '#e74c3c', '#ed2814']; + +export const jobIsHead = (jobId) => jobId % 10 === 0; + +export const jobToColor = (jobId) => { + if (jobId >= 0 && jobId < 10) { + return COLORS.department.captain; + } + if (jobId >= 10 && jobId < 20) { + return COLORS.department.security; + } + if (jobId >= 20 && jobId < 30) { + return COLORS.department.medbay; + } + if (jobId >= 30 && jobId < 40) { + return COLORS.department.science; + } + if (jobId >= 40 && jobId < 50) { + return COLORS.department.engineering; + } + if (jobId >= 50 && jobId < 60) { + return COLORS.department.cargo; + } + if (jobId >= 200 && jobId < 230) { + return COLORS.department.centcom; + } + if (jobId === -1) { + return null; + } + return COLORS.department.other; +}; + +export const healthToColor = (oxy, tox, burn, brute) => { + const healthSum = oxy + tox + burn + brute; + const level = Math.min(Math.max(Math.ceil(healthSum / 25), 0), 5); + return HEALTH_COLOR_BY_LEVEL[level]; +}; + +export const HealthStat = (props) => { + const { type, value } = props; + return ( + + {value} + + ); +}; + +export const CrewConsole = () => { + return ( + + +
+ +
+
+
+ ); +}; + +const CrewTable = (props, context) => { + const { act, data } = useBackend(context); + const sensors = sortBy((s) => s.ijob)(data.sensors ?? []); + return ( + + + Name + + + Vitals + + Position + {!!data.link_allowed && ( + + Tracking + + )} + + {sensors.map((sensor) => ( + + ))} +
+ ); +}; + +const CrewTableEntry = (props, context) => { + const { act, data } = useBackend(context); + const { link_allowed } = data; + const { sensor_data } = props; + const { name, assignment, ijob, life_status, oxydam, toxdam, burndam, brutedam, area, can_track } = sensor_data; + + return ( + + + {name} + {assignment !== undefined ? ` (${assignment})` : ''} + + + {life_status ? : } + + + {oxydam !== undefined ? ( + + + {'/'} + + {'/'} + + {'/'} + + + ) : life_status ? ( + 'Alive' + ) : ( + 'Dead' + )} + + {area !== undefined ? area : 'N/A'} + {!!link_allowed && ( + + - - setSearchQuery((e.target as HTMLTextAreaElement).value)} /> - - }> - - - Name - - - Vitals - - - Position - - {!!data.link_allowed && ( - - Tracking - - )} - - {sorted.map((sensor) => ( - - ))} -
- - ); -}; - -type CrewTableEntryProps = { - sensor_data: CrewSensor; -}; - -const CrewTableEntry = (props: CrewTableEntryProps, context) => { - const { act, data } = useBackend(context); - const { link_allowed } = data; - const { sensor_data } = props; - const { name, assignment, ijob, life_status, oxydam, toxdam, burndam, brutedam, area, can_track } = sensor_data; - - return ( - - - {name} - {assignment !== undefined ? ` (${assignment})` : ''} - - - {oxydam !== undefined ? ( - - ) : life_status !== STAT_DEAD ? ( - - ) : ( - - )} - - - {oxydam !== undefined ? ( - - - {'/'} - - {'/'} - - {'/'} - - - ) : life_status !== STAT_DEAD ? ( - 'Alive' - ) : ( - 'Dead' - )} - - {area !== '~' && area !== undefined ? area : } - {!!link_allowed && ( - - - - )} - - ); -};