From ff57c5a294d8779082e69d06989b4ed8f3d71df4 Mon Sep 17 00:00:00 2001 From: Artur Date: Fri, 22 May 2020 16:44:21 +0300 Subject: [PATCH] Fixes APC and makes sleeper work again --- code/modules/power/apc.dm | 2 +- tgui/packages/tgui/interfaces/Apc.js | 101 ++++++++++++----------- tgui/packages/tgui/interfaces/Sleeper.js | 15 ++-- 3 files changed, 64 insertions(+), 54 deletions(-) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 0fb53501f9..eb3f2a5dc3 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -854,7 +854,7 @@ ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) if(!ui) - ui = new(user, src, ui_key, "Apc", name, 450, 460, master_ui, state) + ui = new(user, src, ui_key, "Apc", name, 480, 460, master_ui, state) ui.open() /obj/machinery/power/apc/ui_data(mob/user) diff --git a/tgui/packages/tgui/interfaces/Apc.js b/tgui/packages/tgui/interfaces/Apc.js index c899ea8ae7..0f44e3509d 100644 --- a/tgui/packages/tgui/interfaces/Apc.js +++ b/tgui/packages/tgui/interfaces/Apc.js @@ -1,50 +1,63 @@ import { Fragment } from 'inferno'; import { useBackend } from '../backend'; import { Box, Button, LabeledList, NoticeBox, ProgressBar, Section } from '../components'; +import { Window } from '../layouts'; import { InterfaceLockNoticeBox } from './common/InterfaceLockNoticeBox'; -export const Apc = props => { - const { act, data } = useBackend(props); +export const Apc = (props, context) => { + return ( + + + + + + ); +}; + +const powerStatusMap = { + 2: { + color: 'good', + externalPowerText: 'External Power', + chargingText: 'Fully Charged', + }, + 1: { + color: 'average', + externalPowerText: 'Low External Power', + chargingText: 'Charging', + }, + 0: { + color: 'bad', + externalPowerText: 'No External Power', + chargingText: 'Not Charging', + }, +}; + +const malfMap = { + 1: { + icon: 'terminal', + content: 'Override Programming', + action: 'hack', + }, + 2: { + icon: 'caret-square-down', + content: 'Shunt Core Process', + action: 'occupy', + }, + 3: { + icon: 'caret-square-left', + content: 'Return to Main Core', + action: 'deoccupy', + }, + 4: { + icon: 'caret-square-down', + content: 'Shunt Core Process', + action: 'occupy', + }, +}; + +const ApcContent = (props, context) => { + const { act, data } = useBackend(context); const locked = data.locked && !data.siliconUser; - const powerStatusMap = { - 2: { - color: 'good', - externalPowerText: 'External Power', - chargingText: 'Fully Charged', - }, - 1: { - color: 'average', - externalPowerText: 'Low External Power', - chargingText: 'Charging', - }, - 0: { - color: 'bad', - externalPowerText: 'No External Power', - chargingText: 'Not Charging', - }, - }; - const malfMap = { - 1: { - icon: 'terminal', - content: 'Override Programming', - action: 'hack', - }, - 2: { - icon: 'caret-square-down', - content: 'Shunt Core Process', - action: 'occupy', - }, - 3: { - icon: 'caret-square-left', - content: 'Return to Main Core', - action: 'deoccupy', - }, - 4: { - icon: 'caret-square-down', - content: 'Shunt Core Process', - action: 'occupy', - }, - }; const externalPowerStatus = powerStatusMap[data.externalPower] || powerStatusMap[0]; const chargingStatus = powerStatusMap[data.chargingStatus] @@ -52,7 +65,6 @@ export const Apc = props => { const channelArray = data.powerChannels || []; const malfStatus = malfMap[data.malfStatus] || malfMap[0]; const adjustedCellChange = data.powerCellStatus / 100; - if (data.failTime > 0) { return ( @@ -73,10 +85,7 @@ export const Apc = props => { return ( - act('lock')} /> +
{ - const { act, data } = useBackend(props); +export const Sleeper = (props, context) => { + const { act, data } = useBackend(context); + const { - occupied, open, - occupant = [], + occupant = {}, + occupied, } = data; const preSortChems = data.chems || []; @@ -69,7 +71,7 @@ export const Sleeper = props => { )}> {!!occupied && ( - + { {occupant.brainLoss ? 'Abnormal' : 'Healthy'} - + )}
@@ -178,6 +180,5 @@ export const Sleeper = props => {
- ); };