From 43e816895d30ce800688ee3b20e6f0f96aeb2ec4 Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Wed, 10 Dec 2014 12:32:27 +0100 Subject: [PATCH 1/5] v1.0 of NanoUI for mech bay consoles. --- code/game/mecha/mech_bay.dm | 63 +++++++++++++------------------------ 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index 20703363ff8..578eea01994 100644 --- a/code/game/mecha/mech_bay.dm +++ b/code/game/mecha/mech_bay.dm @@ -46,8 +46,8 @@ return // temporary fix for broken icon until somebody gets around to make these player-buildable -/turf/simulated/floor/mech_bay_recharge_floor/attackby(obj/item/C as obj, mob/user as mob) - ..() +/turf/simulated/floor/mech_bay_recharge_floor/attackby(obj/item/C as obj, mob/user as mob) + ..() if(floor_type) icon_state = "recharge_floor" else @@ -190,45 +190,26 @@ var/turf/simulated/floor/mech_bay_recharge_floor/F = locate() in range(1,src) if(F) F.init_devices() - - var/output = "[src.name]" - if(!recharge_floor) - output += "Mech Bay Recharge Station not initialized.
" - else - output += {"Mech Bay Recharge Station Data:
- Mecha: [recharge_floor.recharging_mecha||"None"]
"} - if(recharge_floor.recharging_mecha) - var/cell_charge = recharge_floor.recharging_mecha.get_charge() - output += "Cell charge: [isnull(cell_charge)?"No powercell found":"[recharge_floor.recharging_mecha.cell.charge]/[recharge_floor.recharging_mecha.cell.maxcharge]"]
" - output += "
" - if(!recharge_port) - output += "Mech Bay Power Port not initialized.
" - else - output += "Mech Bay Power Port Status: [recharge_port.active()?"Now charging":"On hold"]
" - /* - output += {"
- Settings: -
- Start sequence on succesful init: [autostart?"On":"Off"]
- Recharge Port Voltage: Low - Medium - High
-
"} - */ + var/list/data = list() - output += "" - user << browse(output, "window=mech_bay_console") - onclose(user, "mech_bay_console") - return + data["has_floor"] = recharge_floor + data["has_port"] = recharge_port + data["has_mech"] = !isnull(recharge_floor.recharging_mecha) + if(recharge_floor) + data["mecha_name"] = recharge_floor.recharging_mecha || "None" + data["mecha_charge"] = isnull(cell_charge) ? 0 : recharge_floor.recharging_mecha.cell.charge + data["mecha_maxcharge"] = isnull(cell_charge) ? 0 : recharge_floor.recharging_mecha.cell.maxcharge + data["mecha_charge_percentage"] = round(recharge_floor.recharging_mecha.cell.percent()) -// unused at the moment, also lacks any kind of exploit prevention -/* -/obj/machinery/computer/mech_bay_power_console/Topic(href, href_list) - if(href_list["autostart"]) - autostart = !autostart - if(href_list["voltage"]) - voltage = text2num(href_list["voltage"]) - if(recharge_port) - recharge_port.set_voltage(voltage) - updateUsrDialog() - return -*/ + 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, "mech_bay_console.tmpl", "Mech Bay Control Console", 300, 200) + // 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) \ No newline at end of file From 73b04ff177085b87737d04fc29d4adfce215b849 Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Wed, 10 Dec 2014 12:34:23 +0100 Subject: [PATCH 2/5] Compile error fix --- code/game/mecha/mech_bay.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index 578eea01994..c2103cb26be 100644 --- a/code/game/mecha/mech_bay.dm +++ b/code/game/mecha/mech_bay.dm @@ -191,7 +191,7 @@ if(F) F.init_devices() - var/list/data = list() + var/list/data = list() data["has_floor"] = recharge_floor data["has_port"] = recharge_port From 1a6d1eac2fc691f6100be4abddc909dd8d7466e0 Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Wed, 10 Dec 2014 12:42:57 +0100 Subject: [PATCH 3/5] Compile error fix --- code/game/mecha/mech_bay.dm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index c2103cb26be..22c099b6b0f 100644 --- a/code/game/mecha/mech_bay.dm +++ b/code/game/mecha/mech_bay.dm @@ -190,16 +190,17 @@ var/turf/simulated/floor/mech_bay_recharge_floor/F = locate() in range(1,src) if(F) F.init_devices() + ui_interact(user) +/obj/machinery/computer/mech_bay_power_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) var/list/data = list() - data["has_floor"] = recharge_floor data["has_port"] = recharge_port data["has_mech"] = !isnull(recharge_floor.recharging_mecha) - if(recharge_floor) + if(recharge_floor && recharge_floor.recharging_mecha) data["mecha_name"] = recharge_floor.recharging_mecha || "None" - data["mecha_charge"] = isnull(cell_charge) ? 0 : recharge_floor.recharging_mecha.cell.charge - data["mecha_maxcharge"] = isnull(cell_charge) ? 0 : recharge_floor.recharging_mecha.cell.maxcharge + data["mecha_charge"] = isnull(recharge_floor.recharging_mecha) ? 0 : recharge_floor.recharging_mecha.cell.charge + data["mecha_maxcharge"] = isnull(recharge_floor.recharging_mecha) ? 0 : recharge_floor.recharging_mecha.cell.maxcharge data["mecha_charge_percentage"] = round(recharge_floor.recharging_mecha.cell.percent()) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) From 0bacf5492e8b36c33f7675c46b7eefb8e5c2eea9 Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Wed, 10 Dec 2014 15:19:53 +0100 Subject: [PATCH 4/5] Final version of Mech Bay Charging Console NanoUI implementation --- code/game/mecha/mech_bay.dm | 9 ++-- nano/templates/mech_bay_console.tmpl | 67 ++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 nano/templates/mech_bay_console.tmpl diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index 22c099b6b0f..65f77c1d999 100644 --- a/code/game/mecha/mech_bay.dm +++ b/code/game/mecha/mech_bay.dm @@ -196,13 +196,14 @@ var/list/data = list() data["has_floor"] = recharge_floor data["has_port"] = recharge_port - data["has_mech"] = !isnull(recharge_floor.recharging_mecha) - if(recharge_floor && recharge_floor.recharging_mecha) + if(recharge_floor && recharge_floor.recharging_mecha && recharge_floor.recharging_mecha.cell) + data["has_mech"] = 1 data["mecha_name"] = recharge_floor.recharging_mecha || "None" data["mecha_charge"] = isnull(recharge_floor.recharging_mecha) ? 0 : recharge_floor.recharging_mecha.cell.charge data["mecha_maxcharge"] = isnull(recharge_floor.recharging_mecha) ? 0 : recharge_floor.recharging_mecha.cell.maxcharge - data["mecha_charge_percentage"] = round(recharge_floor.recharging_mecha.cell.percent()) - + data["mecha_charge_percentage"] = isnull(recharge_floor.recharging_mecha) ? 0 : round(recharge_floor.recharging_mecha.cell.percent()) + else + data["has_mech"] = 0 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 diff --git a/nano/templates/mech_bay_console.tmpl b/nano/templates/mech_bay_console.tmpl new file mode 100644 index 00000000000..87e34d7b8e1 --- /dev/null +++ b/nano/templates/mech_bay_console.tmpl @@ -0,0 +1,67 @@ +

Subsystems

+
+
+ Recharge Station: +
+
+ {{if data.has_floor}} + OK + {{else}} + ERROR + {{/if}} +
+
+
+
+ Power Port: +
+
+ {{if data.has_port}} + OK + {{else}} + ERROR + {{/if}} +
+
+
+
+ Mecha: +
+
+ {{if data.has_mech}} + LOCATED ({{:data.mecha_name}}) + {{else}} + NONE + {{/if}} +
+
+{{if data.has_mech}} +

Charging

+
+
+ Charge Level: +
+
+ {{:helper.displayBar(data.mecha_charge_percentage, 0, 100)}} +
+ {{:data.mecha_charge_percentage}}%
+
+
+
+
+
+ Cell Rating: +
+
+ {{:data.mecha_maxcharge}} +
+
+
+
+ Cell Charge: +
+
+ {{:data.mecha_charge}} +
+
+{{/if}} \ No newline at end of file From 836c5038db6904ba87833de2180a8c5d32d96f2b Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Thu, 11 Dec 2014 09:49:55 +0100 Subject: [PATCH 5/5] Adjusts size of previous UI --- code/game/mecha/mech_bay.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index 65f77c1d999..d3c249b7473 100644 --- a/code/game/mecha/mech_bay.dm +++ b/code/game/mecha/mech_bay.dm @@ -208,7 +208,7 @@ 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, "mech_bay_console.tmpl", "Mech Bay Control Console", 300, 200) + ui = new(user, src, ui_key, "mech_bay_console.tmpl", "Mech Bay Control Console", 500, 325) // when the ui is first opened this is the data it will use ui.set_initial_data(data) // open the new ui window