mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-13 08:56:49 +01:00
Makes the Shield Capacitor UI into a TGUI. (#17719)
* Makes the Shield Capacitor UI into a TGUI. * Update code/modules/shieldgen/shield_capacitor.dm Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> --------- Co-authored-by: Matt Atlas <liermattia@gmail.com> Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com>
This commit is contained in:
@@ -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 = "<B>Shield Capacitor Control Console</B><br><br>"
|
||||
if(locked)
|
||||
t += "<i>Swipe your ID card to begin.</i>"
|
||||
else
|
||||
t += "This capacitor is: [active ? "<font color=green>Online</font>" : "<font color=red>Offline</font>" ] <a href='?src=\ref[src];toggle=1'>[active ? "\[Deactivate\]" : "\[Activate\]"]</a><br>"
|
||||
t += "Capacitor Status: [time_since_fail > 2 ? "<font color=green>OK.</font>" : "<font color=red>Discharging!</font>"]<br>"
|
||||
t += "Stored Energy: [round(stored_charge/1000, 0.1)] kJ ([100 * round(stored_charge/max_charge, 0.1)]%)<br>"
|
||||
t += "Charge Rate: \
|
||||
<a href='?src=\ref[src];charge_rate=-100000'>\[----\]</a> \
|
||||
<a href='?src=\ref[src];charge_rate=-10000'>\[---\]</a> \
|
||||
<a href='?src=\ref[src];charge_rate=-1000'>\[--\]</a> \
|
||||
<a href='?src=\ref[src];charge_rate=-100'>\[-\]</a>[charge_rate] W \
|
||||
<a href='?src=\ref[src];charge_rate=100'>\[+\]</a> \
|
||||
<a href='?src=\ref[src];charge_rate=1000'>\[++\]</a> \
|
||||
<a href='?src=\ref[src];charge_rate=10000'>\[+++\]</a> \
|
||||
<a href='?src=\ref[src];charge_rate=100000'>\[+++\]</a><br>"
|
||||
t += "<hr>"
|
||||
t += "<A href='?src=\ref[src]'>Refresh</A> "
|
||||
t += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
/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, "<span class='warning'>The [src] needs to be firmly secured to the floor first.</span>")
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user