Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 50 additions & 57 deletions code/game/machinery/atmoalter/area_atmos_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,66 +27,59 @@
if(..(user))
return
src.add_fingerprint(usr)
var/header = {"<style type="text/css">
a.green:link
{
color:#00CC00;
}
a.green:visited
{
color:#00CC00;
}
a.green:hover
{
color:#00CC00;
}
a.green:active
{
color:#00CC00;
}
a.red:link
{
color:#FF0000;
}
a.red:visited
{
color:#FF0000;
}
a.red:hover
{
color:#FF0000;
}
a.red:active
{
color:#FF0000;
}
</style"}
var/dat = {"
<center><h1>Area Air Control</h1></center>
<font color="red">[status]</font><br>
<a href="byond://?src=\ref[src];scan=1">Scan</a>
<table border="1" width="90%">"}
ui_interact(user)

/obj/machinery/computer/area_atmos/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AreaAtmos", "Area Air Control")
ui.open()

/obj/machinery/computer/area_atmos/ui_state(mob/user)
return GLOB.default_state

/obj/machinery/computer/area_atmos/ui_data(mob/user)
var/list/data = list()

data["status"] = status
data["zone"] = zone

var/list/scrubber_data = list()
for(var/obj/machinery/portable_atmospherics/powered/scrubber/huge/scrubber in connectedscrubbers)
dat += {"
<tr>
<td>
[scrubber.name]<br>
Pressure: [round(scrubber.air_contents.return_pressure(), 0.01)] kPa<br>
Flow Rate: [round(scrubber.last_flow_rate,0.1)] L/s<br>
</td>
<td width="150">
<a class="green" href="byond://?src=\ref[src];scrub=\ref[scrubber];toggle=1">Turn On</a>
<a class="red" href="byond://?src=\ref[src];scrub=\ref[scrubber];toggle=0">Turn Off</a><br>
Load: [round(scrubber.last_power_draw)] W
</td>
</tr>"}

dat += {"
</table><br>
<i>[zone]</i>"}
user << browse(HTML_SKELETON_INTERNAL(header, dat), "window=miningshuttle;size=400x400")
scrubber_data += list(list(
"name" = scrubber.name,
"pressure" = round(scrubber.air_contents.return_pressure(), 0.01),
"flow_rate" = round(scrubber.last_flow_rate, 0.1),
"power_draw" = round(scrubber.last_power_draw),
"ref" = "\ref[scrubber]"
))

data["scrubbers"] = scrubber_data

// Clear status after displaying
status = ""

return data

/obj/machinery/computer/area_atmos/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return TRUE

// Map TGUI actions to existing Topic parameters
var/list/href_list = list()

switch(action)
if("scan")
href_list["scan"] = "1"
if("toggle_scrubber")
href_list["scrub"] = params["ref"]
href_list["toggle"] = params["state"]

// Call existing Topic method
Topic("", href_list)
return TRUE

/obj/machinery/computer/area_atmos/Topic(href, href_list)
if(..())
return
Expand Down
65 changes: 44 additions & 21 deletions code/game/machinery/computer/aifixer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,58 @@
..()
return

// AI Fixer Computer TGUI Backend - Keep existing Topic logic, add TGUI frontend
/obj/machinery/computer/aifixer/attack_hand(mob/user as mob)
if(..())
return
ui_interact(user)

user.set_machine(src)
var/dat = "<h3>AI System Integrity Restorer</h3><br><br>"
/obj/machinery/computer/aifixer/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AIFixer", "AI System Integrity Restorer")
ui.open()

if (src.occupant)
var/laws
dat += "Stored AI: [src.occupant.name]<br>System integrity: [src.occupant.hardware_integrity()]%<br>Backup Capacitor: [src.occupant.backup_capacitor()]%<br>"
/obj/machinery/computer/aifixer/ui_state(mob/user)
return GLOB.default_state

for (var/datum/ai_law/law in occupant.laws.all_laws())
laws += "[law.get_index()]: [law.law]<BR>"
/obj/machinery/computer/aifixer/ui_data(mob/user)
var/list/data = list()

dat += "Laws:<br>[laws]<br>"
data["hasOccupant"] = !!occupant
data["active"] = active

if (src.occupant.stat == 2)
dat += "<b>AI nonfunctional</b>"
else
dat += "<b>AI functional</b>"
if (!src.active)
dat += {"<br><br><A href='byond://?src=\ref[src];fix=1'>Begin Reconstruction</A>"}
else
dat += "<br><br>Reconstruction in process, please wait.<br>"
dat += {" <A href='byond://?src=\ref[user];mach_close=computer'>Close</A>"}

user << browse(HTML_SKELETON_TITLE("AI System Integrity Restorer", dat), "window=computer;size=400x500")
onclose(user, "computer")
return
if(occupant)
data["aiName"] = occupant.name
data["hardwareIntegrity"] = occupant.hardware_integrity()
data["backupCapacitor"] = occupant.backup_capacitor()
data["aiDead"] = occupant.stat == 2

var/list/laws_list = list()
for(var/datum/ai_law/law in occupant.laws.all_laws())
laws_list += list(list(
"index" = law.get_index(),
"law" = law.law
))
data["laws"] = laws_list

return data

/obj/machinery/computer/aifixer/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return TRUE

// Map TGUI actions to existing Topic parameters
var/list/href_list = list()

switch(action)
if("fix")
href_list["fix"] = "1"

// Call existing Topic method
Topic("", href_list)
return TRUE

/obj/machinery/computer/aifixer/Process()
if(..())
Expand Down
Loading
Loading