Merge pull request #14065 from TDSSS/shuttle-console-tgui

[TGUI] Shuttle console
This commit is contained in:
AffectedArc07
2020-09-15 18:38:00 +01:00
committed by GitHub
7 changed files with 114 additions and 104 deletions
@@ -13,15 +13,3 @@
possible_destinations = "laborcamp_away"
circuit = /obj/item/circuitboard/labor_shuttle/one_way
req_access = list( )
/obj/machinery/computer/shuttle/labor/one_way/Topic(href, href_list)
if(href_list["move"])
var/obj/docking_port/mobile/M = SSshuttle.getShuttle("laborcamp")
if(!M)
to_chat(usr, "<span class='warning'>Cannot locate shuttle!</span>")
return 0
var/obj/docking_port/stationary/S = M.get_docked()
if(S && S.name == "laborcamp_away")
to_chat(usr, "<span class='warning'>Shuttle is already at the outpost!</span>")
return 0
..()
+5 -6
View File
@@ -6,13 +6,12 @@
resistance_flags = INDESTRUCTIBLE
flags = NODECONSTRUCT
/obj/machinery/computer/shuttle/ert/Topic(href, href_list)
if(href_list["move"])
/obj/machinery/computer/shuttle/ert/can_call_shuttle(mob/user, action)
if(action == "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)]")
..()
if(!((user.mind?.assigned_role in authorized_roles) || is_admin(user)))
message_admins("Potential ERT shuttle hijack, ERT shuttle moved by unauthorized user: [key_name_admin(user)]")
return TRUE
/obj/machinery/computer/camera_advanced/shuttle_docker/ert
name = "specops navigation computer"
+38 -36
View File
@@ -727,13 +727,13 @@
name = "Shuttle Console"
icon_screen = "shuttle"
icon_keyboard = "tech_key"
req_access = list( )
req_access = list()
circuit = /obj/item/circuitboard/shuttle
var/shuttleId
var/possible_destinations = ""
var/admin_controlled
var/max_connect_range = 7
var/docking_request = 0
var/moved = FALSE //workaround for nukie shuttle, hope I find a better way to do this...
/obj/machinery/computer/shuttle/New(location, obj/item/circuitboard/shuttle/C)
..()
@@ -773,21 +773,20 @@
return
connect()
add_fingerprint(user)
ui_interact(user)
tgui_interact(user)
/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)
/obj/machinery/computer/shuttle/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, "shuttle_console.tmpl", M ? M.name : "shuttle", 300, 200)
ui = new(user, src, ui_key, "ShuttleConsole", name, 350, 150, master_ui, state)
ui.open()
/obj/machinery/computer/shuttle/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
var/data[0]
/obj/machinery/computer/shuttle/tgui_data(mob/user)
var/list/data = list()
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
data["status"] = M ? M.getStatusText() : null
if(M)
data["shuttle"] = 1
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)
@@ -799,34 +798,35 @@
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
/obj/machinery/computer/shuttle/Topic(href, href_list)
if(..())
return 1
/obj/machinery/computer/shuttle/tgui_act(action, params)
if(..()) //we can't actually interact, so no action
return TRUE
if(!allowed(usr))
to_chat(usr, "<span class='danger'>Access denied.</span>")
return
return TRUE
if(!can_call_shuttle(usr, action))
return TRUE
var/list/options = params2list(possible_destinations)
if(href_list["move"])
if(!options.Find(href_list["move"])) //I see you're trying Href exploits, I see you're failing, I SEE ADMIN WARNING.
// Seriously, though, NEVER trust a Topic with something like this. Ever.
// Sidenote for whoever did this last. Why did you set it to echo whatever the user entered to admin chat? You solved one exploit and created another.
if(action == "move")
var/destination = params["move"]
if(!options.Find(destination))//figure out if this translation works
message_admins("<span class='boldannounce'>EXPLOIT:</span> [ADMIN_LOOKUPFLW(usr)] attempted to move [src] to an invalid location! [ADMIN_COORDJMP(src)]")
return
switch(SSshuttle.moveShuttle(shuttleId, href_list["move"], 1, usr))
switch(SSshuttle.moveShuttle(shuttleId, destination, TRUE, 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(!moved)
moved = TRUE
add_fingerprint(usr)
return TRUE
if(1)
to_chat(usr, "<span class='warning'>Invalid shuttle requested.</span>")
else
to_chat(usr, "<span class='notice'>Unable to comply.</span>")
return 1
/obj/machinery/computer/shuttle/emag_act(mob/user)
if(!emagged)
@@ -834,6 +834,10 @@
emagged = 1
to_chat(user, "<span class='notice'>You fried the consoles ID checking system.</span>")
//for restricting when the computer can be used, needed for some console subtypes.
/obj/machinery/computer/shuttle/proc/can_call_shuttle(mob/user, action)
return TRUE
/obj/machinery/computer/shuttle/ferry
name = "transport ferry console"
circuit = /obj/item/circuitboard/ferry
@@ -844,25 +848,23 @@
/obj/machinery/computer/shuttle/ferry/request
name = "ferry console"
circuit = /obj/item/circuitboard/ferry/request
var/cooldown //prevents spamming admins
var/next_request //to prevent spamming admins
possible_destinations = "ferry_home"
admin_controlled = 1
admin_controlled = TRUE
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
/obj/machinery/computer/shuttle/ferry/request/Topic(href, href_list)
if(..())
return 1
if(href_list["request"])
if(cooldown)
/obj/machinery/computer/shuttle/ferry/request/tgui_act(action, params)
if(..()) // Note that the parent handels normal shuttle movement on top of security checks
return
if(action == "request")
if(world.time < next_request)
return
cooldown = 1
next_request = world.time + 60 SECONDS //1 minute cooldown
to_chat(usr, "<span class='notice'>Your request has been recieved by Centcom.</span>")
log_admin("[key_name(usr)] requested to move the transport ferry to Centcom.")
message_admins("<b>FERRY: <font color='blue'>[key_name_admin(usr)] (<A HREF='?_src_=holder;secretsfun=moveferry'>Move Ferry</a>)</b> is requesting to move the transport ferry to Centcom.</font>")
. = 1
SSnanoui.update_uis(src)
spawn(600) //One minute cooldown
cooldown = 0
return TRUE
/obj/machinery/computer/shuttle/white_ship
name = "White Ship Console"
+9 -11
View File
@@ -11,20 +11,18 @@
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
flags = NODECONSTRUCT
var/challenge = FALSE
var/moved = FALSE
/obj/machinery/computer/shuttle/syndicate/recall
name = "syndicate shuttle recall terminal"
circuit = /obj/item/circuitboard/shuttle/syndicate/recall
possible_destinations = "syndicate_away"
/obj/machinery/computer/shuttle/syndicate/Topic(href, href_list)
if(href_list["move"])
/obj/machinery/computer/shuttle/syndicate/can_call_shuttle(user, action)
if(action == "move")
if(challenge && world.time < SYNDICATE_CHALLENGE_TIMER)
to_chat(usr, "<span class='warning'>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.</span>")
return 0
moved = TRUE
..()
to_chat(user, "<span class='warning'>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.</span>")
return FALSE
return TRUE
/obj/machinery/computer/shuttle/syndicate/drop_pod
name = "syndicate assault pod control"
@@ -35,11 +33,11 @@
shuttleId = "steel_rain"
possible_destinations = null
/obj/machinery/computer/shuttle/syndicate/drop_pod/Topic(href, href_list)
if(href_list["move"])
/obj/machinery/computer/shuttle/syndicate/drop_pod/can_call_shuttle(user, action)
if(action == "move")
if(z != level_name_to_num(CENTCOMM))
to_chat(usr, "<span class='warning'>Pods are one way!</span>")
return 0
to_chat(user, "<span class='warning'>Pods are one way!</span>")
return FALSE
..()
/obj/machinery/computer/shuttle/sst
-37
View File
@@ -1,37 +0,0 @@
<!--
Title: Shuttle Console
Used In File(s): /code/modules/shuttle/shuttle.dm
-->
<div class='item'>
<div class='itemLabel'>Location:</div>
<div class='itemContent'>{{:data.status ? data.status : '<span class="bad">*Missing*</span>'}}</div>
</div>
{{if data.shuttle}}
{{if data.docking_ports_len}}
<hr>
<div class='item'>
{{for data.docking_ports}}
<div class='line'>{{:helper.link('Send to ' + value.name, 'sign-out', {'move' : value.id})}}</div>
{{/for}}
</div>
{{else}}
<div class='item'>
<div class='itemLabel'>Status:</div>
<div class='itemContent bad'>Shuttle locked
{{if data.admin_controlled}}
<span>, authorized personnel only</span>
</div></div>
<hr>
<div class='item'>{{:helper.link('Request authorization', 'share-square-o', {'request' : 1})}}</div>
{{else}}
</div>
</div>
<hr>
{{/if}}
{{/if}}
{{if data.docking_request}}
<div class='line'>{{:helper.link('Request docking at the station', 'share-square-o', {'request' : 1})}}</div>
{{/if}}
{{/if}}
@@ -0,0 +1,60 @@
import { useBackend } from '../backend';
import { Button, LabeledList, Box, Fragment, Section, NoticeBox } from '../components';
import { Window } from '../layouts';
import { LabeledListItem } from '../components/LabeledList';
export const ShuttleConsole = (props, context) => {
const { act, data } = useBackend(context);
return (
<Window resizable>
<Window.Content>
<Section>
<LabeledList>
<LabeledList.Item label="Location">
{data.status ? (
data.status
) : (
<NoticeBox color="red">
Shuttle Missing
</NoticeBox>
)}
</LabeledList.Item>
{!!data.shuttle && (// only show this stuff if there's a shuttle
!!data.docking_ports_len && (
<LabeledList.Item label={"Send to "}>
{data.docking_ports.map(port => (
<Button
icon="chevron-right"
key={port.name}
content={port.name}
onClick={() => act('move', {
move: port.id,
})} />
)
)}
</LabeledList.Item>
) || (// ELSE, if there's no docking ports.
<Fragment>
<LabeledListItem label="Status" color="red">
<NoticeBox color="red">
Shuttle Locked
</NoticeBox>
</LabeledListItem>
{!!data.admin_controlled && (
<LabeledListItem label="Authorization">
<Button
icon="exclamation-circle"
content="Request Authorization"
disabled={!data.status}
onClick={() => act('request')} />
</LabeledListItem>
)}
</Fragment>
)
)}
</LabeledList>
</Section>
</Window.Content>
</Window>
);
};
File diff suppressed because one or more lines are too long