Browse Source

tgui: Shuttle Console (#53168)

master
Arkatos1 7 months ago
committed by GitHub
parent
commit
3343863325
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 260 additions and 69 deletions
  1. +1
    -1
      code/modules/mining/mine_items.dm
  2. +2
    -2
      code/modules/security_levels/security_levels.dm
  3. +89
    -50
      code/modules/shuttle/computer.dm
  4. +1
    -1
      code/modules/shuttle/emergency.dm
  5. +0
    -12
      code/modules/shuttle/ferry.dm
  6. +20
    -1
      code/modules/shuttle/shuttle.dm
  7. +145
    -0
      tgui/packages/tgui/interfaces/ShuttleConsole.js
  8. +1
    -1
      tgui/public/tgui-panel.bundle.js
  9. +1
    -1
      tgui/public/tgui.bundle.js

+ 1
- 1
code/modules/mining/mine_items.dm View File

@ -71,7 +71,7 @@
circuit = /obj/item/circuitboard/computer/mining_shuttle
shuttleId = "mining"
possible_destinations = "mining_home;mining_away;landing_zone_dock;mining_public"
no_destination_swap = 1
no_destination_swap = TRUE
var/static/list/dumb_rev_heads = list()
//ATTACK HAND IGNORING PARENT RETURN VALUE


+ 2
- 2
code/modules/security_levels/security_levels.dm View File

@ -60,7 +60,7 @@ GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN)
if(is_station_level(FA.z))
FA.update_icon()
for(var/obj/machinery/computer/shuttle/pod/pod in GLOB.machines)
pod.admin_controlled = 0
pod.admin_controlled = FALSE
if(SEC_LEVEL_DELTA)
minor_announce(CONFIG_GET(string/alert_delta), "Attention! Delta security level reached!",1)
if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL)
@ -73,7 +73,7 @@ GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN)
if(is_station_level(FA.z))
FA.update_icon()
for(var/obj/machinery/computer/shuttle/pod/pod in GLOB.machines)
pod.admin_controlled = 0
pod.admin_controlled = FALSE
if(level >= SEC_LEVEL_RED)
for(var/obj/machinery/door/D in GLOB.machines)
if(D.red_alert_access)


+ 89
- 50
code/modules/shuttle/computer.dm View File

@ -5,69 +5,108 @@
icon_keyboard = "tech_key"
light_color = LIGHT_COLOR_CYAN
req_access = list( )
/// ID of the attached shuttle
var/shuttleId
/// Possible destinations of the attached shuttle
var/possible_destinations = ""
var/admin_controlled
var/no_destination_swap = 0
/// Variable dictating if the attached shuttle requires authorization from the admin staff to move
var/admin_controlled = FALSE
/// Variable dictating if the attached shuttle can change destinations mid-flight
var/no_destination_swap = FALSE
/// ID of the currently selected destination of the attached shuttle
var/destination
/// Authorization request cooldown to prevent request spam to admin staff
COOLDOWN_DECLARE(request_cooldown)
/obj/machinery/computer/shuttle/ui_interact(mob/user)
. = ..()
/obj/machinery/computer/shuttle/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ShuttleConsole", name)
ui.open()
/obj/machinery/computer/shuttle/ui_data(mob/user)
var/list/data = list()
var/list/options = params2list(possible_destinations)
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
var/dat = "<small><i>Donk Co. Transportation Division</small></i><br>Status: [M ? M.getStatusText() : "*Missing*"]<br><br>"
if(M)
var/destination_found
for(var/obj/docking_port/stationary/S in SSshuttle.stationary)
if(!options.Find(S.id))
continue
if(!M.check_dock(S, silent=TRUE))
continue
destination_found = 1
dat += "<A href='?src=[REF(src)];move=[S.id]'>Send to [S.name]</A><br>"
if(!destination_found)
dat += "<B>Shuttle Locked</B><br>"
if(admin_controlled)
dat += "Authorized personnel only<br>"
dat += "<A href='?src=[REF(src)];request=1]'>Request Authorization</A><br>"
dat += "<a href='?src=[REF(user)];mach_close=computer'>Close</a>"
var/datum/browser/popup = new(user, "computer", M ? M.name : "shuttle", 300, 200)
popup.set_content("<center>[dat]</center>")
popup.open()
data["docked_location"] = M ? M.get_status_text_tgui() : "Unknown"
data["status"] = M.mode == SHUTTLE_IGNITING ? "Igniting" : M.mode != SHUTTLE_IDLE ? "In Transit" : "Idle"
data["locations"] = list()
data["locked"] = FALSE
data["authorization_required"] = admin_controlled
data["timer_str"] = M ? M.getTimerStr() : "00:00"
data["destination"] = destination
if(admin_controlled)
data["status"] = "Unauthorized Access"
if(!M)
data["status"] = "Missing"
return data
for(var/obj/docking_port/stationary/S in SSshuttle.stationary)
if(!options.Find(S.id))
continue
if(!M.check_dock(S, silent = TRUE))
continue
var/list/location_data = list(
id = S.id,
name = S.name
)
data["locations"] += list(location_data)
if(length(data["locations"]) == 1)
for(var/location in data["locations"])
destination = location["id"]
data["destination"] = destination
if(!length(data["locations"]))
data["locked"] = TRUE
data["status"] = "Locked"
return data
/obj/machinery/computer/shuttle/Topic(href, href_list)
if(..())
/obj/machinery/computer/shuttle/ui_act(action, params)
. = ..()
if(.)
return
usr.set_machine(src)
src.add_fingerprint(usr)
if(!allowed(usr))
to_chat(usr, "<span class='danger'>Access denied.</span>")
return
if(href_list["move"])
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
if(M.launch_status == ENDGAME_LAUNCHED)
to_chat(usr, "<span class='warning'>You've already escaped. Never going back to that place again!</span>")
return
if(no_destination_swap)
if(M.mode == SHUTTLE_RECHARGING)
to_chat(usr, "<span class='warning'>Shuttle engines are not ready for use.</span>")
switch(action)
if("move")
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
if(M.launch_status == ENDGAME_LAUNCHED)
to_chat(usr, "<span class='warning'>You've already escaped. Never going back to that place again!</span>")
return
if(no_destination_swap)
if(M.mode == SHUTTLE_RECHARGING)
to_chat(usr, "<span class='warning'>Shuttle engines are not ready for use.</span>")
return
if(M.mode != SHUTTLE_IDLE)
to_chat(usr, "<span class='warning'>Shuttle already in transit.</span>")
return
var/list/options = params2list(possible_destinations)
if(!(params["shuttle_id"] in options))
log_admin("[usr] attempted to href dock exploit on [src] with target location \"[params["shuttle_id"]]\"")
message_admins("[usr] just attempted to href dock exploit on [src] with target location \"[params["shuttle_id"]]\"")
return
if(M.mode != SHUTTLE_IDLE)
to_chat(usr, "<span class='warning'>Shuttle already in transit.</span>")
switch(SSshuttle.moveShuttle(shuttleId, params["shuttle_id"], 1))
if(0)
say("Shuttle departing. Please stand away from the doors.")
log_shuttle("[key_name(usr)] has sent shuttle \"[M]\" towards \"[params["shuttle_id"]]\", using [src].")
return TRUE
if(1)
to_chat(usr, "<span class='warning'>Invalid shuttle requested.</span>")
else
to_chat(usr, "<span class='warning'>Unable to comply.</span>")
if("set_destination")
var/target_destination = params["destination"]
if(target_destination)
destination = target_destination
return TRUE
if("request")
if(!COOLDOWN_FINISHED(src, request_cooldown))
to_chat(usr, "<span class='warning'>CentCom is still processing last authorization request!</span>")
return
if(!(href_list["move"] in params2list(possible_destinations)))
log_admin("[usr] attempted to forge a target location through a href exploit on [src] with target location \"[href_list["move"]]\"")
message_admins("[ADMIN_FULLMONTY(usr)] attempted to forge a target location through a href exploit on [src]")
return
switch(SSshuttle.moveShuttle(shuttleId, href_list["move"], 1))
if(0)
say("Shuttle departing. Please stand away from the doors.")
log_shuttle("[key_name(usr)] has sent shuttle \"[M]\" towards \"[href_list["move"]]\", using [src].")
if(1)
to_chat(usr, "<span class='warning'>Invalid shuttle requested.</span>")
else
to_chat(usr, "<span class='warning'>Unable to comply.</span>")
COOLDOWN_START(src, request_cooldown, 1 MINUTES)
to_chat(usr, "<span class='notice'>Your request has been received by CentCom.</span>")
to_chat(GLOB.admins, "<b>FERRY: <font color='#3d5bc3'>[ADMIN_LOOKUPFLW(usr)] (<A HREF='?_src_=holder;[HrefToken()];secrets=moveferry'>Move Ferry</a>)</b> is requesting to move the transport ferry to CentCom.</font>")
return TRUE
/obj/machinery/computer/shuttle/emag_act(mob/user)
if(obj_flags & EMAGGED)


+ 1
- 1
code/modules/shuttle/emergency.dm View File

@ -465,7 +465,7 @@
/obj/machinery/computer/shuttle/pod
name = "pod control computer"
admin_controlled = 1
admin_controlled = TRUE
possible_destinations = "pod_asteroid"
icon = 'icons/obj/terminals.dmi'
icon_state = "dorm_available"


+ 0
- 12
code/modules/shuttle/ferry.dm View File

@ -5,7 +5,6 @@
shuttleId = "ferry"
possible_destinations = "ferry_home;ferry_away"
req_access = list(ACCESS_CENT_GENERAL)
var/allow_silicons = FALSE
var/allow_emag = FALSE
@ -24,17 +23,6 @@
/obj/machinery/computer/shuttle/ferry/request
name = "ferry console"
circuit = /obj/item/circuitboard/computer/ferry/request
var/last_request //prevents spamming admins
var/cooldown = 600
possible_destinations = "ferry_home;ferry_away"
req_access = list(ACCESS_CENT_GENERAL)
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
/obj/machinery/computer/shuttle/ferry/request/Topic(href, href_list)
..()
if(href_list["request"])
if(last_request && (last_request + cooldown > world.time))
return
last_request = world.time
to_chat(usr, "<span class='notice'>Your request has been received by CentCom.</span>")
to_chat(GLOB.admins, "<b>FERRY: <font color='#3d5bc3'>[ADMIN_LOOKUPFLW(usr)] (<A HREF='?_src_=holder;[HrefToken()];secrets=moveferry'>Move Ferry</a>)</b> is requesting to move the transport ferry to CentCom.</font>")

+ 20
- 1
code/modules/shuttle/shuttle.dm View File

@ -708,6 +708,26 @@
else
return "00:00"
/**
* Gets shuttle location status in a form of string for tgui interfaces
*/
/obj/docking_port/mobile/proc/get_status_text_tgui()
var/obj/docking_port/stationary/dockedAt = get_docked()
var/docked_at = dockedAt?.name || "Unknown"
if(istype(dockedAt, /obj/docking_port/stationary/transit))
if(timeLeft() > 1 HOURS)
return "Hyperspace"
else
var/obj/docking_port/stationary/dst
if(mode == SHUTTLE_RECALL)
dst = previous
else
dst = destination
return "In transit towards [dst?.name || "unknown location"]"
else if(mode == SHUTTLE_RECHARGING)
return "[docked_at], recharging [getTimerStr()]"
else
return docked_at
/obj/docking_port/mobile/proc/getStatusText()
var/obj/docking_port/stationary/dockedAt = get_docked()
@ -727,7 +747,6 @@
else
return docked_at
/obj/docking_port/mobile/proc/getDbgStatusText()
var/obj/docking_port/stationary/dockedAt = get_docked()
. = (dockedAt && dockedAt.name) ? dockedAt.name : "unknown"


+ 145
- 0
tgui/packages/tgui/interfaces/ShuttleConsole.js View File

@ -0,0 +1,145 @@
import { useBackend } from '../backend';
import { Box, Button, Dropdown, Flex, Icon, LabeledList, Modal, Section } from '../components';
import { Window } from '../layouts';
export const ShuttleConsole = (props, context) => {
const { act, data } = useBackend(context);
const {
authorization_required,
} = data;
return (
<Window
width={350}
height={230}>
{!!authorization_required && (
<Modal
ml={1}
mt={1}
width={26}
height={12}
fontSize="28px"
fontFamily="monospace"
textAlign="center">
<Flex>
<Flex.Item mt={2}>
<Icon
name="minus-circle" />
</Flex.Item>
<Flex.Item
mt={2}
ml={2}
color="bad">
{'SHUTTLE LOCKED'}
</Flex.Item>
</Flex>
<Box
fontSize="18px"
mt={4}>
<Button
lineHeight="40px"
icon="arrow-circle-right"
content="Request Authorization"
color="bad"
onClick={() => act('request')} />
</Box>
</Modal>
)}
<Window.Content>
<ShuttleConsoleContent />
</Window.Content>
</Window>
);
};
const getLocationNameById = (locations, id) => {
return locations?.find(location => location.id === id).name;
};
const getLocationIdByName = (locations, name) => {
return locations?.find(location => location.name === name).id;
};
const ShuttleConsoleContent = (props, context) => {
const { act, data } = useBackend(context);
const {
status,
locked,
authorization_required,
destination,
docked_location,
timer_str,
locations = [],
} = data;
return (
<Section>
<Box
bold
fontSize="26px"
textAlign="center"
fontFamily="monospace">
{timer_str || "00:00"}
</Box>
<Box
textAlign="center"
fontSize="14px"
mb={1}>
<Box
inline
bold>
STATUS:
</Box>
<Box
inline
color={status==="In Transit"
? 'good'
: status==="Idle"
? 'average'
: status==="Igniting"
? 'average'
: 'bad'}
ml={1}>
{status || "Not Available"}
</Box>
</Box>
<Section
title="Shuttle Controls"
level={2}>
<LabeledList>
<LabeledList.Item label="Location">
{docked_location || "Not Available"}
</LabeledList.Item>
<LabeledList.Item label="Destination">
{locations.length===0 && (
<Box color="bad">
Not Available
</Box>
) || locations.length===1 &&(
<Box color="average">
{getLocationNameById(locations, destination)}
</Box>
) || (
<Dropdown
over
width="240px"
options={locations.map(location => location.name)}
disabled={locked || authorization_required}
selected={destination ? getLocationNameById(locations, destination) : "Select a Destination"}
onSelected={value => act('set_destination', {
destination: getLocationIdByName(locations, value),
})} />)}
</LabeledList.Item>
</LabeledList>
<Button
fluid
content="Depart"
disabled={locked || authorization_required || !destination}
mt={1.5}
icon="arrow-up"
textAlign="center"
onClick={() => act('move', {
shuttle_id: destination,
})} />
</Section>
</Section>
);
};

+ 1
- 1
tgui/public/tgui-panel.bundle.js
File diff suppressed because it is too large
View File


+ 1
- 1
tgui/public/tgui.bundle.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save