Adjustments to RCON console UI

- Adds buttons to show/hide specific sections of the UI.
This commit is contained in:
Atlantiscze
2015-01-01 08:40:47 +01:00
parent 5a6815b200
commit 1a1963e292
2 changed files with 104 additions and 62 deletions

View File

@@ -1,3 +1,9 @@
// RCON REMOTE CONTROL CONSOLE
//
// Last Change 1.1.2015 by Atlantis
//
// Allows remote operation of electrical systems on station (SMESs and Breaker Boxes)
/obj/machinery/computer/rcon
name = "\improper RCON remote control console"
desc = "Console used to remotely control machinery on the station."
@@ -8,14 +14,21 @@
var/current_tag = null
var/list/known_SMESs = null
var/list/known_breakers = null
// Allows you to hide specific parts of the UI
var/hide_SMES = 0
var/hide_SMES_details = 0
var/hide_breakers = 0
/obj/machinery/computer/rcon/attack_ai(var/mob/user as mob)
return attack_hand(user)
// Proc: attack_hand()
// Parameters: 1 (user - Person which clicked this computer)
// Description: Opens UI of this machine.
/obj/machinery/computer/rcon/attack_hand(var/mob/user as mob)
..()
ui_interact(user)
// Proc: ui_interact()
// Parameters: 4 (standard NanoUI parameters)
// Description: Uses dark magic (NanoUI) to render this machine's UI
/obj/machinery/computer/rcon/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
FindDevices() // Update our devices list
var/data[0]
@@ -42,20 +55,20 @@
"enabled" = BR.on
)))
data["breaker_info"] = breakerlist
data["hide_smes"] = hide_SMES
data["hide_smes_details"] = hide_SMES_details
data["hide_breakers"] = hide_breakers
// update the ui if it exists, returns null if no ui is passed/found
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
// the ui does not exist, so we'll create a new() one
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
ui = new(user, src, ui_key, "rcon.tmpl", "RCON Control Console", 600, 400)
// when the ui is first opened this is the data it will use
ui.set_initial_data(data)
// open the new ui window
ui.open()
// auto update every Master Controller tick
ui.set_auto_update(1)
// Proc: Topic()
// Parameters: 2 (href, href_list - allows us to process UI clicks)
// Description: Allows us to process UI clicks, which are relayed in form of hrefs.
/obj/machinery/computer/rcon/Topic(href, href_list)
if(href_list["smes_in_toggle"])
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_in_toggle"])
@@ -86,7 +99,17 @@
usr << "The breaker box was recently toggled. Please wait before toggling it again."
else
toggle.auto_toggle()
if(href_list["hide_smes"])
hide_SMES = !hide_SMES
if(href_list["hide_smes_details"])
hide_SMES_details = !hide_SMES_details
if(href_list["hide_breakers"])
hide_breakers = !hide_breakers
// Proc: GetSMESByTag()
// Parameters: 1 (tag - RCON tag of SMES we want to look up)
// Description: Looks up and returns SMES which has matching RCON tag
/obj/machinery/computer/rcon/proc/GetSMESByTag(var/tag)
if(!tag)
return
@@ -95,6 +118,9 @@
if(S.RCon_tag == tag)
return S
// Proc: FindDevices()
// Parameters: None
// Description: Refreshes local list of known devices.
/obj/machinery/computer/rcon/proc/FindDevices()
known_SMESs = new /list()
for(var/obj/machinery/power/smes/buildable/SMES in machines)

View File

@@ -1,57 +1,73 @@
<b>Detected SMES units with RCON support:</b>
{{for data.smes_info}}
<div class = "item">
<div class="itemLabel">
{{:value.RCON_tag}}
<table>
<tr><td>{{:helper.link('Show/Hide SMES readings', 'folder', { 'hide_smes' : 1})}}
<tr><td>{{:helper.link('Show/Hide SMES controls', 'folder', { 'hide_smes_details' : 1})}}
<tr><td>{{:helper.link('Show/Hide Breaker readings', 'folder', { 'hide_breakers' : 1})}}
</table>
{{if data.hide_smes}}
<b>SMES readings hidden.</b><br>
{{else}}
<b>Detected SMES units with RCON support:</b><br>
{{for data.smes_info}}
<div class = "item">
<div class="itemLabel">
{{:value.RCON_tag}}
</div>
<div class="itemContent">
<table>
<tr><td colspan=2>
{{if value.charge > 50}}
{{:helper.displayBar(value.charge, 0, 100, 'good')}}
{{else value.charge > 25}}
{{:helper.displayBar(value.charge, 0, 100, 'average')}}
{{else}}
{{:helper.displayBar(value.charge, 0, 100, 'bad')}}
{{/if}}
<div class="statusValue">
{{:value.charge}}%<br>
</div>
{{if !data.hide_smes_details}}
<tr><td>
Input: {{:value.input_val}}W - {{:value.input_set ? "AUTO" : "OFF"}}
<td>
{{:helper.link('', 'power', { 'smes_in_toggle' : value.RCON_tag})}}
{{:helper.link('', 'pencil', { 'smes_in_set' : value.RCON_tag})}}
<tr><td>
Output: {{:value.output_val}}W - {{:value.output_set ? "ONLINE" : "OFFLINE"}}
<td>
{{:helper.link('', 'power', { 'smes_out_toggle' : value.RCON_tag})}}
{{:helper.link('', 'pencil', { 'smes_out_set' : value.RCON_tag})}}
<tr><td>
Output Load:
<td>
{{:value.output_load}}W
{{/if}}
</table>
</div>
</div>
<div class="itemContent">
<table>
<tr><td colspan=2>
{{if value.charge > 50}}
{{:helper.displayBar(value.charge, 0, 100, 'good')}}
{{else value.charge > 25}}
{{:helper.displayBar(value.charge, 0, 100, 'average')}}
{{else}}
{{:helper.displayBar(value.charge, 0, 100, 'bad')}}
{{/if}}
<div class="statusValue">
{{:value.charge}}%<br>
</div>
{{empty}}
No connected SMES units detected!<br>
{{/for}}
{{/if}}
{{if data.hide_breakers}}
<b>Breaker readings hidden.</b><br>
{{else}}
<b>Detected Breaker Boxes with RCON support:</b><br>
{{for data.breaker_info}}
<div class = "item">
<div class="itemLabel">
{{:value.RCON_tag}}
</div>
<div class="itemContent">
<table>
<tr><td>
Input: {{:value.input_val}}W - {{:value.input_set ? "AUTO" : "OFF"}}
{{:value.enabled ? "[<span class='good'>ENABLED</span>]" : "[<span class='bad'>DISABLED</span>]"}}
<td>
{{:helper.link('', 'power', { 'smes_in_toggle' : value.RCON_tag})}}
{{:helper.link('', 'pencil', { 'smes_in_set' : value.RCON_tag})}}
<tr><td>
Output: {{:value.output_val}}W - {{:value.output_set ? "ONLINE" : "OFFLINE"}}
<td>
{{:helper.link('', 'power', { 'smes_out_toggle' : value.RCON_tag})}}
{{:helper.link('', 'pencil', { 'smes_out_set' : value.RCON_tag})}}
<tr><td>
Output Load:
<td>
{{:value.output_load}}W
</table>
{{:helper.link('', 'power', {'toggle_breaker' : value.RCON_tag})}}
</table>
</div>
</div>
</div>
{{empty}}
No connected SMES units detected!
{{/for}}
<b>Detected Breaker Boxes with RCON support:</b>
{{for data.breaker_info}}
<div class = "item">
<div class="itemLabel">
{{:value.RCON_tag}}
</div>
<div class="itemContent">
<table>
<tr><td>
{{:value.enabled ? "[<span class='good'>ENABLED</span>]" : "[<span class='bad'>DISABLED</span>]"}}
<td>
{{:helper.link('', 'power', {'toggle_breaker' : value.RCON_tag})}}
</table>
</div>
</div>
{{empty}}
No connected Breaker Boxes detected!
{{/for}}
{{empty}}
No connected Breaker Boxes detected!
{{/for}}
{{/if}}