diff --git a/code/modules/shieldgen/shield_capacitor.dm b/code/modules/shieldgen/shield_capacitor.dm
index 0ca99a25277..bd2a026734a 100644
--- a/code/modules/shieldgen/shield_capacitor.dm
+++ b/code/modules/shieldgen/shield_capacitor.dm
@@ -1,25 +1,25 @@
-
-//---------- shield capacitor
-//pulls energy out of a power net and charges an adjacent generator
-
/obj/machinery/shield_capacitor
name = "shield capacitor"
desc = "Machine that charges a shield generator."
icon = 'icons/obj/machinery/shielding.dmi'
icon_state = "capacitor"
obj_flags = OBJ_FLAG_ROTATABLE
- var/active = FALSE
density = TRUE
- var/stored_charge = 0 //not to be confused with power cell charge, this is in Joules
+ /// Doesn't use APC power.
+ use_power = POWER_USE_OFF
+ req_one_access = list(access_captain, access_security, access_engine)
+
+ var/active = FALSE
+ /// Not to be confused with power cell charge, this is in Joules.
+ var/stored_charge = 0
var/last_stored_charge = 0
var/time_since_fail = 100
var/max_charge = 8e6 //8 MJ
var/max_charge_rate = 400000 //400 kW
var/locked = FALSE
- use_power = POWER_USE_OFF //doesn't use APC power
+
var/charge_rate = 100000 //100 kW
var/obj/machinery/shield_gen/owned_gen
- req_one_access = list(access_captain, access_security, access_engine)
/obj/machinery/shield_capacitor/Initialize()
..()
@@ -68,36 +68,40 @@
/obj/machinery/shield_capacitor/attack_hand(mob/user)
if(stat & (BROKEN))
return
- interact(user)
+ ui_interact(user)
-/obj/machinery/shield_capacitor/interact(mob/user)
- if ( !in_range(src, user) || (stat & (BROKEN)) )
- if (!issilicon(user))
- user.unset_machine()
- user << browse(null, "window=shield_capacitor")
- return
- var/t = "Shield Capacitor Control Console
"
- if(locked)
- t += "Swipe your ID card to begin."
- else
- t += "This capacitor is: [active ? "Online" : "Offline" ] [active ? "\[Deactivate\]" : "\[Activate\]"]
"
- t += "Capacitor Status: [time_since_fail > 2 ? "OK." : "Discharging!"]
"
- t += "Stored Energy: [round(stored_charge/1000, 0.1)] kJ ([100 * round(stored_charge/max_charge, 0.1)]%)
"
- t += "Charge Rate: \
- \[----\] \
- \[---\] \
- \[--\] \
- \[-\][charge_rate] W \
- \[+\] \
- \[++\] \
- \[+++\] \
- \[+++\]
"
- t += "
"
- t += "Refresh "
- t += "Close
"
+/obj/machinery/shield_capacitor/ui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ ui = new(user, src, "ShieldCapacitor", "Shield Capacitor", 400, 300)
+ ui.open()
- user << browse(t, "window=shield_capacitor;size=500x400")
- user.set_machine(src)
+/obj/machinery/shield_capacitor/ui_data(mob/user)
+ var/list/data = list()
+ data["anchored"] = anchored
+ data["locked"] = locked
+ data["active"] = active
+ data["time_since_fail"] = time_since_fail
+ data["charge_rate"] = charge_rate
+ data["stored_charge"] = stored_charge
+ data["max_charge"] = max_charge
+ data["max_charge_rate"] = max_charge_rate
+ return data
+
+/obj/machinery/shield_capacitor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
+ . = ..()
+ if(.)
+ return
+ switch(action)
+ if("toggle")
+ if(!active && !anchored)
+ to_chat(usr, SPAN_WARNING("\The [src] needs to be firmly secured to the floor first."))
+ return
+ active = !active
+ . = TRUE
+ if("charge_rate")
+ charge_rate = between(10000, params["charge_rate"], max_charge_rate)
+ . = TRUE
/obj/machinery/shield_capacitor/process()
if (!anchored)
@@ -126,22 +130,6 @@
time_since_fail = 0 //losing charge faster than we can draw from PN
last_stored_charge = stored_charge
-/obj/machinery/shield_capacitor/Topic(href, href_list[])
- ..()
- if( href_list["close"] )
- usr << browse(null, "window=shield_capacitor")
- usr.unset_machine()
- return
- if( href_list["toggle"] )
- if(!active && !anchored)
- to_chat(usr, "The [src] needs to be firmly secured to the floor first.")
- return
- active = !active
- if( href_list["charge_rate"] )
- charge_rate = between(10000, charge_rate + text2num(href_list["charge_rate"]), max_charge_rate)
-
- updateDialog()
-
/obj/machinery/shield_capacitor/power_change()
if(stat & BROKEN)
icon_state = "broke"
diff --git a/html/changelogs/mattatlas-livearrange.yml b/html/changelogs/mattatlas-livearrange.yml
new file mode 100644
index 00000000000..105ec492aa1
--- /dev/null
+++ b/html/changelogs/mattatlas-livearrange.yml
@@ -0,0 +1,41 @@
+################################
+# Example Changelog File
+#
+# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
+#
+# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
+# When it is, any changes listed below will disappear.
+#
+# Valid Prefixes:
+# bugfix
+# wip (For works in progress)
+# tweak
+# soundadd
+# sounddel
+# rscadd (general adding of nice things)
+# rscdel (general deleting of nice things)
+# imageadd
+# imagedel
+# maptweak
+# spellcheck (typo fixes)
+# experiment
+# balance
+# admin
+# backend
+# security
+# refactor
+#################################
+
+# Your name.
+author: MattAtlas
+
+# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
+delete-after: True
+
+# Any changes you've made. See valid prefix list above.
+# INDENT WITH TWO SPACES. NOT TABS. SPACES.
+# SCREW THIS UP AND IT WON'T WORK.
+# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
+# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
+changes:
+ - rscadd: "Made the Shield Capacitor UI into a TGUI."
diff --git a/tgui/packages/tgui/interfaces/ShieldCapacitor.tsx b/tgui/packages/tgui/interfaces/ShieldCapacitor.tsx
new file mode 100644
index 00000000000..1d84c14e30f
--- /dev/null
+++ b/tgui/packages/tgui/interfaces/ShieldCapacitor.tsx
@@ -0,0 +1,84 @@
+import { BooleanLike } from '../../common/react';
+import { useBackend } from '../backend';
+import { Box, Button, LabeledList, NoticeBox, NumberInput, ProgressBar, Section } from '../components';
+import { Window } from '../layouts';
+
+export type CapacitorData = {
+ anchored: BooleanLike;
+ locked: BooleanLike;
+ active: BooleanLike;
+ time_since_fail: number;
+ charge_rate: number;
+ stored_charge: number;
+ max_charge: number;
+ max_charge_rate: number;
+};
+
+export const ShieldCapacitor = (props, context) => {
+ const { act, data } = useBackend(context);
+
+ return (
+
+
+
+ {data.locked ? (
+ Swipe ID to unlock.
+ ) : (
+
+ )}
+
+
+
+ );
+};
+
+export const CapacitorWindow = (props, context) => {
+ const { act, data } = useBackend(context);
+
+ return (
+ act('toggle')}
+ />
+ }>
+
+ Capacitor status:{' '}
+ 2 ? 'good' : 'bad'}>
+ {data.time_since_fail > 2 ? 'OK' : 'Discharging'}.
+
+
+
+
+
+ {data.stored_charge} / {data.max_charge} W
+
+
+
+ act('charge_rate', { charge_rate: v })}
+ unit="W"
+ />
+
+
+
+ );
+};