TGUI Teleporter

This commit is contained in:
ShadowLarkens
2020-09-19 21:16:18 -07:00
parent f6085dfaac
commit b1c7c65cb6
6 changed files with 146 additions and 152 deletions

View File

@@ -11,7 +11,7 @@
var/id = null
var/one_time_use = 0 //Used for one-time-use teleport cards (such as clown planet coordinates.)
//Setting this to 1 will set locked to null after a player enters the portal and will not allow hand-teles to open portals to that location.
var/datum/nano_module/program/teleport_control/teleport_control
var/datum/tgui_module/teleport_control/teleport_control
/obj/machinery/computer/teleporter/New()
id = "[rand(1000, 9999)]"
@@ -44,7 +44,7 @@
teleport_control.station = station
/obj/machinery/computer/teleporter/Destroy()
qdel_null(teleport_control)
QDEL_NULL(teleport_control)
return ..()
/obj/machinery/computer/teleporter/attackby(I as obj, mob/living/user as mob)
@@ -96,108 +96,13 @@
attack_hand()
/obj/machinery/computer/teleporter/attack_ai(mob/user)
ui_interact(user)
teleport_control.tgui_interact(user)
/obj/machinery/computer/teleporter/attack_hand(mob/user)
add_fingerprint(user)
if(stat & (BROKEN|NOPOWER))
return
ui_interact(user)
/obj/machinery/computer/teleporter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
teleport_control.ui_interact(user, ui_key, ui, force_open)
/obj/machinery/computer/teleporter/interact(mob/user)
teleport_control.ui_interact(user)
//////
////// Nano-module for teleporter
//////
/datum/nano_module/program/teleport_control
name = "Teleporter Control"
var/locked_name = "Not Locked"
var/obj/item/locked = null
var/obj/machinery/teleport/station/station = null
var/obj/machinery/teleport/hub/hub = null
/datum/nano_module/program/teleport_control/Topic(href, href_list)
if(..()) return 1
if(href_list["select_target"])
var/list/L = list()
var/list/areaindex = list()
for(var/obj/item/device/radio/beacon/R in all_beacons)
var/turf/T = get_turf(R)
if(!T)
continue
if(!(T.z in using_map.player_levels))
continue
var/tmpname = T.loc.name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = R
for (var/obj/item/weapon/implant/tracking/I in all_tracking_implants)
if(!I.implanted || !ismob(I.loc))
continue
else
var/mob/M = I.loc
if(M.stat == 2)
if(M.timeofdeath + 6000 < world.time)
continue
var/turf/T = get_turf(M)
if(T) continue
if(T.z == 2) continue
var/tmpname = M.real_name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = I
var/desc = input("Please select a location to lock in.", "Locking Menu") in L|null
if(!desc)
return 0
if(get_dist(host, usr) > 1 && !issilicon(usr))
return 0
locked = L[desc]
locked_name = desc
return 1
if(href_list["test_fire"])
station?.testfire()
return 1
if(href_list["toggle_on"])
if(!station)
return 0
if(station.engaged)
station.disengage()
else
station.engage()
return 1
/datum/nano_module/program/teleport_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
var/list/data = host.initial_data()
data["locked_name"] = locked_name ? locked_name : "No Target"
data["station_connected"] = station ? 1 : 0
data["hub_connected"] = hub ? 1 : 0
data["calibrated"] = hub ? hub.accurate : 0
data["teleporter_on"] = station ? station.engaged : 0
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "teleport_control.tmpl", "Teleport Control Console", 400, 500, state = state)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
teleport_control.tgui_interact(user)
/obj/machinery/computer/teleporter/verb/set_id(t as text)
set category = "Object"
@@ -211,14 +116,6 @@
id = t
return
/proc/find_loc(obj/R as obj)
if(!R) return null
var/turf/T = R.loc
while(!istype(T, /turf))
T = T.loc
if(!T || istype(T, /area)) return null
return T
//////
////// Root of all the machinery
//////

View File

@@ -0,0 +1,85 @@
/datum/tgui_module/teleport_control
name = "Teleporter Control"
tgui_id = "Teleporter"
var/locked_name = "Not Locked"
var/obj/item/locked = null
var/obj/machinery/teleport/station/station = null
var/obj/machinery/teleport/hub/hub = null
/datum/tgui_module/teleport_control/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
var/list/data = ..()
data["locked_name"] = locked_name || "No Target"
data["station_connected"] = !!station
data["hub_connected"] = !!hub
data["calibrated"] = hub?.accurate
data["teleporter_on"] = station?.engaged
return data
/datum/tgui_module/teleport_control/tgui_act(action, params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return TRUE
switch(action)
if("select_target")
var/list/L = list()
var/list/areaindex = list()
for(var/obj/item/device/radio/beacon/R in all_beacons)
var/turf/T = get_turf(R)
if(!T)
continue
if(!(T.z in using_map.player_levels))
continue
var/tmpname = T.loc.name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = R
for(var/obj/item/weapon/implant/tracking/I in all_tracking_implants)
if(!I.implanted || !ismob(I.loc))
continue
else
var/mob/M = I.loc
if(M.stat == 2)
if(M.timeofdeath + 6000 < world.time)
continue
var/turf/T = get_turf(M)
if(T)
continue
if(!(T in using_map.station_levels))
continue
var/tmpname = M.real_name
if(areaindex[tmpname])
tmpname = "[tmpname] ([++areaindex[tmpname]])"
else
areaindex[tmpname] = 1
L[tmpname] = I
var/desc = input("Please select a location to lock in.", "Locking Menu") in L|null
if(!desc)
return FALSE
if(tgui_status(usr, state) != STATUS_INTERACTIVE)
return FALSE
locked = L[desc]
locked_name = desc
return TRUE
if("test_fire")
station?.testfire()
return TRUE
if("toggle_on")
if(!station)
return FALSE
if(station.engaged)
station.disengage()
else
station.engage()
return TRUE

View File

@@ -1,44 +0,0 @@
<div class='block'>
<div class='item'>
<div class='itemLabelNarrow'>Target:</div>
<div>
{{:helper.link(data.locked_name, null, {'select_target' : 1}, null, null)}}
</div>
</div>
<div class='item'>
<div class='itemLabelNarrow'>Calibrated:</div>
<div>
{{:helper.link(data.calibrated ? 'Accurate' : 'Test Fire', data.calibrated ? 'check' : 'close', {'test_fire' : 1}, null, data.calibrated ? 'linkOn' : 'redButton')}}
</div>
</div>
<div class='item'>
<div class='itemLabelNarrow'>Teleporter:</div>
<div>
{{:helper.link(data.teleporter_on ? 'Online' : 'Offline', data.teleporter_on ? 'check' : 'close', {'toggle_on' : 1}, null, data.teleporter_on ? 'linkOn' : 'redButton')}}
</div>
</div>
<div class='item'>
<div class='itemLabelNarrow'>Station:</div>
<div>
{{if data.station_connected}}
Connected
{{else}}
Not Connected!
{{/if}}
</div>
</div>
<div class='item'>
<div class='itemLabelNarrow'>Hub:</div>
<div>
{{if data.hub_connected}}
Connected
{{else}}
Not Connected!
{{/if}}
</div>
</div>
</div>

View File

@@ -0,0 +1,55 @@
import { useBackend } from "../backend";
import { Button, LabeledList, Section } from "../components";
import { Window } from "../layouts";
export const Teleporter = (props, context) => {
const { act, data } = useBackend(context);
const {
locked_name,
station_connected,
hub_connected,
calibrated,
teleporter_on,
} = data;
return (
<Window width={300} height={200} resizable>
<Window.Content>
<Section>
<LabeledList>
<LabeledList.Item label="Target">
<Button
fluid
icon="bullseye"
onClick={() => act("select_target")}
content={locked_name} />
</LabeledList.Item>
<LabeledList.Item label="Calibrated">
<Button.Checkbox
fluid
checked={calibrated}
color={calibrated ? "good" : "bad"}
onClick={() => act("test_fire")}
content={calibrated ? "Accurate" : "Test Fire"} />
</LabeledList.Item>
<LabeledList.Item label="Teleporter">
<Button.Checkbox
fluid
checked={teleporter_on}
color={teleporter_on ? "good" : "bad"}
onClick={() => act("toggle_on")}
content={teleporter_on ? "Online" : "OFFLINE"} />
</LabeledList.Item>
<LabeledList.Item label="Station">
{station_connected ? "Connected" : "Not Connected"}
</LabeledList.Item>
<LabeledList.Item label="Hub">
{hub_connected ? "Connected" : "Not Connected"}
</LabeledList.Item>
</LabeledList>
</Section>
</Window.Content>
</Window>
);
};

File diff suppressed because one or more lines are too long

View File

@@ -3543,6 +3543,7 @@
#include "code\modules\tgui\modules\rcon.dm"
#include "code\modules\tgui\modules\shutoff_monitor.dm"
#include "code\modules\tgui\modules\supermatter_monitor.dm"
#include "code\modules\tgui\modules\teleporter.dm"
#include "code\modules\tgui\modules\ntos-only\cardmod.dm"
#include "code\modules\tgui\modules\ntos-only\configurator.dm"
#include "code\modules\tgui\modules\ntos-only\email.dm"