diff --git a/code/modules/power/generator.dm b/code/modules/power/generator.dm index f6f7f135e2..391d4c0c61 100644 --- a/code/modules/power/generator.dm +++ b/code/modules/power/generator.dm @@ -134,8 +134,7 @@ add_avail(effective_gen) /obj/machinery/power/generator/attack_ai(mob/user) - if(stat & (BROKEN|NOPOWER)) return - interact(user) + attack_hand(user) /obj/machinery/power/generator/attackby(obj/item/weapon/W as obj, mob/user as mob) if(istype(W, /obj/item/weapon/wrench)) @@ -152,70 +151,60 @@ /obj/machinery/power/generator/attack_hand(mob/user) add_fingerprint(user) if(stat & (BROKEN|NOPOWER) || !anchored) return - interact(user) - - -/obj/machinery/power/generator/interact(mob/user) - if ( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai))) - user.unset_machine() - user << browse(null, "window=teg") - return - - user.set_machine(src) - - var/t = "
Thermoelectric Generator
" - t += "Total Output: [round(effective_gen/1000)] kW
" - t += "Thermal Output: [round(last_thermal_gen/1000)] kW
" - t += "
" + if(!circ1 || !circ2) //Just incase the middle part of the TEG was not wrenched last. + reconnect() + ui_interact(user) +/obj/machinery/power/generator/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + // this is the data which will be sent to the ui var/vertical = 0 if (dir == NORTH || dir == SOUTH) vertical = 1 + var/data[0] + data["totalOutput"] = effective_gen/1000 + data["maxTotalOutput"] = max_power/1000 + data["thermalOutput"] = last_thermal_gen/1000 + data["circConnected"] = 0 + + if(circ1) + //The one on the left (or top) + data["primaryDir"] = vertical ? "top" : "left" + data["primaryOutput"] = last_circ1_gen/1000 + data["primaryFlowCapacity"] = circ1.volume_capacity_used*100 + data["primaryInletPressure"] = circ1.air1.return_pressure() + data["primaryInletTemperature"] = circ1.air1.temperature + data["primaryOutletPressure"] = circ1.air2.return_pressure() + data["primaryOutletTemperature"] = circ1.air2.temperature + + if(circ2) + //Now for the one on the right (or bottom) + data["secondaryDir"] = vertical ? "bottom" : "right" + data["secondaryOutput"] = last_circ2_gen/1000 + data["secondaryFlowCapacity"] = circ2.volume_capacity_used*100 + data["secondaryInletPressure"] = circ2.air1.return_pressure() + data["secondaryInletTemperature"] = circ2.air1.temperature + data["secondaryOutletPressure"] = circ2.air2.return_pressure() + data["secondaryOutletTemperature"] = circ2.air2.temperature + if(circ1 && circ2) - t += "Primary Circulator ([vertical ? "top" : "left"])
" - t += "Turbine Output: [round(last_circ1_gen/1000)] kW
" - t += "Flow Capacity: [round(circ1.volume_capacity_used*100)]%
" - t += "
" - t += "Inlet Pressure: [round(circ1.air1.return_pressure(), 0.1)] kPa
" - t += "Inlet Temperature: [round(circ1.air1.temperature, 0.1)] K
" - t += "
" - t += "Outlet Pressure: [round(circ1.air2.return_pressure(), 0.1)] kPa
" - t += "Outlet Temperature: [round(circ1.air2.temperature, 0.1)] K
" - t += "
" - t += "Secondary Circulator ([vertical ? "bottom" : "right"])
" - t += "Turbine Output: [round(last_circ2_gen/1000)] kW
" - t += "Flow Capacity: [round(circ2.volume_capacity_used*100)]%
" - t += "
" - t += "Inlet Pressure: [round(circ2.air1.return_pressure(), 0.1)] kPa
" - t += "Inlet Temperature: [round(circ2.air1.temperature, 0.1)] K
" - t += "
" - t += "Outlet Pressure: [round(circ2.air2.return_pressure(), 0.1)] kPa
" - t += "Outlet Temperature: [round(circ2.air2.temperature, 0.1)] K
" - + data["circConnected"] = 1 else - t += "Unable to connect to circulators.
" - t += "Ensure both are in position and wrenched into place." - - t += "
" - t += "
" - t += "Refresh Close" - - user << browse(t, "window=teg;size=400x500") - onclose(user, "teg") - return 1 + data["circConnected"] = 0 -/obj/machinery/power/generator/Topic(href, href_list) - ..() - if( href_list["close"] ) - usr << browse(null, "window=teg") - usr.unset_machine() - return 0 - - updateDialog() - return 1 - + // 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, "generator.tmpl", "Thermoelectric Generator", 450, 500) + // 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) /obj/machinery/power/generator/power_change() ..() diff --git a/icons/obj/pipes.dmi b/icons/obj/pipes.dmi index eb005aaf31..ec6d28a613 100644 Binary files a/icons/obj/pipes.dmi and b/icons/obj/pipes.dmi differ diff --git a/icons/obj/power.dmi b/icons/obj/power.dmi index 5da859b982..099070a4fc 100644 Binary files a/icons/obj/power.dmi and b/icons/obj/power.dmi differ diff --git a/nano/templates/generator.tmpl b/nano/templates/generator.tmpl new file mode 100644 index 0000000000..150884187f --- /dev/null +++ b/nano/templates/generator.tmpl @@ -0,0 +1,142 @@ ++++ Total Output: +++ {{:helper.displayBar(data.totalOutput, 0, data.maxTotalOutput)}} +++ {{:helper.fixed(data.totalOutput, 1)}} kW +++++ Thermal Output: +++ {{:helper.fixed(data.thermalOutput, 1)}} kW ++
+ +{{if data.circConnected}} +
|
+
+
+ Primary Circulator ({{:data.primaryDir}})
+
+
+ Turbine Output:
+
+
+ {{:helper.fixed(data.primaryOutput, 1)}} kW
+
+
+
+
+ Flow Capacity:
+
+
+ {{:helper.fixed(data.primaryFlowCapacity, 1)}} %
+
+ +
+
+
+ Inlet Pressure:
+
+
+ {{:helper.fixed(data.primaryInletPressure, 1)}} kPa
+
+
+
+
+ Inlet Temperature:
+
+
+ {{:helper.fixed(data.primaryInletTemperature, 1)}} K
+
+ +
+
+
+ Outlet Pressure:
+
+
+ {{:helper.fixed(data.primaryOutletPressure, 1)}} kPa
+
+
+
+
+ Outlet Temperature:
+
+
+ {{:helper.fixed(data.primaryOutletTemperature, 1)}} K
+
+ |
+
+
+
+
+ Secondary Circulator ({{:data.secondaryDir}})
+
+
+ Turbine Output:
+
+
+ {{:helper.fixed(data.secondaryOutput, 1)}} kW
+
+
+
+
+ Flow Capacity:
+
+
+ {{:helper.fixed(data.secondaryFlowCapacity, 1)}} %
+
+ +
+
+
+ Inlet Pressure:
+
+
+ {{:helper.fixed(data.secondaryInletPressure, 1)}} kPa
+
+
+
+
+ Inlet Temperature:
+
+
+ {{:helper.fixed(data.secondaryInletTemperature, 1)}} K
+
+ +
+
+
+ Outlet Pressure:
+
+
+ {{:helper.fixed(data.secondaryOutletPressure, 1)}} kPa
+
+
+
+
+ Outlet Temperature:
+
+
+ {{:helper.fixed(data.secondaryOutletTemperature, 1)}} K
+
+ |
+