NanoUI Conversions - DNA Analyzer & Engines Control (#22326)

changes:
  - refactor: "Migrates DNA Analyzer NanoUI to TGUI."
  - refactor: "Migrates Engines Control NanoUI to TGUI."
- qol: "DNA Analyzer reports now provide the date and time the scan was
produced."
- bugfix: "Ship computers no longer function after their power is cut."
  
Before/After images:
<img width="540" height="683" alt="dna_analyzer"
src="https://github.com/user-attachments/assets/b1199467-74e5-4b08-a0d6-3a052142baa0"
/>
<img width="776" height="696" alt="engines_control"
src="https://github.com/user-attachments/assets/cea796cf-34f5-43dd-897f-f5435ff7f120"
/>
This commit is contained in:
Batrachophreno
2026-04-27 14:49:22 -04:00
committed by GitHub
parent ffdb6edfdb
commit 34ebbcd67a
12 changed files with 543 additions and 199 deletions
@@ -10,7 +10,7 @@
var/display_state = "status"
/obj/machinery/computer/ship/engines/cockpit
density = 0
density = FALSE
icon = 'icons/obj/cockpit_console.dmi'
icon_state = "right"
icon_screen = "engine"
@@ -28,91 +28,116 @@
can_pass_under = FALSE
light_power_on = 1
/obj/machinery/computer/ship/engines/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
/obj/machinery/computer/ship/engines/ui_interact(mob/user, datum/tgui/ui)
if(!connected)
display_reconnect_dialog(user, "ship control systems")
return
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "EnginesControl", "[connected.get_real_name()] Engines Control")
ui.open()
/obj/machinery/computer/ship/engines/ui_data(mob/user)
var/list/data = list()
if(!connected)
return
var/data[0]
data["state"] = display_state
data["global_state"] = connected.engines_state
data["global_limit"] = round(connected.thrust_limit*100)
var/total_thrust = 0
data["global_state"] = !!connected.engines_state
data["global_limit"] = round(connected.thrust_limit * 100)
var/total_thrust = 0
var/list/enginfo = list()
var/list/enginfo[0]
for(var/datum/ship_engine/E in connected.engines)
var/list/rdata[0]
rdata["eng_type"] = E.name
rdata["eng_on"] = E.is_on()
rdata["eng_thrust"] = E.get_thrust()
rdata["eng_thrust_limiter"] = round(E.get_thrust_limit()*100)
rdata["eng_status"] = E.get_status()
rdata["eng_reference"] = "[REF(E)]"
var/list/edata = list()
edata["eng_type"] = E.name
edata["eng_on"] = !!E.is_on()
edata["eng_thrust"] = E.get_thrust() * 10
edata["eng_thrust_limiter"] = round(E.get_thrust_limit() * 100)
edata["eng_status"] = E.get_status()
edata["eng_reference"] = "[REF(E)]"
total_thrust += E.get_thrust()
enginfo.Add(list(rdata))
enginfo += list(edata)
data["engines_info"] = enginfo
data["total_thrust"] = total_thrust
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "engines_control.tmpl", "[connected.get_real_name()] Engines Control", 390, 530)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
return data
/obj/machinery/computer/ship/engines/Topic(href, href_list)
if(..())
return TOPIC_HANDLED
/obj/machinery/computer/ship/engines/ui_act(action, params)
. = ..()
if(.)
return
if(href_list["state"])
display_state = href_list["state"]
return TOPIC_REFRESH
if(!connected)
return FALSE
if(href_list["global_toggle"])
connected.engines_state = !connected.engines_state
for(var/datum/ship_engine/E in connected.engines)
if(connected.engines_state == !E.is_on())
E.toggle()
return TOPIC_REFRESH
if(use_check_and_message(usr))
return FALSE
if(href_list["set_global_limit"])
var/newlim = tgui_input_number(usr, "Input the new thrust limit.", "Thrust Limit", connected.thrust_limit*100, 100, 0)
if(!CanInteract(usr, GLOB.physical_state))
return TOPIC_NOACTION
connected.thrust_limit = clamp(newlim/100, 0, 1)
for(var/datum/ship_engine/E in connected.engines)
E.set_thrust_limit(connected.thrust_limit)
return TOPIC_REFRESH
switch(action)
if("set_state")
var/new_state = params["state"]
if(new_state in list("status", "engines"))
display_state = new_state
return TRUE
return FALSE
if(href_list["global_limit"])
connected.thrust_limit = clamp(connected.thrust_limit + text2num(href_list["global_limit"]), 0, 1)
for(var/datum/ship_engine/E in connected.engines)
E.set_thrust_limit(connected.thrust_limit)
return TOPIC_REFRESH
if("global_toggle")
connected.engines_state = !connected.engines_state
for(var/datum/ship_engine/E in connected.engines)
if(connected.engines_state == !E.is_on())
E.toggle()
return TRUE
if(href_list["engine"])
if(href_list["set_limit"])
var/datum/ship_engine/E = locate(href_list["engine"])
var/newlim = tgui_input_number(usr, "Input the new thrust limit.", "Thrust Limit", E.get_thrust_limit(), 100, 0)
if(!CanInteract(usr, GLOB.physical_state))
return
var/limit = clamp(newlim/100, 0, 1)
if(istype(E))
E.set_thrust_limit(limit)
return TOPIC_REFRESH
if(href_list["limit"])
var/datum/ship_engine/E = locate(href_list["engine"])
var/limit = clamp(E.get_thrust_limit() + text2num(href_list["limit"]), 0, 1)
if(istype(E))
E.set_thrust_limit(limit)
return TOPIC_REFRESH
if("set_global_limit")
var/newlim = tgui_input_number(usr, "Input the new thrust limit.", "Thrust Limit", connected.thrust_limit * 100, 100, 0)
if(isnull(newlim))
return FALSE
if(href_list["toggle"])
var/datum/ship_engine/E = locate(href_list["engine"])
if(istype(E))
E.toggle()
return TOPIC_REFRESH
return TOPIC_REFRESH
return TOPIC_NOACTION
connected.thrust_limit = clamp(newlim / 100, 0, 1)
for(var/datum/ship_engine/E in connected.engines)
E.set_thrust_limit(connected.thrust_limit)
return TRUE
if("global_limit_delta")
var/delta = text2num(params["delta"])
connected.thrust_limit = round(clamp(connected.thrust_limit + delta, 0, 1),0.1)
for(var/datum/ship_engine/E in connected.engines)
E.set_thrust_limit(connected.thrust_limit)
return TRUE
if("engine_set_limit")
var/datum/ship_engine/E = locate(params["engine"])
if(!istype(E))
return FALSE
var/newlim = tgui_input_number(usr, "Input the new thrust limit.", "Thrust Limit", E.get_thrust_limit() * 100, 100, 0)
if(isnull(newlim))
return FALSE
var/limit = clamp(newlim / 100, 0, 1)
E.set_thrust_limit(limit)
return TRUE
if("engine_limit_delta")
var/datum/ship_engine/E = locate(params["engine"])
if(!istype(E))
return FALSE
var/delta = text2num(params["delta"])
var/limit = clamp(E.get_thrust_limit() + delta, 0, 1)
E.set_thrust_limit(limit)
return TRUE
if("engine_toggle")
var/datum/ship_engine/E = locate(params["engine"])
if(!istype(E))
return FALSE
E.toggle()
return TRUE
return FALSE
+3 -1
View File
@@ -339,8 +339,10 @@
light_power_on = 1
/obj/machinery/computer/ship/navigation/attack_hand(mob/user)
if(stat & (NOPOWER|BROKEN))
return FALSE
if(use_check_and_message(user))
return
return FALSE
if(!emagged && !allowed(user))
to_chat(user, SPAN_WARNING("Access denied."))
return FALSE
+3 -1
View File
@@ -65,12 +65,14 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov
return ..()
/obj/machinery/computer/ship/attack_hand(mob/user)
if(stat & (NOPOWER|BROKEN))
return FALSE
// Snowflake case for checking player characters for a Pilot Spacecraft Skill.
// Only player characters will have the component. Which will both always be present on them, and will only enable its own return logic if it exists.
// NPCs, Ghostroles, and Offship Antags that don't generate skills are unaffected by this check by intentional design so that we don't have to account for them.
if (user.GetComponent(PILOT_SPACECRAFT_SKILL_COMPONENT)?.skill_level == SKILL_LEVEL_UNFAMILIAR)
to_chat(user, SPAN_WARNING("There's just so many buttons... You have no idea where to even begin."))
return
return FALSE
if(use_check_and_message(user))
return
+4 -4
View File
@@ -14,13 +14,13 @@ GLOBAL_LIST_INIT_TYPED(ship_engines, /datum/ship_engine, list())
/datum/ship_engine/proc/can_burn()
return 0
//Tries to fire the engine with power modifier (0..1). Returns thrust.
//Power modifier is intended to be used for maneuvers or the like,
//that should use less/more fuel/electricity than an actual burn.
/// Tries to fire the engine with power modifier (0..1). Returns thrust.
/// Power modifier is intended to be used for maneuvers or the like,
/// that should use less/more fuel/electricity than an actual burn.
/datum/ship_engine/proc/burn(var/power_modifier = 1)
return 0
//Returns status string for this engine
/// Returns status string for this engine
/datum/ship_engine/proc/get_status()
return "All systems nominal"
@@ -158,20 +158,33 @@
/obj/machinery/atmospherics/unary/engine/proc/get_status()
. = list()
.+= "Location: [get_area(src)]."
if(stat & NOPOWER)
.+= "<span class='average'>Insufficient power to operate.</span>"
if(!check_fuel())
.+= "<span class='average'>Insufficient fuel for a burn.</span>"
if(stat & BROKEN)
.+= "<span class='average'>Inoperable engine configuration.</span>"
if(blockage)
.+= "<span class='average'>Obstruction of airflow detected.</span>"
.+= "Propellant total mass: [round(air_contents.get_mass(),0.01)] kg."
.+= "Propellant used per burn: [round(air_contents.get_mass() * volume_per_burn * thrust_limit / air_contents.volume,0.01)] kg."
.+= "Propellant pressure: [round(XGM_PRESSURE(air_contents)/1000,0.1)] MPa."
. = jointext(.,"<br>")
. += list(list(
"text" = "Location: [get_area(src)].",
"severity" = "info"
))
if(stat & NOPOWER)
. += list(list("text" = "Insufficient power to operate.", "severity" = "bad"))
if(!check_fuel())
. += list(list("text" = "Insufficient fuel for a burn.", "severity" = "bad"))
if(stat & BROKEN)
. += list(list("text" = "Inoperable engine configuration.", "severity" = "bad"))
if(blockage)
. += list(list("text" = "Obstruction of airflow detected.", "severity" = "bad"))
. += list(list(
"text" = "Propellant total mass: [round(air_contents.get_mass(), 0.01)] kg.",
"severity" = null
))
. += list(list(
"text" = "Propellant used per burn: [round(air_contents.get_mass() * volume_per_burn * thrust_limit / air_contents.volume, 0.01)] kg.",
"severity" = null
))
. += list(list(
"text" = "Propellant pressure: [round(XGM_PRESSURE(air_contents)/1000, 0.1)] MPa.",
"severity" = null
))
/obj/machinery/atmospherics/unary/engine/power_change()
. = ..()
@@ -246,7 +259,7 @@
new/obj/effect/engine_exhaust(T, dir, is_cmb && air_contents.temperature >= PHORON_MINIMUM_BURN_TEMPERATURE)
/obj/machinery/atmospherics/unary/engine/proc/calculate_thrust(datum/gas_mixture/propellant, used_part = 1)
return round(sqrt(propellant.get_mass() * used_part * sqrt(XGM_PRESSURE(air_contents)/200)),0.1)
return round(sqrt(propellant.get_mass() * used_part * sqrt(XGM_PRESSURE(air_contents)/200)),0.01)
//Exhaust effect
/obj/effect/engine_exhaust
@@ -52,7 +52,7 @@
var/datum/ship_engine/ion/controller
var/thrust_limit = 1
var/on = 1
var/on = TRUE
var/burn_cost = 36000
var/generated_thrust = 2.5
@@ -66,11 +66,14 @@
/obj/machinery/ion_engine/proc/get_status()
. = list()
.+= "Location: [get_area(src)]."
if(!powered())
.+= "Insufficient power to operate."
. = jointext(.,"<br>")
. += list(list(
"text" = "Location: [get_area(src)].",
"severity" = "info"
))
if(!powered())
. += list(list("text" = "Insufficient power to operate.", "severity" = "bad"))
/obj/machinery/ion_engine/proc/burn(var/power_modifier = 1)
if(!on && !powered())
@@ -71,8 +71,11 @@
/obj/machinery/maneuvering_engine/proc/get_status()
. = list()
.+= "Location: [get_area(src)]."
. = jointext(.,"<br>")
. += list(list(
"text" = "Location: [get_area(src)].",
"severity" = "info"
))
/obj/machinery/maneuvering_engine/proc/burn(var/power_modifier = 1)
. = thrust_limit * generated_thrust * power_modifier