From 42561b25af6f52361fbe3d83cf1980e982ba5fa3 Mon Sep 17 00:00:00 2001 From: TDSSS <32099540+TDSSS@users.noreply.github.com> Date: Tue, 11 Aug 2020 15:16:18 +0200 Subject: [PATCH 01/13] backend first try --- code/modules/shuttle/shuttle.dm | 56 +++++++++++++++++++ .../tgui/interfaces/shuttle_console.js | 0 2 files changed, 56 insertions(+) create mode 100644 tgui/packages/tgui/interfaces/shuttle_console.js diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index cfd3ab8e6f2..8ddbf3c88ea 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -775,6 +775,61 @@ add_fingerprint(user) ui_interact(user) +//note to self, new stuff. Also TODO: remove dumb comments once you know how tgui works, ya dork +/obj/machinery/computer/shuttle/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, 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, "shuttle_console.js", name, 300, 300, master_ui, state) + ui.open() + +/obj/machinery/computer/shuttle/tgui_data(mob/user) + var/list/data = list() + var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId) //attempt one, use old data, let's see if this works + data["status"] = M ? M.getStatusText() : null + if(M) + data["shuttle"] = TRUE //this should just be boolean, right? + var/list/docking_ports = list() + data["docking_ports"] = docking_ports + var/list/options = params2list(possible_destinations) + for(var/obj/docking_port/stationary/S in SSshuttle.stationary) + if(!options.Find(S.id)) + continue + if(!M.check_dock(S)) + continue + docking_ports[++docking_ports.len] = list("name" = S.name, "id" = S.id) + data["docking_ports_len"] = docking_ports.len + data["admin_controlled"] = admin_controlled + data["docking_request"] = docking_request + return data + +//default vscode params, may need change +/obj/machinery/computer/shuttle/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state) + if(..()) //we can't actually interact, so no action + return TRUE + if(!allowed(usr)) + to_chat(usr, "Access denied.") + return //I am not sure if/why this returning instead of returning 1 matters here, original topic did it. Change? + var/list/options = params2list(possible_destinations) + if(action == "move") + var/destination = params["move"] + if(!options.Find(destination))//TODO figure out if this translation works + message_admins("EXPLOIT: [ADMIN_LOOKUPFLW(usr)] attempted to move [src] to an invalid location! [ADMIN_COORDJMP(src)]") + return + switch(SSshuttle.moveShuttle(shuttleId, destination, 1, usr)) + if(0) + atom_say("Shuttle departing! Please stand away from the doors.") + usr.create_log(MISC_LOG, "used [src] to call the [shuttleId] shuttle") + if(1) + to_chat(usr, "Invalid shuttle requested.") + else + to_chat(usr, "Unable to comply.") + return 1 + + + + + +//old crap, delete before push/when done lmao /obj/machinery/computer/shuttle/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId) ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open) @@ -849,6 +904,7 @@ admin_controlled = 1 resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF +//TODO remember the ferry has its own topic to update. Don't miss it /obj/machinery/computer/shuttle/ferry/request/Topic(href, href_list) if(..()) return 1 diff --git a/tgui/packages/tgui/interfaces/shuttle_console.js b/tgui/packages/tgui/interfaces/shuttle_console.js new file mode 100644 index 00000000000..e69de29bb2d From cfe665842eeb15ab05ccd0969556c789403e1a88 Mon Sep 17 00:00:00 2001 From: TDSSS <32099540+TDSSS@users.noreply.github.com> Date: Tue, 11 Aug 2020 20:32:19 +0200 Subject: [PATCH 02/13] WIP --- code/modules/mining/laborcamp/laborshuttle.dm | 2 +- code/modules/shuttle/ert.dm | 4 +- code/modules/shuttle/shuttle.dm | 6 +- code/modules/shuttle/syndicate.dm | 2 +- .../tgui/interfaces/ShuttleConsole.js | 72 +++++++++++++++++++ .../tgui/interfaces/shuttle_console.js | 0 tgui/packages/tgui/public/tgui.bundle.js | 4 +- 7 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 tgui/packages/tgui/interfaces/ShuttleConsole.js delete mode 100644 tgui/packages/tgui/interfaces/shuttle_console.js diff --git a/code/modules/mining/laborcamp/laborshuttle.dm b/code/modules/mining/laborcamp/laborshuttle.dm index 8e585eb15b0..26ffc7b352e 100644 --- a/code/modules/mining/laborcamp/laborshuttle.dm +++ b/code/modules/mining/laborcamp/laborshuttle.dm @@ -14,7 +14,7 @@ circuit = /obj/item/circuitboard/labor_shuttle/one_way req_access = list( ) -/obj/machinery/computer/shuttle/labor/one_way/Topic(href, href_list) +/obj/machinery/computer/shuttle/labor/one_way/Topic(href, href_list) //TODO make those work, too if(href_list["move"]) var/obj/docking_port/mobile/M = SSshuttle.getShuttle("laborcamp") if(!M) diff --git a/code/modules/shuttle/ert.dm b/code/modules/shuttle/ert.dm index 356ca9687dc..4340a9e2f96 100644 --- a/code/modules/shuttle/ert.dm +++ b/code/modules/shuttle/ert.dm @@ -6,13 +6,13 @@ resistance_flags = INDESTRUCTIBLE flags = NODECONSTRUCT -/obj/machinery/computer/shuttle/ert/Topic(href, href_list) +/obj/machinery/computer/shuttle/ert/Topic(href, href_list) //TODO convert this, too if(href_list["move"]) var/authorized_roles = list(SPECIAL_ROLE_ERT, SPECIAL_ROLE_DEATHSQUAD) if(!((usr.mind.assigned_role in authorized_roles) || is_admin(usr))) message_admins("Potential ERT shuttle hijack, ERT shuttle moved by unauthorized user: [key_name_admin(usr)]") ..() - + /obj/machinery/computer/camera_advanced/shuttle_docker/ert name = "specops navigation computer" diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 8ddbf3c88ea..9ec2375d548 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -773,13 +773,13 @@ return connect() add_fingerprint(user) - ui_interact(user) + tgui_interact(user) //note to self, new stuff. Also TODO: remove dumb comments once you know how tgui works, ya dork /obj/machinery/computer/shuttle/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, 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, "shuttle_console.js", name, 300, 300, master_ui, state) + ui = new(user, src, ui_key, "ShuttleConsole", name, 300, 300, master_ui, state) ui.open() /obj/machinery/computer/shuttle/tgui_data(mob/user) @@ -823,7 +823,7 @@ to_chat(usr, "Invalid shuttle requested.") else to_chat(usr, "Unable to comply.") - return 1 + return TRUE diff --git a/code/modules/shuttle/syndicate.dm b/code/modules/shuttle/syndicate.dm index f9ec738b167..6197f3c10f6 100644 --- a/code/modules/shuttle/syndicate.dm +++ b/code/modules/shuttle/syndicate.dm @@ -18,7 +18,7 @@ circuit = /obj/item/circuitboard/shuttle/syndicate/recall possible_destinations = "syndicate_away" -/obj/machinery/computer/shuttle/syndicate/Topic(href, href_list) +/obj/machinery/computer/shuttle/syndicate/Topic(href, href_list) // TODO convert this too if(href_list["move"]) if(challenge && world.time < SYNDICATE_CHALLENGE_TIMER) to_chat(usr, "You've issued a combat challenge to the station! You've got to give them at least [round(((SYNDICATE_CHALLENGE_TIMER - world.time) / 10) / 60)] more minutes to allow them to prepare.") diff --git a/tgui/packages/tgui/interfaces/ShuttleConsole.js b/tgui/packages/tgui/interfaces/ShuttleConsole.js new file mode 100644 index 00000000000..793442e6040 --- /dev/null +++ b/tgui/packages/tgui/interfaces/ShuttleConsole.js @@ -0,0 +1,72 @@ +import { useBackend } from '../backend'; +import { Button, LabeledList, Box, Section } from '../components'; +import { Window } from '../layouts'; +import { LabeledListItem } from '../components/LabeledList'; + +export const ShuttleConsole = (props, context) => { + const { act, data } = useBackend(context); + // get stuff + return ( + + + + + {data.status ? ( + data.status + ) : ( + + *MISSING* + + )} + + + {!!data.shuttle && (// only show this stuff if there's a shuttle + <> + {!!data.docking_ports_len && ( + // I am not sure if I am nesting this stuff right... + <> + {data.docking_ports.map(port => ( +