diff --git a/code/game/machinery/computer/aifixer.dm b/code/game/machinery/computer/aifixer.dm index 0d715fe5759..b69c08c1b45 100644 --- a/code/game/machinery/computer/aifixer.dm +++ b/code/game/machinery/computer/aifixer.dm @@ -22,20 +22,19 @@ return ..() /obj/machinery/computer/aifixer/attack_ai(var/mob/user as mob) - ui_interact(user) + tgui_interact(user) /obj/machinery/computer/aifixer/attack_hand(var/mob/user as mob) - ui_interact(user) + tgui_interact(user) -/obj/machinery/computer/aifixer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) - ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open) +/obj/machinery/computer/aifixer/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state) + ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) if(!ui) - ui = new(user, src, ui_key, "ai_fixer.tmpl", "AI System Integrity Restorer", 550, 500) + ui = new(user, src, ui_key, "ai_fixer", name, 550, 500, master_ui, state) ui.open() - ui.set_auto_update(1) -/obj/machinery/computer/aifixer/ui_data(mob/user, datum/topic_state/state) +/obj/machinery/computer/aifixer/tgui_data(mob/user, datum/topic_state/state) var/data[0] if(occupant) data["occupant"] = occupant.name @@ -48,43 +47,43 @@ var/laws[0] for(var/datum/ai_law/law in occupant.laws.all_laws()) - laws.Add(list(list("law" = law.law, "number" = law.get_index()))) + laws.Add(list("law" = law.law, "number" = law.get_index()))) data["laws"] = laws return data -/obj/machinery/computer/aifixer/Topic(href, href_list) +/obj/machinery/computer/aifixer/tgui_act(action, params) if(..()) - return 1 + return + switch(action) + if("fix") + active = 1 + while(occupant.health < 100) + occupant.adjustOxyLoss(-1, FALSE) + occupant.adjustFireLoss(-1, FALSE) + occupant.adjustToxLoss(-1, FALSE) + occupant.adjustBruteLoss(-1, FALSE) + occupant.updatehealth() + if(occupant.health >= 0 && occupant.stat == DEAD) + occupant.update_revive() + occupant.lying = 0 + update_icon() + sleep(10) + active = 0 + add_fingerprint(usr) - if(href_list["fix"]) - active = 1 - while(occupant.health < 100) - occupant.adjustOxyLoss(-1, FALSE) - occupant.adjustFireLoss(-1, FALSE) - occupant.adjustToxLoss(-1, FALSE) - occupant.adjustBruteLoss(-1, FALSE) - occupant.updatehealth() - if(occupant.health >= 0 && occupant.stat == DEAD) - occupant.update_revive() - occupant.lying = 0 - update_icon() - sleep(10) - active = 0 - add_fingerprint(usr) + if("wireless") + var/wireless = text2num("wireless") + if(wireless == 0 || wireless == 1) + occupant.control_disabled = wireless - if(href_list["wireless"]) - var/wireless = text2num(href_list["wireless"]) - if(wireless == 0 || wireless == 1) - occupant.control_disabled = wireless + if("radio") + var/radio = text2num("radio") + if(radio == 0 || radio == 1) + occupant.aiRadio.disabledAi = radio - if(href_list["radio"]) - var/radio = text2num(href_list["radio"]) - if(radio == 0 || radio == 1) - occupant.aiRadio.disabledAi = radio - - SSnanoui.update_uis(src) + SStgui.update_uis(src) update_icon() return diff --git a/nano/templates/ai_fixer.tmpl b/nano/templates/ai_fixer.tmpl deleted file mode 100644 index 4be6fee598d..00000000000 --- a/nano/templates/ai_fixer.tmpl +++ /dev/null @@ -1,58 +0,0 @@ - -{{if data.occupant}} -
-

Stored AI: {{:data.occupant}}

-

Information

-
- Integrity -
-
- {{:data.integrity}}% -
-
- Status -
-
- {{if data.stat == 2}} - Non-functional - {{else}} - Functional - {{/if}} -
-
- Wireless Activity -
-
- {{:helper.link('Enabled','check',{'wireless' : 0},data.wireless == 0 ? 'selected' : '')}} - {{:helper.link('Disabled','close',{'wireless' : 1},data.wireless == 1 ? 'selected' : '')}} -
-
- Subspace Transceiver -
-
- {{:helper.link('Enabled','check',{'radio' : 0},data.radio == 0 ? 'selected' : '')}} - {{:helper.link('Disabled','close',{'radio' : 1},data.radio == 1 ? 'selected' : '')}} -
-

Laws

- {{for data.laws}} - {{:value.number}}: {{:value.law}}
- {{empty}} - No laws detected! - {{/for}} - -

Actions

- {{if data.active}} - Reconstruction in progress, please wait. - {{:helper.displayBar(data.integrity, 0, 100, (data.integrity >= 75) ? 'good' : (data.integrity >= 25) ? 'average' : 'bad')}} - {{:helper.smoothRound(data.integrity)}}% - {{/if}} -
- {{:helper.link('Reconstruct', 'wrench', {'fix' : 1}, data.active || data.integrity >= 100 ? 'disabled' : '')}} -
-
-{{else}} -

No artificial intelligence detected.

-{{/if}} \ No newline at end of file diff --git a/tgui/packages/tgui/interfaces/ai_fixer.js b/tgui/packages/tgui/interfaces/ai_fixer.js new file mode 100644 index 00000000000..6539d9c8718 --- /dev/null +++ b/tgui/packages/tgui/interfaces/ai_fixer.js @@ -0,0 +1,94 @@ +import { useBackend } from "../backend"; +import { Button, ProgressBar, Box, LabeledList } from "../components"; +import { Window } from "../layouts"; + +export const AIFixer = (props, context) => { + const { act, data } = useBackend(context); + const laws = data.laws || []; + if (data.occupant == null) { + return ( + + + +

No artificial intelligence detected.

+
+
+
+ ); + } else { + let workingAI = null; + if (data.stat == 2 || data.stat == null) { + workingAI = false; + } else { workingAI = true; } + + let integrityColor = null; + if (data.integrity >= 75) {integrityColor = 'green';} + else if (data.integrity >= 25) {integrityColor = 'yellow';} + else {integrityColor = 'red';} + + return ( + + + +

Stored AI: {data.occupant}

+
+ + +

Information

+
+ + + + + + {workingAI ? "Functional" : "Non-Functional"} + + + + +

Laws

+
+ {/* + for (let i = 0; i < lawsList.length; i++) { + + } + */} + + {/* {laws.map(law => ( + {law.number} {law.law} + ))} */} + + +

Actions

+
+ + +