Merge pull request #14277 from RedWolfie/teleporter

[TGUI] Teleporter
This commit is contained in:
AffectedArc07
2020-09-16 10:59:08 +01:00
committed by GitHub
4 changed files with 408 additions and 241 deletions
+239 -203
View File
@@ -1,16 +1,24 @@
#define REGIME_TELEPORT 0
#define REGIME_GATE 1
#define REGIME_GPS 2
/obj/machinery/computer/teleporter
name = "teleporter control console"
desc = "Used to control a linked teleportation Hub and Station."
icon_screen = "teleport"
icon_keyboard = "teleport_key"
circuit = /obj/item/circuitboard/teleporter
var/obj/item/gps/locked = null
var/regime_set = "Teleporter"
var/obj/item/gps/locked = null /// A GPS with a locked destination
var/regime = REGIME_TELEPORT /// Switches mode between teleporter, gate and gps
var/id = null
var/obj/machinery/teleport/station/power_station
var/calibrating
var/turf/target //Used for one-time-use teleport cards (such as clown planet coordinates.)
//Setting this to 1 will set src.locked to null after a player enters the portal and will not allow hand-teles to open portals to that location.
var/obj/machinery/teleport/station/power_station /// The power station that's connected to the console
var/calibrating = FALSE /// Whether calibration is in progress or not. Calibration prevents changes.
var/turf/target ///The target turf of the teleporter
var/target_list ///lists of suitable teleport targets, dependent on regime. Used in the UI
/* var/area_bypass is for one-time-use teleport cards (such as clown planet coordinates.)
Setting this to TRUE will set var/obj/item/gps/locked to null after a player enters the portal and will not allow hand-teles to open portals to that location.
*/
var/area_bypass = FALSE
var/cc_beacon = FALSE
@@ -24,6 +32,7 @@
..()
link_power_station()
update_icon()
target_list = targets_teleport()
/obj/machinery/computer/teleporter/Destroy()
if(power_station)
@@ -55,202 +64,238 @@
/obj/machinery/computer/teleporter/emag_act(mob/user)
if(!emagged)
emagged = 1
emagged = TRUE
to_chat(user, "<span class='notice'>The teleporter can now lock on to Syndicate beacons!</span>")
else
ui_interact(user)
tgui_interact(user)
/obj/machinery/computer/teleporter/attack_ai(mob/user)
src.attack_hand(user)
attack_hand(user)
/obj/machinery/computer/teleporter/attack_hand(mob/user)
ui_interact(user)
tgui_interact(user)
/obj/machinery/computer/teleporter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
/obj/machinery/computer/teleporter/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
if(stat & (NOPOWER|BROKEN))
return
// Set up the Nano UI
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "teleporter_console.tmpl", "Teleporter Console UI", 400, 400)
ui = new(user, src, ui_key, "Teleporter", "Teleporter Console", 380, 260)
ui.open()
/obj/machinery/computer/teleporter/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
var/data[0]
/obj/machinery/computer/teleporter/tgui_data(mob/user)
var/list/data = list()
data["powerstation"] = power_station
if(power_station?.teleporter_hub)
data["teleporterhub"] = power_station.teleporter_hub
data["calibrated"] = power_station.teleporter_hub.calibrated
data["accurate"] = power_station.teleporter_hub.accurate
else
data["teleporterhub"] = null
data["calibrated"] = null
data["accurate"] = null
data["regime"] = regime_set
data["regime"] = regime
var/area/targetarea = get_area(target)
data["target"] = (!target || !targetarea) ? "None" : sanitize(targetarea.name)
data["calibrating"] = calibrating
data["locked"] = locked
data["locked"] = locked ? TRUE : FALSE
data["targetsTeleport"] = target_list
return data
/obj/machinery/computer/teleporter/Topic(href, href_list)
/obj/machinery/computer/teleporter/tgui_act(action, params)
if(..())
return 1
if(href_list["eject"])
eject()
SSnanoui.update_uis(src)
return
if(!check_hub_connection())
to_chat(usr, "<span class='warning'>Error: Unable to detect hub.</span>")
SSnanoui.update_uis(src)
atom_say("Error: Unable to detect hub.")
return
if(calibrating)
to_chat(usr, "<span class='warning'>Error: Calibration in progress. Stand by.</span>")
SSnanoui.update_uis(src)
atom_say("Error: Calibration in progress. Stand by.")
return
if(href_list["regimeset"])
power_station.engaged = 0
power_station.teleporter_hub.update_icon()
power_station.teleporter_hub.calibrated = 0
reset_regime()
SSnanoui.update_uis(src)
if(href_list["settarget"])
power_station.engaged = 0
power_station.teleporter_hub.update_icon()
power_station.teleporter_hub.calibrated = 0
set_target(usr)
SSnanoui.update_uis(src)
if(href_list["lock"])
power_station.engaged = 0
power_station.teleporter_hub.update_icon()
power_station.teleporter_hub.calibrated = 0
target = get_turf(locked.locked_location)
SSnanoui.update_uis(src)
if(href_list["calibrate"])
if(!target)
to_chat(usr, "<span class='warning'>Error: No target set to calibrate to.</span>")
SSnanoui.update_uis(src)
return
if(power_station.teleporter_hub.calibrated || power_station.teleporter_hub.accurate >= 3)
to_chat(usr, "<span class='notice'>Hub is already calibrated.</span>")
SSnanoui.update_uis(src)
return
src.visible_message("<span class='notice'>Processing hub calibration to target...</span>")
. = TRUE
calibrating = 1
SSnanoui.update_uis(src)
spawn(50 * (3 - power_station.teleporter_hub.accurate)) //Better parts mean faster calibration
calibrating = 0
if(check_hub_connection())
power_station.teleporter_hub.calibrated = 1
src.visible_message("<span class='notice'>Calibration complete.</span>")
else
src.visible_message("<span class='warning'>Error: Unable to detect hub.</span>")
SSnanoui.update_uis(src)
switch(action)
if("eject") //eject gps device
eject()
if("load") //load gps coordinates
target = locate(locked.locked_location.x,locked.locked_location.y,locked.locked_location.z)
if("setregime")
regime = text2num(params["regime"])
if(regime == REGIME_TELEPORT)
target_list = targets_teleport()
if(regime == REGIME_GATE)
target_list = targets_gate()
if(regime == REGIME_GPS)
target_list = null //clears existing entries, target is added by load action
resetPowerstation()
target = null
if("settarget")
resetPowerstation()
var/turf/tmpTarget = locate(text2num(params["x"]),text2num(params["y"]),text2num(params["z"]))
if(!istype(tmpTarget, /turf))
atom_say("No valid targets available.")
return
target = tmpTarget
if(regime == REGIME_TELEPORT)
teleport_helper()
if(regime == REGIME_GATE)
gate_helper()
if("calibrate")
if(!target)
atom_say("Error: No target set to calibrate to.")
return
if(power_station.teleporter_hub.calibrated || power_station.teleporter_hub.accurate >= 3)
atom_say("Hub is already calibrated.")
return
SSnanoui.update_uis(src)
atom_say("Processing hub calibration to target...")
calibrating = TRUE
addtimer(CALLBACK(src, .proc/calibrateCallback), 50 * (3 - power_station.teleporter_hub.accurate)) //Better parts mean faster calibration
/**
* Resets the connected powerstation to initial values. Helper function of tgui_act
*/
/obj/machinery/computer/teleporter/proc/resetPowerstation()
power_station.engaged = FALSE
power_station.teleporter_hub.calibrated = FALSE
power_station.teleporter_hub.update_icon()
/**
* Calibrates the hub. Helper function of tgui_act
*/
/obj/machinery/computer/teleporter/proc/calibrateCallback()
calibrating = FALSE
if(check_hub_connection())
power_station.teleporter_hub.calibrated = TRUE
atom_say("Calibration complete.")
else
atom_say("Error: Unable to detect hub.")
/obj/machinery/computer/teleporter/proc/check_hub_connection()
if(!power_station)
return
if(!power_station.teleporter_hub)
return
return 1
/obj/machinery/computer/teleporter/proc/reset_regime()
target = null
if(regime_set == "Teleporter")
regime_set = "Gate"
else
regime_set = "Teleporter"
return TRUE
/**
* Helper function of tgui_act
*
* Triggered when ejecting a gps device. Sets the gps to the ground and resets the console
*/
/obj/machinery/computer/teleporter/proc/eject()
if(locked)
locked.loc = loc
locked = null
regime = REGIME_TELEPORT
target_list = targets_teleport()
/obj/machinery/computer/teleporter/proc/set_target(mob/user)
area_bypass = FALSE
if(regime_set == "Teleporter")
var/list/L = list()
var/list/areaindex = list()
/**
* Creates a list of viable targets for the teleport. Helper function of tgui_data
*/
/obj/machinery/computer/teleporter/proc/targets_teleport()
var/list/L = list()
var/list/areaindex = list()
for(var/obj/item/radio/beacon/R in GLOB.beacons)
var/turf/T = get_turf(R)
if(!T)
continue
if(!is_teleport_allowed(T.z) && !R.cc_beacon)
continue
if(R.syndicate == 1 && emagged == 0)
continue
var/tmpname = T.loc.name
for(var/obj/item/radio/beacon/R in GLOB.beacons)
var/turf/T = get_turf(R)
if(!T)
continue
if(!is_teleport_allowed(T.z) && !R.cc_beacon)
continue
if(R.syndicate && !emagged)
continue
var/tmpname = T.loc.name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = list(
"name" = tmpname,
"x" = T.x,
"y" = T.y,
"z" = T.z)
for(var/obj/item/implant/tracking/I in GLOB.tracked_implants)
if(!I.implanted || !ismob(I.loc))
continue
else
var/mob/M = I.loc
if(M.stat == DEAD)
if(M.timeofdeath + 6000 < world.time)
continue
var/turf/T = get_turf(M)
if(!T) continue
if(!is_teleport_allowed(T.z)) continue
var/tmpname = M.real_name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = R
L[tmpname] = list(
"name" = tmpname,
"x" = T.x,
"y" = T.y,
"z" = T.z)
return L
for(var/obj/item/implant/tracking/I in GLOB.tracked_implants)
if(!I.implanted || !ismob(I.loc))
continue
else
var/mob/M = I.loc
if(M.stat == DEAD)
if(M.timeofdeath + 6000 < world.time)
continue
var/turf/T = get_turf(M)
if(!T) continue
if(!is_teleport_allowed(T.z)) continue
var/tmpname = M.real_name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = I
/**
* Creates a list of viable targets for the gate. Helper function of tgui_data
*/
/obj/machinery/computer/teleporter/proc/targets_gate(mob/users)
var/list/L = list()
var/list/areaindex = list()
var/list/S = power_station.linked_stations
if(!S.len)
return L
for(var/obj/machinery/teleport/station/R in S)
var/turf/T = get_turf(R)
if(!T || !R.teleporter_hub || !R.teleporter_console)
continue
if(!is_teleport_allowed(T.z))
continue
var/tmpname = T.loc.name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = list(
"name" = tmpname,
"x" = T.x,
"y" = T.y,
"z" = T.z)
return L
var/desc = input("Please select a location to lock in.", "Locking Computer") in L
target = L[desc]
if(istype(target, /obj/item/radio/beacon))
var/obj/item/radio/beacon/B = target
/**
* Helper function of tgui_act.
*
* Called after selecting a target for the gate in the UI. Sets area_bypass and cc_beacon.
*/
/obj/machinery/computer/teleporter/proc/teleport_helper()
area_bypass = FALSE
for(var/item in target.contents)
if(istype(item, /obj/item/radio/beacon))
var/obj/item/radio/beacon/B = item
if(B.area_bypass)
area_bypass = TRUE
cc_beacon = B.cc_beacon
else
var/list/L = list()
var/list/areaindex = list()
var/list/S = power_station.linked_stations
if(!S.len)
to_chat(user, "<span class='alert'>No connected stations located.</span>")
return
for(var/obj/machinery/teleport/station/R in S)
var/turf/T = get_turf(R)
if(!T || !R.teleporter_hub || !R.teleporter_console)
continue
if(!is_teleport_allowed(T.z))
continue
var/tmpname = T.loc.name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = R
var/desc = input("Please select a station to lock in.", "Locking Computer") in L
target = L[desc]
if(target)
var/obj/machinery/teleport/station/trg = target
trg.linked_stations |= power_station
trg.stat &= ~NOPOWER
if(trg.teleporter_hub)
trg.teleporter_hub.stat &= ~NOPOWER
trg.teleporter_hub.update_icon()
if(trg.teleporter_console)
trg.teleporter_console.stat &= ~NOPOWER
trg.teleporter_console.update_icon()
return
/**
* Helper function of tgui_act.
*
* Called after selecting a target for the teleporter in the UI.
*/
/obj/machinery/computer/teleporter/proc/gate_helper()
area_bypass = FALSE
var/obj/machinery/teleport/station/trg = target
trg.linked_stations |= power_station
trg.stat &= ~NOPOWER
if(trg.teleporter_hub)
trg.teleporter_hub.stat &= ~NOPOWER
trg.teleporter_hub.update_icon()
if(trg.teleporter_console)
trg.teleporter_console.stat &= ~NOPOWER
trg.teleporter_console.update_icon()
/proc/find_loc(obj/R as obj)
if(!R) return null
@@ -263,20 +308,20 @@
/obj/machinery/teleport
name = "teleport"
icon = 'icons/obj/stationobjs.dmi'
density = 1
anchored = 1.0
density = TRUE
anchored = TRUE
/obj/machinery/teleport/hub
name = "teleporter hub"
desc = "It's the hub of a teleporting machine."
icon_state = "tele0"
var/accurate = 0
var/accurate = FALSE
use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 2000
var/obj/machinery/teleport/station/power_station
var/calibrated //Calibration prevents mutation
var/admin_usage = 0 // if 1, works on z2. If 0, doesn't. Used for admin room teleport.
var/admin_usage = FALSE // if 1, works on z2. If 0, doesn't. Used for admin room teleport.
/obj/machinery/teleport/hub/New()
..()
@@ -317,6 +362,7 @@
for(dir in list(NORTH,EAST,SOUTH,WEST))
power_station = locate(/obj/machinery/teleport/station, get_step(src, dir))
if(power_station)
power_station.link_console_and_hub()
break
return power_station
@@ -324,27 +370,12 @@
if(!is_teleport_allowed(z) && !admin_usage)
to_chat(M, "You can't use this here.")
return
if(power_station && power_station.engaged && !panel_open)
//--FalseIncarnate
//Prevents AI cores from using the teleporter, prints out failure messages for clarity
if(istype(M, /mob/living/silicon/ai) || istype(M, /obj/structure/AIcore))
visible_message("<span class='warning'>The teleporter rejects the AI unit.</span>")
if(istype(M, /mob/living/silicon/ai))
var/mob/living/silicon/ai/T = M
var/list/TPError = list("<span class='warning'>Firmware instructions dictate you must remain on your assigned station!</span>",
"<span class='warning'>You cannot interface with this technology and get rejected!</span>",
"<span class='warning'>External firewalls prevent you from utilizing this machine!</span>",
"<span class='warning'>Your AI core's anti-bluespace failsafes trigger and prevent teleportation!</span>")
to_chat(T, "[pick(TPError)]")
return
else
if(!teleport(M) && isliving(M)) // the isliving(M) is needed to avoid triggering errors if a spark bumps the telehub
visible_message("<span class='warning'>[src] emits a loud buzz, as its teleport portal flickers and fails!</span>")
playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0)
power_station.toggle() // turn off the portal.
use_power(5000)
//--FalseIncarnate
if(power_station && power_station.engaged && !panel_open && !blockAI(M) && !istype(M, /obj/spacepod))
if(!teleport(M) && isliving(M)) // the isliving(M) is needed to avoid triggering errors if a spark bumps the telehub
visible_message("<span class='warning'>[src] emits a loud buzz, as its teleport portal flickers and fails!</span>")
playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, FALSE)
power_station.toggle() // turn off the portal.
use_power(5000)
return
/obj/machinery/teleport/hub/attackby(obj/item/I, mob/user, params)
@@ -375,7 +406,7 @@
. = do_teleport(M, locate(rand((2*TRANSITIONEDGE), world.maxx - (2*TRANSITIONEDGE)), rand((2*TRANSITIONEDGE), world.maxy - (2*TRANSITIONEDGE)), 3), 2, bypass_area_flag = com.area_bypass)
else
. = do_teleport(M, com.target, bypass_area_flag = com.area_bypass)
calibrated = 0
calibrated = FALSE
/obj/machinery/teleport/hub/update_icon()
if(panel_open)
@@ -389,7 +420,7 @@
name = "permanent teleporter"
desc = "A teleporter with the target pre-set on the circuit board."
icon_state = "tele0"
var/recalibrating = 0
var/recalibrating = FALSE
use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 2000
@@ -406,37 +437,42 @@
tele_delay = max(A, 0)
update_icon()
/obj/machinery/teleport/perma/Bumped(M as mob|obj)
/**
Internal helper function
Prevents AI from using the teleporter, prints out failure messages for clarity
*/
/obj/machinery/teleport/proc/blockAI(atom/A)
if(istype(A, /mob/living/silicon/ai) || istype(A, /obj/structure/AIcore))
visible_message("<span class='warning'>The teleporter rejects the AI unit.</span>")
if(istype(A, /mob/living/silicon/ai))
var/mob/living/silicon/ai/T = A
var/list/TPError = list("<span class='warning'>Firmware instructions dictate you must remain on your assigned station!</span>",
"<span class='warning'>You cannot interface with this technology and get rejected!</span>",
"<span class='warning'>External firewalls prevent you from utilizing this machine!</span>",
"<span class='warning'>Your AI core's anti-bluespace failsafes trigger and prevent teleportation!</span>")
to_chat(T, "[pick(TPError)]")
return TRUE
return FALSE
/obj/machinery/teleport/perma/Bumped(atom/A)
if(stat & (BROKEN|NOPOWER))
return
if(!is_teleport_allowed(z))
to_chat(M, "You can't use this here.")
to_chat(A, "You can't use this here.")
return
if(target && !recalibrating && !panel_open)
//--FalseIncarnate
//Prevents AI cores from using the teleporter, prints out failure messages for clarity
if(istype(M, /mob/living/silicon/ai) || istype(M, /obj/structure/AIcore))
visible_message("<span class='warning'>The teleporter rejects the AI unit.</span>")
if(istype(M, /mob/living/silicon/ai))
var/mob/living/silicon/ai/T = M
var/list/TPError = list("<span class='warning'>Firmware instructions dictate you must remain on your assigned station!</span>",
"<span class='warning'>You cannot interface with this technology and get rejected!</span>",
"<span class='warning'>External firewalls prevent you from utilizing this machine!</span>",
"<span class='warning'>Your AI core's anti-bluespace failsafes trigger and prevent teleportation!</span>")
to_chat(T, "[pick(TPError)]")
return
else
do_teleport(M, target)
use_power(5000)
if(tele_delay)
recalibrating = 1
update_icon()
spawn(tele_delay)
recalibrating = 0
update_icon()
//--FalseIncarnate
return
if(target && !recalibrating && !panel_open && !blockAI(A))
do_teleport(A, target)
use_power(5000)
if(tele_delay)
recalibrating = TRUE
update_icon()
addtimer(CALLBACK(src, .proc/BumpedCallback), tele_delay)
/obj/machinery/teleport/perma/proc/BumpedCallback()
recalibrating = FALSE
update_icon()
/obj/machinery/teleport/perma/power_change()
..()
@@ -467,7 +503,7 @@
name = "station"
desc = "The power control station for a bluespace teleporter."
icon_state = "controller"
var/engaged = 0
var/engaged = FALSE
use_power = IDLE_POWER_USE
idle_power_usage = 10
active_power_usage = 2000
@@ -568,7 +604,7 @@
/obj/machinery/teleport/station/attack_ai()
src.attack_hand()
attack_hand()
/obj/machinery/teleport/station/attack_hand(mob/user)
if(!panel_open)
@@ -583,12 +619,12 @@
to_chat(user, "<span class='notice'>Close the hub's maintenance panel first.</span>")
return
if(teleporter_console.target)
src.engaged = !src.engaged
engaged = !engaged
use_power(5000)
visible_message("<span class='notice'>Teleporter [engaged ? "" : "dis"]engaged!</span>")
else
visible_message("<span class='alert'>No target detected.</span>")
src.engaged = 0
engaged = FALSE
teleporter_hub.update_icon()
if(istype(user))
add_fingerprint(user)
-36
View File
@@ -1,36 +0,0 @@
<!--
Title: Teleporter Console UI
Used In File(s): \code\game\machinery\teleporter.dm
-->
<h1>Teleporter Status</h1>
{{if !data.powerstation}}
<div class="bad">No power station linked.</div>
{{else !data.teleporterhub}}
<div class="bad">No hub linked.</div>
{{else}}
<div class="block">
<div class="item">
<div class="itemLabel">Current Regime</div>
<div class="itemContent">{{:data.regime}}</div>
</div>
<div class="item">
<div class="itemLabel">Current Target</div>
<div class="itemContent">{{:data.target}}{{if data.target != "None"}}{{if data.regime == "Gate"}} Teleporter{{/if}}{{/if}}</div>
</div>
<div class="item">
<div class="itemLabel">Calibration</div>
<div class="itemContent">{{if data.calibrating}}<span class="average">In Progress</span>{{else data.calibrated}}<span class="good">Optimal</span>{{else data.accurate > 2}}<span class="good">Optimal</span>{{else}}<span class="bad">Sub-Optimal</span>{{/if}}</div>
</div>
</div>
<div style="margin-top:10px;" class="item">
<div class="item">{{:helper.link('Change regime', 'gear', {'regimeset': 1})}}</div>
<div class="item">{{:helper.link('Set target', 'gear', {'settarget': 1})}}</div>
</div>
<div style="margin-top:10px;" class="item">
<div class="item">{{:helper.link('Get target from memory', 'arrow-circle-down', {'lock': 1}, data.locked ? '' : 'disabled')}}</div>
<div class="item">{{:helper.link('Eject GPS device', 'eject', {'eject': 1}, data.locked ? '' : 'disabled')}}</div>
</div>
<div style="margin-top:10px;" class="item">
<div class="item">{{:helper.link('Calibrate hub', 'arrows-alt', {'calibrate': 1}, data.target == 'None' ? 'disabled' : '')}}</div>
</div>
{{/if}}
+167
View File
@@ -0,0 +1,167 @@
import { useBackend } from '../backend';
import { Box, Button, LabeledList, Section, Grid, Dropdown, Flex } from '../components';
import { Window } from '../layouts';
import { GridColumn } from '../components/Grid';
export const Teleporter = (props, context) => {
const { act, data } = useBackend(context);
let targetsTeleport = data.targetsTeleport ? data.targetsTeleport : {};
const REGIME_TELEPORT = 0;
const REGIME_GATE = 1;
const REGIME_GPS = 2;
const {
calibrated,
calibrating,
powerstation,
regime,
teleporterhub,
target,
locked,
} = data;
return (
<Window>
<Window.Content>
{(!powerstation || !teleporterhub)
&& (
<Section
title="Error">
{teleporterhub}
{!powerstation
&& (
<Box color="bad"> Powerstation not linked </Box>
)}
{powerstation && !teleporterhub
&& (
<Box color="bad"> Teleporter hub not linked </Box>
)}
</Section>
)}
{(powerstation && teleporterhub)
&& (
<Section title="Status">
<LabeledList>
<LabeledList.Item label="Regime">
<Button
tooltip="Teleport to another teleport hub. "
color={regime === REGIME_GATE ? 'good' : null}
onClick={() =>
act('setregime', { regime: REGIME_GATE })}>
Gate
</Button>
<Button
tooltip="One-way teleport. "
color={regime === REGIME_TELEPORT ? 'good' : null}
onClick={() =>
act('setregime', { regime: REGIME_TELEPORT })}>
Teleporter
</Button>
<Button
tooltip="Teleport to a location stored in a GPS device. "
color={regime === REGIME_GPS ? 'good' : null}
disabled={locked ? false : true}
onClick={() =>
act('setregime', { regime: REGIME_GPS })}>
GPS
</Button>
</LabeledList.Item>
<LabeledList.Item label="Teleport target">
{/* The duplication of the dropdowns is due to the
updates of selected not affecting the state
of the dropdown */}
{regime === REGIME_TELEPORT && (
<Dropdown
width="220px"
selected={target}
options={Object.keys(targetsTeleport)}
color={target !== "None" ? "default" : "bad"}
onSelected={val => act('settarget',
{
x: targetsTeleport[val]["x"],
y: targetsTeleport[val]["y"],
z: targetsTeleport[val]["z"],
})} />
)}
{regime === REGIME_GATE && (
<Dropdown
width="220px"
selected={target}
options={Object.keys(targetsTeleport)}
color={target !== "None" ? "default" : "bad"}
onSelected={val => act('settarget',
{
x: targetsTeleport[val]["x"],
y: targetsTeleport[val]["y"],
z: targetsTeleport[val]["z"],
})} />
)}
{regime === REGIME_GPS && (
<Box>
{target}
</Box>
)}
</LabeledList.Item>
<LabeledList.Item label="Calibration">
{target !== 'None'
&& (
<Grid>
<GridColumn size="2">
{calibrating
&& (
<Box color="average">
In Progress
</Box>
) || (calibrated
&& (
<Box color="good">
Optimal
</Box>
) || (
<Box color="bad">
Sub-Optimal
</Box>
))}
</GridColumn>
<GridColumn size="3">
<Box class="ml-1">
<Button
icon="sync-alt"
tooltip="Calibrates the hub. \
Accidents may occur when the \
calibration is not optimal."
disabled={(calibrated || calibrating) ? true : false}
onClick={() => act('calibrate')} />
</Box>
</GridColumn>
</Grid>
)}
{target === 'None'
&& (
<Box lineHeight="21px">
No target set
</Box>
)}
</LabeledList.Item>
</LabeledList>
</Section>
)}
{!!(locked && powerstation && teleporterhub && regime === REGIME_GPS)
&& (
<Section title="GPS">
<Flex direction="row" justify="space-around">
<Button
content="Upload GPS data"
tooltip="Loads the GPS data from the device."
icon="upload"
onClick={() => act('load')} />
<Button
content="Eject"
tooltip="Ejects the GPS device"
icon="eject"
onClick={() => act('eject')} />
</Flex>
</Section>
)}
</Window.Content>
</Window>
);
};
File diff suppressed because one or more lines are too long