mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 01:49:19 +00:00
Update Turbine computer to use TGUI
This commit is contained in:
committed by
CitadelStationBot
parent
dbf2467f5e
commit
694958f587
@@ -332,51 +332,38 @@
|
||||
if(..())
|
||||
return
|
||||
|
||||
interact(user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/turbine_computer/interact(mob/user)
|
||||
/obj/machinery/computer/turbine_computer/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "turbine_computer", name, 350, 280, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
var/dat
|
||||
if(compressor && compressor.turbine)
|
||||
dat += "<BR><B>Gas turbine remote control system</B><HR>"
|
||||
if(compressor.stat || compressor.turbine.stat)
|
||||
dat += "[compressor.stat ? "<B>Compressor is inoperable</B><BR>" : "<B>Turbine is inoperable</B>"]"
|
||||
else
|
||||
dat += {"Turbine status: [ src.compressor.starter ? "<A href='?src=[REF(src)];str=1'>Off</A> <B>On</B>" : "<B>Off</B> <A href='?src=[REF(src)];str=1'>On</A>"]
|
||||
\n<BR>
|
||||
\nTurbine speed: [src.compressor.rpm]rpm<BR>
|
||||
\nPower currently being generated: [DisplayPower(src.compressor.turbine.lastgen)]<BR>
|
||||
\nInternal gas temperature: [src.compressor.gas_contained.temperature]K<BR>
|
||||
\n</PRE><HR><A href='?src=[REF(src)];close=1'>Close</A>
|
||||
\n<BR>
|
||||
\n"}
|
||||
else
|
||||
dat += "<B>There is [!compressor ? "no compressor" : " compressor[!compressor.turbine ? " but no turbine" : ""]"].</B><BR>"
|
||||
if(!compressor)
|
||||
dat += "<A href='?src=[REF(src)];search=1'>Search for compressor</A>"
|
||||
/obj/machinery/computer/turbine_computer/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
var/datum/browser/popup = new(user, "turbinecomputer", name)
|
||||
popup.set_content(dat)
|
||||
popup.open()
|
||||
return
|
||||
data["working"] = (compressor.starter && compressor && compressor.turbine && !compressor.stat && !compressor.turbine.stat)
|
||||
data["connected"] = (compressor && compressor.turbine) ? TRUE : FALSE
|
||||
data["compressor_broke"] = (!compressor || compressor.stat) ? TRUE : FALSE
|
||||
data["turbine_broke"] = (!compressor || compressor.turbine.stat) ? TRUE : FALSE
|
||||
data["online"] = compressor.starter
|
||||
|
||||
/obj/machinery/computer/turbine_computer/Topic(href, href_list)
|
||||
data["power"] = DisplayPower(compressor.turbine.lastgen)
|
||||
data["rpm"] = compressor.rpm
|
||||
data["temp"] = compressor.gas_contained.temperature
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/computer/turbine_computer/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
|
||||
else if( href_list["str"] )
|
||||
if(compressor && compressor.turbine)
|
||||
compressor.starter = !compressor.starter
|
||||
else if( href_list["close"] )
|
||||
usr << browse(null, "window=turbinecomputer")
|
||||
usr.unset_machine(src)
|
||||
return
|
||||
else if(href_list["search"])
|
||||
locate_machinery()
|
||||
|
||||
src.updateUsrDialog()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/turbine_computer/process()
|
||||
src.updateDialog()
|
||||
return
|
||||
switch(action)
|
||||
if("power")
|
||||
if(compressor && compressor.turbine)
|
||||
compressor.starter = !compressor.starter
|
||||
. = TRUE
|
||||
if("reconnect")
|
||||
locate_machinery()
|
||||
. = TRUE
|
||||
|
||||
51
tgui/src/interfaces/turbine_computer.ract
Normal file
51
tgui/src/interfaces/turbine_computer.ract
Normal file
@@ -0,0 +1,51 @@
|
||||
<script>
|
||||
component.exports = {
|
||||
data: {
|
||||
powerState (status) {
|
||||
switch (status) {
|
||||
case 1: return 'good'
|
||||
default: return 'bad'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<ui-notice>
|
||||
<ui-section label='Reconnect'>
|
||||
<div style='float:right'>
|
||||
<ui-button icon='refresh' action='reconnect' state='{{data.connected}}'>Reconnect</ui-button>
|
||||
</div>
|
||||
</ui-section>
|
||||
</ui-notice>
|
||||
<ui-display title='Turbine Controller'>
|
||||
<ui-section label='Status'>
|
||||
{{#if data.working}}
|
||||
<span class='{{powerState(data.online)}}'>{{data.online && !(data.compressor_broke || data.turbine_broke) ? "Online" : "Offline"}}</span>
|
||||
{{else}}
|
||||
<span class='bad'>Broken</span>
|
||||
{{/if}}
|
||||
<div style='float:right'>
|
||||
<ui-button icon='power-off' action='power' state='{{data.working}}' style='{{data.online ? "selected" : ""}}'>On</ui-button>
|
||||
<ui-button icon='close' action='power' state='{{data.working}}' style='{{data.online ? "" : "selected"}}'>Off</ui-button>
|
||||
</div>
|
||||
{{#if data.compressor_broke}}
|
||||
<br>
|
||||
[ <span class='bad'>Compressor is inoperable</span> ]
|
||||
{{/if}}
|
||||
{{#if data.turbine_broke}}
|
||||
<br>
|
||||
[ <span class='bad'>Turbine is inoperable</span> ]
|
||||
{{/if}}
|
||||
</ui-section>
|
||||
</ui-display>
|
||||
<ui-display title='Status'>
|
||||
<ui-section label='Turbine Speed'>
|
||||
<span>{{data.working ? data.rpm : "--"}} RPM</span>
|
||||
</ui-section>
|
||||
<ui-section label='Internal Temp'>
|
||||
<span>{{data.working ? data.temp : "--"}} K</span>
|
||||
</ui-section>
|
||||
<ui-section label='Generated Power'>
|
||||
<span>{{data.working ? data.power : "--"}}</span>
|
||||
</ui-section>
|
||||
</ui-display>
|
||||
Reference in New Issue
Block a user