mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 20:16:55 +01:00
Updates access controller to TGUI
This commit is contained in:
@@ -83,45 +83,51 @@
|
||||
else
|
||||
icon_state = "access_control_off"
|
||||
|
||||
/obj/machinery/embedded_controller/radio/airlock/access_controller/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/embedded_controller/radio/airlock/access_controller/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, "door_access_console.tmpl", name, 330, 220)
|
||||
ui = new(user, src, ui_key, "AirlockAccessController", name, 470, 290, master_ui, state)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/embedded_controller/radio/airlock/access_controller/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
|
||||
var/data[0]
|
||||
/obj/machinery/embedded_controller/radio/airlock/access_controller/tgui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
data = list(
|
||||
"exterior_status" = program.memory["exterior_status"],
|
||||
"interior_status" = program.memory["interior_status"],
|
||||
"processing" = program.memory["processing"]
|
||||
)
|
||||
data["exterior_status"] = program.memory["exterior_status"]
|
||||
data["interior_status"] = program.memory["interior_status"]
|
||||
data["processing"] = program.memory["processing"]
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/embedded_controller/radio/airlock/access_controller/Topic(href, href_list)
|
||||
/obj/machinery/embedded_controller/radio/airlock/access_controller/tgui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
|
||||
usr.set_machine(src)
|
||||
src.add_fingerprint(usr)
|
||||
add_fingerprint(usr)
|
||||
|
||||
var/clean = 0
|
||||
switch(href_list["command"]) //anti-HTML-hacking checks
|
||||
var/clean = FALSE
|
||||
|
||||
// Repeat the frontend check to make sure only allowed command are sent. You are only allowed to lock or cycle exterior if exterior is open
|
||||
// Vice versa for internal
|
||||
|
||||
switch(action)
|
||||
if("cycle_ext_door")
|
||||
clean = 1
|
||||
clean = TRUE
|
||||
if("cycle_int_door")
|
||||
clean = 1
|
||||
if("force_ext")
|
||||
if(program.memory["interior_status"]["state"] == "closed")
|
||||
clean = 1
|
||||
if("force_int")
|
||||
if(program.memory["exterior_status"]["state"] == "closed")
|
||||
clean = 1
|
||||
clean = TRUE
|
||||
if("force_ext") // Cannot force exterior if interior open
|
||||
if(program.memory["interior_status"]["state"] == "closed" && program.memory["exterior_status"]["state"] == "open")
|
||||
clean = TRUE
|
||||
if("force_int") // Cannot force interior if exterior open
|
||||
if(program.memory["exterior_status"]["state"] == "closed" && program.memory["interior_status"]["state"] == "open")
|
||||
clean = TRUE
|
||||
|
||||
message_admins(action)
|
||||
message_admins(clean)
|
||||
message_admins("Interior" + program.memory["interior_status"]["state"])
|
||||
message_admins("Exterior" + program.memory["exterior_status"]["state"])
|
||||
|
||||
if(clean)
|
||||
program.receive_user_command(href_list["command"])
|
||||
program.receive_user_command(action)
|
||||
|
||||
return TRUE
|
||||
|
||||
return 1
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<div class="item" style="padding-top: 10px">
|
||||
<div class="item">
|
||||
<div class="itemLabel" style="width: 150px">
|
||||
Exterior Door Status:
|
||||
</div>
|
||||
<div class="statusValue">
|
||||
{{if data.exterior_status.state == "closed"}}
|
||||
Locked
|
||||
{{else}}
|
||||
Open
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="itemLabel" style="width: 150px">
|
||||
Interior Door Status:
|
||||
</div>
|
||||
<div class="statusValue">
|
||||
{{if data.interior_status.state == "closed"}}
|
||||
Locked
|
||||
{{else}}
|
||||
Open
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item" style="padding-top: 10px">
|
||||
<div class="item">
|
||||
<div class="itemContent" style="width: 100%">
|
||||
{{if data.exterior_status.state == "open"}}
|
||||
{{:helper.link('Lock Exterior Door', 'exclamation-triangle', {'command' : 'force_ext'}, data.processing ? 'disabled' : null)}}
|
||||
{{else}}
|
||||
{{:helper.link('Cycle to Exterior', 'arrow-circle-o-left', {'command' : 'cycle_ext_door'}, data.processing ? 'disabled' : null)}}
|
||||
{{/if}}
|
||||
{{if data.interior_status.state == "open"}}
|
||||
{{:helper.link('Lock Interior Door', 'exclamation-triangle', {'command' : 'force_int'}, data.processing ? 'disabled' : null)}}
|
||||
{{else}}
|
||||
{{:helper.link('Cycle to Interior', 'arrow-circle-right', {'command' : 'cycle_int_door'}, data.processing ? 'disabled' : null)}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,75 @@
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, LabeledList, Section } from '../components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
export const AirlockAccessController = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const {
|
||||
exterior_status,
|
||||
interior_status,
|
||||
processing,
|
||||
} = data;
|
||||
let exteriorbutton;
|
||||
let interiorbutton;
|
||||
// If exterior is open, then it can be locked, if closed, it can be cycled to. Vice versa for interior
|
||||
|
||||
if (data.exterior_status.state === "open") {
|
||||
exteriorbutton = (
|
||||
<Button
|
||||
content={"Lock Exterior Door"}
|
||||
icon={"exclamation-triangle"}
|
||||
disabled={processing}
|
||||
onClick={() => act("force_ext")} />
|
||||
);
|
||||
} else {
|
||||
exteriorbutton = (
|
||||
<Button
|
||||
content={"Cycle to Exterior"}
|
||||
icon={"arrow-circle-left"}
|
||||
disabled={processing}
|
||||
onClick={() => act("cycle_ext_door")} />
|
||||
);
|
||||
}
|
||||
if (data.interior_status.state === "open") {
|
||||
interiorbutton = (
|
||||
<Button
|
||||
content={"Lock Interior Door"}
|
||||
icon={"exclamation-triangle"}
|
||||
disabled={processing}
|
||||
color={interior_status === "open" ? "red" : processing ? "yellow": null}
|
||||
onClick={() => act("force_int")} />
|
||||
);
|
||||
} else {
|
||||
interiorbutton = (
|
||||
<Button
|
||||
content={"Cycle to Interior"}
|
||||
icon={"arrow-circle-right"}
|
||||
disabled={processing}
|
||||
onClick={() => act("cycle_int_door")} />
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Window>
|
||||
<Window.Content>
|
||||
<Section title="Information">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="External Door Status">
|
||||
{exterior_status.state === "closed" ? "Locked" : "Open"}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Internal Door Status">
|
||||
{interior_status.state === "closed" ? "Locked" : "Open"}
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
<Section title="Actions">
|
||||
<Box>
|
||||
{exteriorbutton}
|
||||
</Box>
|
||||
<Box>
|
||||
{interiorbutton}
|
||||
</Box>
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user