diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm
index 25fb343136..c4831a1a94 100644
--- a/code/__defines/misc.dm
+++ b/code/__defines/misc.dm
@@ -462,6 +462,17 @@ GLOBAL_LIST_INIT(all_volume_channels, list(
#ifndef HTTP_POST_DLL_LOCATION
#define HTTP_POST_DLL_LOCATION (world.system_type == MS_WINDOWS ? WINDOWS_HTTP_POST_DLL_LOCATION : UNIX_HTTP_POST_DLL_LOCATION)
+<<<<<<< HEAD
+#endif
+||||||| parent of da19f6f9b3... Merge pull request #10740 from ShadowLarkens/ux_fixes
#endif
-#define DOCK_ATTEMPT_TIMEOUT 200 //how long in ticks we wait before assuming the docking controller is broken or blown up.
\ No newline at end of file
+#define DOCK_ATTEMPT_TIMEOUT 200 //how long in ticks we wait before assuming the docking controller is broken or blown up.
+=======
+#endif
+
+#define DOCK_ATTEMPT_TIMEOUT 200 //how long in ticks we wait before assuming the docking controller is broken or blown up.
+
+#define SMES_TGUI_INPUT 1
+#define SMES_TGUI_OUTPUT 2
+>>>>>>> da19f6f9b3... Merge pull request #10740 from ShadowLarkens/ux_fixes
diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm
index ac091a9fdb..d0dc9a21e0 100644
--- a/code/modules/power/smes.dm
+++ b/code/modules/power/smes.dm
@@ -375,7 +375,6 @@ GLOBAL_LIST_EMPTY(smeses)
return 0
return round(100.0*charge/capacity, 0.1)
-
/obj/machinery/power/smes/tgui_act(action, params)
if(..())
return TRUE
@@ -389,39 +388,30 @@ GLOBAL_LIST_EMPTY(smeses)
update_icon()
. = TRUE
if("input")
- var/target = params["target"]
- var/adjust = text2num(params["adjust"])
- if(target == "min")
- target = 0
- . = TRUE
- else if(target == "max")
- target = input_level_max
- . = TRUE
- else if(adjust)
- target = input_level + adjust
- . = TRUE
- else if(text2num(target) != null)
- target = text2num(target)
- . = TRUE
- if(.)
- input_level = clamp(target, 0, input_level_max)
+ tgui_set_io(SMES_TGUI_INPUT, params["target"], text2num(params["adjust"]))
if("output")
- var/target = params["target"]
- var/adjust = text2num(params["adjust"])
- if(target == "min")
- target = 0
- . = TRUE
- else if(target == "max")
- target = output_level_max
- . = TRUE
- else if(adjust)
- target = output_level + adjust
- . = TRUE
- else if(text2num(target) != null)
- target = text2num(target)
- . = TRUE
- if(.)
- output_level = clamp(target, 0, output_level_max)
+ tgui_set_io(SMES_TGUI_OUTPUT, params["target"], text2num(params["adjust"]))
+
+/obj/machinery/power/smes/proc/tgui_set_io(io, target, adjust)
+ if(target == "min")
+ target = 0
+ . = TRUE
+ else if(target == "max")
+ target = output_level_max
+ . = TRUE
+ else if(adjust)
+ target = output_level + adjust
+ . = TRUE
+ else if(text2num(target) != null)
+ target = text2num(target)
+ . = TRUE
+ if(.)
+ switch(io)
+ if(SMES_TGUI_INPUT)
+ set_input(target)
+ if(SMES_TGUI_OUTPUT)
+ set_output(target)
+
/obj/machinery/power/smes/proc/inputting(var/do_input)
input_attempt = do_input
@@ -481,4 +471,33 @@ GLOBAL_LIST_EMPTY(smeses)
if(25 to 49)
. += "It's casing is quite seriously damaged."
if(0 to 24)
- . += "It's casing has some minor damage."
\ No newline at end of file
+ . += "It's casing has some minor damage."
+
+
+// Proc: toggle_input()
+// Parameters: None
+// Description: Switches the input on/off depending on previous setting
+/obj/machinery/power/smes/proc/toggle_input()
+ inputting(!input_attempt)
+ update_icon()
+
+// Proc: toggle_output()
+// Parameters: None
+// Description: Switches the output on/off depending on previous setting
+/obj/machinery/power/smes/proc/toggle_output()
+ outputting(!output_attempt)
+ update_icon()
+
+// Proc: set_input()
+// Parameters: 1 (new_input - New input value in Watts)
+// Description: Sets input setting on this SMES. Trims it if limits are exceeded.
+/obj/machinery/power/smes/proc/set_input(var/new_input = 0)
+ input_level = between(0, new_input, input_level_max)
+ update_icon()
+
+// Proc: set_output()
+// Parameters: 1 (new_output - New output value in Watts)
+// Description: Sets output setting on this SMES. Trims it if limits are exceeded.
+/obj/machinery/power/smes/proc/set_output(var/new_output = 0)
+ output_level = between(0, new_output, output_level_max)
+ update_icon()
\ No newline at end of file
diff --git a/code/modules/power/smes_construction.dm b/code/modules/power/smes_construction.dm
index 326e9ecd23..dae8941e8c 100644
--- a/code/modules/power/smes_construction.dm
+++ b/code/modules/power/smes_construction.dm
@@ -361,31 +361,3 @@
recalc_coils()
else
to_chat(user, "You can't insert more coils into this SMES unit!")
-
-// Proc: toggle_input()
-// Parameters: None
-// Description: Switches the input on/off depending on previous setting
-/obj/machinery/power/smes/buildable/proc/toggle_input()
- inputting(!input_attempt)
- update_icon()
-
-// Proc: toggle_output()
-// Parameters: None
-// Description: Switches the output on/off depending on previous setting
-/obj/machinery/power/smes/buildable/proc/toggle_output()
- outputting(!output_attempt)
- update_icon()
-
-// Proc: set_input()
-// Parameters: 1 (new_input - New input value in Watts)
-// Description: Sets input setting on this SMES. Trims it if limits are exceeded.
-/obj/machinery/power/smes/buildable/proc/set_input(var/new_input = 0)
- input_level = between(0, new_input, input_level_max)
- update_icon()
-
-// Proc: set_output()
-// Parameters: 1 (new_output - New output value in Watts)
-// Description: Sets output setting on this SMES. Trims it if limits are exceeded.
-/obj/machinery/power/smes/buildable/proc/set_output(var/new_output = 0)
- output_level = between(0, new_output, output_level_max)
- update_icon()
\ No newline at end of file
diff --git a/code/modules/tgui/modules/rcon.dm b/code/modules/tgui/modules/rcon.dm
index 62cf3e5d71..01ba355248 100644
--- a/code/modules/tgui/modules/rcon.dm
+++ b/code/modules/tgui/modules/rcon.dm
@@ -12,17 +12,9 @@
// SMES DATA (simplified view)
var/list/smeslist[0]
for(var/obj/machinery/power/smes/buildable/SMES in known_SMESs)
- smeslist.Add(list(list(
- "capacity" = SMES.capacity,
- "capacityPercent" = round(100*SMES.charge/SMES.capacity, 0.1),
- "charge" = SMES.charge,
- "input_set" = SMES.input_attempt,
- "input_val" = round(SMES.input_level/1000, 0.1),
- "output_set" = SMES.output_attempt,
- "output_val" = round(SMES.output_level/1000, 0.1),
- "output_load" = round(SMES.output_used/1000, 0.1),
- "RCON_tag" = SMES.RCon_tag
- )))
+ var/list/smes_data = SMES.tgui_data()
+ smes_data["RCON_tag"] = SMES.RCon_tag
+ smeslist.Add(list(smes_data))
data["smes_info"] = sortByKey(smeslist, "RCON_tag")
@@ -55,14 +47,16 @@
if("smes_in_set")
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(params["smes"])
if(SMES)
- var/inputset = (input(usr, "Enter new input level (0-[SMES.input_level_max/1000] kW)", "SMES Input Power Control", SMES.input_level/1000) as num) * 1000
- SMES.set_input(inputset)
+ SMES.tgui_set_io(SMES_TGUI_INPUT, params["target"], text2num(params["adjust"]))
+ // var/inputset = (input(usr, "Enter new input level (0-[SMES.input_level_max/1000] kW)", "SMES Input Power Control", SMES.input_level/1000) as num) * 1000
+ // SMES.set_input(inputset)
. = TRUE
if("smes_out_set")
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(params["smes"])
if(SMES)
- var/outputset = (input(usr, "Enter new output level (0-[SMES.output_level_max/1000] kW)", "SMES Output Power Control", SMES.output_level/1000) as num) * 1000
- SMES.set_output(outputset)
+ SMES.tgui_set_io(SMES_TGUI_OUTPUT, params["target"], text2num(params["adjust"]))
+ // var/outputset = (input(usr, "Enter new output level (0-[SMES.output_level_max/1000] kW)", "SMES Output Power Control", SMES.output_level/1000) as num) * 1000
+ // SMES.set_output(outputset)
. = TRUE
if("toggle_breaker")
var/obj/machinery/power/breakerbox/toggle = null
diff --git a/tgui/packages/tgui/interfaces/RCON.js b/tgui/packages/tgui/interfaces/RCON.js
index f057749b63..46477d60ca 100644
--- a/tgui/packages/tgui/interfaces/RCON.js
+++ b/tgui/packages/tgui/interfaces/RCON.js
@@ -1,8 +1,14 @@
import { round } from 'common/math';
+import { formatPower } from '../format';
import { Fragment } from 'inferno';
import { useBackend, useLocalState } from "../backend";
-import { Box, Button, Flex, Icon, LabeledList, ProgressBar, Section, Tabs } from "../components";
+import { Box, Button, Flex, Icon, LabeledList, ProgressBar, Stack, Section, Tabs, Slider, AnimatedNumber } from "../components";
import { Window } from "../layouts";
+import { capitalize } from 'common/string';
+
+// Common power multiplier
+const POWER_MUL = 1e3;
+
export const RCON = (props, context) => {
return (
@@ -59,76 +65,194 @@ const RCONSmesList = (props, context) => {
return (
-
- {smes_info ? smes_info.map(smes => (
-
-
-
- {
- round(smes.charge/(1000*60), 1)
- } kWh / {
- round(smes.capacity/(1000*60))
- } kWh ({smes.capacityPercent}%)
-
-
-
-
-
-
- act("smes_out_toggle", {
- smes: smes.RCON_tag,
- })} />
- act("smes_out_set", {
- smes: smes.RCON_tag,
- })} />
-
- )}>
- {smes.output_val} kW - {smes.output_set ? "ONLINE" : "OFFLINE"}
-
-
- {smes.output_load} kW
-
-
-
- )) : (
-
- No SMESs detected.
-
- )}
-
+
+ {smes_info.map(smes => (
+
+
+
+ ))}
+
);
};
+const SMESItem = (props, context) => {
+ const { act } = useBackend(context);
+ const {
+ capacityPercent,
+ capacity,
+ charge,
+ inputAttempt,
+ inputting,
+ inputLevel,
+ inputLevelMax,
+ inputAvailable,
+ outputAttempt,
+ outputting,
+ outputLevel,
+ outputLevelMax,
+ outputUsed,
+ RCON_tag,
+ } = props.smes;
+
+ return (
+
+
+
+
+ {RCON_tag}
+
+
+
+ {round(charge/(1000*60), 1)} kWh / {round(capacity/(1000*60))} kWh
+ ({capacityPercent}%)
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+const SMESControls = (props, context) => {
+ const { act } = useBackend(context);
+ const {
+ way,
+ smes,
+ } = props;
+ const {
+ capacityPercent,
+ capacity,
+ charge,
+ inputAttempt,
+ inputting,
+ inputLevel,
+ inputLevelMax,
+ inputAvailable,
+ outputAttempt,
+ outputting,
+ outputLevel,
+ outputLevelMax,
+ outputUsed,
+ RCON_tag,
+ } = smes;
+
+ let level;
+ let levelMax;
+ let available;
+ let direction;
+ let changeStatusAct;
+ let changeAmountAct;
+ let enabled;
+ let powerColor;
+ let powerTooltip;
+
+ switch (way) {
+ case "input":
+ level = inputLevel;
+ levelMax = inputLevelMax;
+ available = inputAvailable;
+ direction = "IN";
+ changeStatusAct = "smes_in_toggle";
+ changeAmountAct = "smes_in_set";
+ enabled = inputAttempt;
+ powerColor = !inputAttempt ? null : (inputting ? "green" : "yellow");
+ powerTooltip = !inputAttempt ? "The SMES input is off." : (inputting ? "The SMES is drawing power." : "The SMES lacks power.");
+ break;
+ case "output":
+ level = outputLevel;
+ levelMax = outputLevelMax;
+ available = outputUsed;
+ direction = "OUT";
+ changeStatusAct = "smes_out_toggle";
+ changeAmountAct = "smes_out_set";
+ enabled = outputAttempt;
+ powerColor = !outputAttempt ? null : (outputting ? "green" : "yellow");
+ powerTooltip = !outputAttempt ? "The SMES output is off." : (outputting ? "The SMES is outputting power." : "The SMES lacks any draw.");
+ break;
+ }
+
+ return (
+
+
+ {capitalize(way)}
+
+
+
+
+ act(changeStatusAct, {
+ smes: RCON_tag,
+ })} />
+
+
+ act(changeAmountAct, {
+ target: 'min',
+ smes: RCON_tag,
+ })} />
+ act(changeAmountAct, {
+ adjust: -10000,
+ smes: RCON_tag,
+ })} />
+
+
+ formatPower(available, 1) + "/" + formatPower(value * POWER_MUL, 1)}
+ onDrag={(e, value) => act(changeAmountAct, {
+ target: value * POWER_MUL,
+ smes: RCON_tag,
+ })} />
+
+
+ act(changeAmountAct, {
+ adjust: 10000,
+ smes: RCON_tag,
+ })} />
+ act(changeAmountAct, {
+ target: 'max',
+ smes: RCON_tag,
+ })} />
+
+
+
+
+ );
+};
+
const RCONBreakerList = (props, context) => {
const { act, data } = useBackend(context);