diff --git a/code/game/mecha/mech_bay.dm b/code/game/mecha/mech_bay.dm index 20703363ff8..d3c249b7473 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,28 @@ 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.
" + 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 + 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"] = isnull(recharge_floor.recharging_mecha) ? 0 : round(recharge_floor.recharging_mecha.cell.percent()) 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
-
"} - */ - - output += "" - user << browse(output, "window=mech_bay_console") - onclose(user, "mech_bay_console") - return - -// 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 -*/ + 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 + // 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", 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 + ui.open() + // auto update every Master Controller tick + ui.set_auto_update(1) \ No newline at end of file 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