From 1fc73700c5551ff96fb0f11e4ab198521a9a968d Mon Sep 17 00:00:00 2001
From: Letter N <24603524+LetterN@users.noreply.github.com>
Date: Mon, 1 Jun 2020 06:22:40 +0800
Subject: [PATCH] Telecomms TGUI (#12145)
* aaaaaa
* branch hell
* time to sync
* build
* adds more """functionality""" for telemonitor
* messaging pda thing
* bakes tgui
* someone didn't finish the code for req. consoles
* go use [TELECOMM STUFF].on, it's better
* build stuff
* a
* interface for teleinteraction
* tgui
* ready for launch - not tested yet
* build
* built ui
* bitflag readability and bye oldcode!
* bepis
* build ui
---
code/game/machinery/requests_console.dm | 476 ++++++------
.../telecomms/computers/logbrowser.dm | 323 ++++----
.../machinery/telecomms/computers/message.dm | 697 ++++++++----------
.../telecomms/computers/telemonitor.dm | 180 ++---
.../telecomms/machine_interactions.dm | 453 ++++++------
code/game/machinery/telecomms/machines/bus.dm | 7 +-
.../telecomms/machines/message_server.dm | 15 +-
.../machinery/telecomms/machines/server.dm | 2 +-
.../machinery/telecomms/telecomunications.dm | 16 +-
.../tgui/interfaces/TelecommsInteraction.js | 238 ++++++
.../tgui/interfaces/TelecommsLogBrowser.js | 174 +++++
.../tgui/interfaces/TelecommsMonitor.js | 221 ++++++
.../tgui/interfaces/TelecommsPDALog.js | 420 +++++++++++
tgui-next/packages/tgui/public/tgui.bundle.js | 4 +-
tgui-next/packages/tgui/routes.js | 23 +
15 files changed, 2105 insertions(+), 1144 deletions(-)
create mode 100644 tgui-next/packages/tgui/interfaces/TelecommsInteraction.js
create mode 100644 tgui-next/packages/tgui/interfaces/TelecommsLogBrowser.js
create mode 100644 tgui-next/packages/tgui/interfaces/TelecommsMonitor.js
create mode 100644 tgui-next/packages/tgui/interfaces/TelecommsPDALog.js
diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm
index d55faf2343..e1f55da551 100644
--- a/code/game/machinery/requests_console.dm
+++ b/code/game/machinery/requests_console.dm
@@ -9,7 +9,7 @@ GLOBAL_LIST_EMPTY(allConsoles)
#define NO_NEW_MESSAGE 0
#define NORMAL_MESSAGE_PRIORITY 1
#define HIGH_MESSAGE_PRIORITY 2
-#define EXTREME_MESSAGE_PRIORITY 3 // not implemented, will probably require some hacking... everything needs to have a hidden feature in this game.
+#define EXTREME_MESSAGE_PRIORITY 3 // is implimented, does require hacking. everything needs to have a hidden feature in this game.
/obj/machinery/requests_console
name = "requests console"
@@ -48,9 +48,9 @@ GLOBAL_LIST_EMPTY(allConsoles)
var/announceAuth = FALSE //Will be set to 1 when you authenticate yourself for announcements
var/msgVerified = "" //Will contain the name of the person who verified it
var/msgStamped = "" //If a message is stamped, this will contain the stamp name
- var/message = "";
- var/dpt = ""; //the department which will be receiving the message
- var/priority = -1 ; //Priority of the message being sent
+ var/message = ""
+ var/dpt = "" //the department which will be receiving the message
+ var/priority = NORMAL_MESSAGE_PRIORITY //Priority of the message being sent. why is the default -1??
var/obj/item/radio/Radio
var/emergency //If an emergency has been called by this device. Acts as both a cooldown and lets the responder know where it the emergency was triggered from
var/receive_ore_updates = FALSE //If ore redemption machines will send an update when it receives new ores.
@@ -62,16 +62,17 @@ GLOBAL_LIST_EMPTY(allConsoles)
update_icon()
/obj/machinery/requests_console/update_icon_state()
- if(stat & NOPOWER)
+ if(CHECK_BITFIELD(stat, NOPOWER))
set_light(0)
else
- set_light(1.4,0.7,"#34D352")//green light
+ set_light(1.4, 0.7, "#34D352")//green light
+
if(open)
if(!hackState)
icon_state="req_comp_open"
else
icon_state="req_comp_rewired"
- else if(stat & NOPOWER)
+ else if(CHECK_BITFIELD(stat, NOPOWER))
if(icon_state != "req_comp_off")
icon_state = "req_comp_off"
else
@@ -122,7 +123,7 @@ GLOBAL_LIST_EMPTY(allConsoles)
GLOB.req_console_information += department
Radio = new /obj/item/radio(src)
- Radio.listening = 0
+ Radio.listening = FALSE
/obj/machinery/requests_console/Destroy()
QDEL_NULL(Radio)
@@ -131,164 +132,173 @@ GLOBAL_LIST_EMPTY(allConsoles)
/obj/machinery/requests_console/ui_interact(mob/user)
. = ..()
+ if(open) //no.
+ return
+
var/dat = ""
- if(!open)
- switch(screen)
- if(1) //req. assistance
- dat += "Which department do you need assistance from?
"
- dat += "
| [dpt] | " - dat += "Normal High" - if(hackState) - dat += "EXTREME" - dat += " | " - dat += "
| [dpt] | " + dat += "" + dat += "Normal" + dat += "High" + if(hackState) + dat += "EXTREME" + dat += " | " + dat += "
| [dpt] | " - dat += "Normal High" - if(hackState) - dat += "EXTREME" - dat += " | " - dat += "
| [dpt] | " - dat += "Normal High" - if(hackState) - dat += "EXTREME" - dat += " | " - dat += "
| [dpt] | " + dat += "" + dat += "Normal" + dat += "High" + if(hackState) + dat += "EXTREME" + dat += " | " + dat += "
| X | Sender | Recipient | Message |
|---|---|---|---|
| [pda.sender] | [pda.recipient] | [pda.message][pda.picture ? " (Photo)":""] |
| Sender | -Sender's Job | -Recipient | -Message |
| [customsender] | -[customjob] | -[customrecepient ? customrecepient.owner : "NONE"] | -[custommessage] |
| X | Sending Dep. | Receiving Dep. | -Message | Stamp | ID Auth. | Priority. |
|---|---|---|---|---|---|---|
| [rc.send_dpt] | -[rc.rec_dpt] | [rc.message] | [rc.stamp] | [rc.id_auth] | [rc.priority] |
" \
- + "", "window=pdaphoto;size=[picture.psize_x]x[picture.psize_y];can-close=true")
+
+ M << browse_rsc(picture.picture_image, "pda_photo.png")
+
+ var/dat = ""
+
+ var/datum/browser/popup = new(M, "pdaphoto", "PDA Photo", picture.psize_x, picture.psize_y)
+ popup.set_content(dat)
+ popup.open()
onclose(M, "pdaphoto")
/datum/data_rc_msg
diff --git a/code/game/machinery/telecomms/machines/server.dm b/code/game/machinery/telecomms/machines/server.dm
index ad4599b4c3..6f80cfbf0e 100644
--- a/code/game/machinery/telecomms/machines/server.dm
+++ b/code/game/machinery/telecomms/machines/server.dm
@@ -33,7 +33,7 @@
totaltraffic += traffic // add current traffic to total traffic
// Delete particularly old logs
- if (log_entries.len >= 400)
+ if(LAZYLEN(log_entries) >= 400) //[list].len is not safe
log_entries.Cut(1, 2)
var/datum/comm_log_entry/log = new
diff --git a/code/game/machinery/telecomms/telecomunications.dm b/code/game/machinery/telecomms/telecomunications.dm
index d21edffea1..e1b345f507 100644
--- a/code/game/machinery/telecomms/telecomunications.dm
+++ b/code/game/machinery/telecomms/telecomunications.dm
@@ -117,9 +117,9 @@ GLOBAL_LIST_EMPTY(telecomms_list)
icon_state = "[initial(icon_state)]_off"
/obj/machinery/telecomms/proc/update_power()
-
if(toggled)
- if(stat & (BROKEN|NOPOWER|EMPED)) // if powered, on. if not powered, off. if too damaged, off
+ // if powered, on. if not powered, off. if too damaged, off
+ if(CHECK_BITFIELD(stat, (BROKEN | NOPOWER | EMPED)))
on = FALSE
else
on = TRUE
@@ -137,11 +137,11 @@ GLOBAL_LIST_EMPTY(telecomms_list)
/obj/machinery/telecomms/emp_act(severity)
. = ..()
- if(. & EMP_PROTECT_SELF)
+ if(CHECK_BITFIELD(., EMP_PROTECT_SELF))
return
- if(prob(100/severity))
- if(!(stat & EMPED))
- stat |= EMPED
- var/duration = (300 * 10)/severity
+ if(prob(100 / severity))
+ if(!CHECK_BITFIELD(stat, EMPED))
+ ENABLE_BITFIELD(stat, EMPED)
+ var/duration = (300 * 10) / severity
spawn(rand(duration - 20, duration + 20)) // Takes a long time for the machines to reboot.
- stat &= ~EMPED
+ DISABLE_BITFIELD(stat, EMPED)
diff --git a/tgui-next/packages/tgui/interfaces/TelecommsInteraction.js b/tgui-next/packages/tgui/interfaces/TelecommsInteraction.js
new file mode 100644
index 0000000000..a67bfdf987
--- /dev/null
+++ b/tgui-next/packages/tgui/interfaces/TelecommsInteraction.js
@@ -0,0 +1,238 @@
+import { Fragment } from 'inferno';
+import { useBackend } from '../backend';
+import { toFixed } from 'common/math';
+import { RADIO_CHANNELS } from '../constants';
+import { Button, LabeledList, NumberInput, NoticeBox, Section, Input } from '../components';
+
+export const TeleInteract = props => {
+ const { act, data } = useBackend(props);
+ const {
+ notice = "",
+ multitool = false,
+ multitool_buf = null,
+ machine = null,
+ links = [],
+ freq_listening = [],
+ } = data;
+ const {
+ power = false,
+ id = "NULL",
+ network,
+ prefab = false,
+ hidden = false,
+ isrelay = false,
+ isbus = false,
+ } = machine;
+ return (
+