diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm
index d3eec4057a..e87de196d9 100644
--- a/code/game/machinery/requests_console.dm
+++ b/code/game/machinery/requests_console.dm
@@ -38,7 +38,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
// 0 = no new message
// 1 = normal priority
// 2 = high priority
- var/screen = RCS_MAINMENU
+ var/screen = RCS_VIEWMSGS
var/silent = 0 // set to 1 for it not to beep all the time
// var/hackState = 0
// 0 = not hacked
@@ -105,10 +105,16 @@ var/list/obj/machinery/requests_console/allConsoles = list()
if(..(user))
return
ui_interact(user)
+ tgui_interact(user)
-/obj/machinery/requests_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
- var/data[0]
+/obj/machinery/requests_console/tgui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ ui = new(user, src, "RequestConsole", "[department] Request Console")
+ ui.open()
+/obj/machinery/requests_console/tgui_data(mob/user)
+ var/list/data = ..()
data["department"] = department
data["screen"] = screen
data["message_log"] = message_log
@@ -122,93 +128,103 @@ var/list/obj/machinery/requests_console/allConsoles = list()
data["message"] = message
data["recipient"] = recipient
- data["priortiy"] = priority
+ data["priority"] = priority
data["msgStamped"] = msgStamped
data["msgVerified"] = msgVerified
data["announceAuth"] = announceAuth
+ return data
- ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
- if(!ui)
- ui = new(user, src, ui_key, "request_console.tmpl", "[department] Request Console", 520, 410)
- ui.set_initial_data(data)
- ui.open()
-
-/obj/machinery/requests_console/Topic(href, href_list)
- if(..()) return
- usr.set_machine(src)
+/obj/machinery/requests_console/tgui_act(action, list/params)
+ if(..())
+ return TRUE
+
add_fingerprint(usr)
+
+ switch(action)
+ if("write")
+ if(reject_bad_text(params["write"]))
+ recipient = params["write"] //write contains the string of the receiving department's name
- if(reject_bad_text(href_list["write"]))
- recipient = href_list["write"] //write contains the string of the receiving department's name
+ var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
+ if(new_message)
+ message = new_message
+ screen = RCS_MESSAUTH
+ switch(params["priority"])
+ if(1)
+ priority = 1
+ if(2)
+ priority = 2
+ else
+ priority = 0
+ else
+ reset_message(1)
+ . = TRUE
- var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
- if(new_message)
- message = new_message
- screen = RCS_MESSAUTH
- switch(href_list["priority"])
- if("1") priority = 1
- if("2") priority = 2
- else priority = 0
- else
+ if("writeAnnouncement")
+ var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
+ if(new_message)
+ message = new_message
+ else
+ reset_message(1)
+ . = TRUE
+
+ if("sendAnnouncement")
+ if(!announcementConsole)
+ return FALSE
+ announcement.Announce(message, msg_sanitized = 1)
reset_message(1)
+ . = TRUE
- if(href_list["writeAnnouncement"])
- var/new_message = sanitize(input("Write your message:", "Awaiting Input", ""))
- if(new_message)
- message = new_message
- else
- reset_message(1)
+ if("department")
+ if(!message)
+ return FALSE
+ var/log_msg = message
+ var/pass = 0
+ screen = RCS_SENTFAIL
+ for(var/obj/machinery/message_server/MS in machines)
+ if(!MS.active)
+ continue
+ MS.send_rc_message(ckey(params["department"]), department, log_msg, msgStamped, msgVerified, priority)
+ pass = 1
+ if(pass)
+ screen = RCS_SENTPASS
+ message_log += list(list("Message sent to [recipient]", "[message]"))
+ else
+ audible_message(text("[bicon(src)] *The Requests Console beeps: 'NOTICE: No server detected!'"),,4)
+ . = TRUE
- if(href_list["sendAnnouncement"])
- if(!announcementConsole) return
- announcement.Announce(message, msg_sanitized = 1)
- reset_message(1)
+ //Handle printing
+ if("print")
+ var/msg = message_log[text2num(params["print"])];
+ if(msg)
+ msg = "[msg[1]]:
[msg[2]]"
+ msg = replacetext(msg, "
", "\n")
+ msg = strip_html_properly(msg)
+ var/obj/item/weapon/paper/R = new(src.loc)
+ R.name = "[department] Message"
+ R.info = "
[department] Requests Console
[msg]
"
+ . = TRUE
- if(href_list["department"] && message)
- var/log_msg = message
- var/pass = 0
- screen = RCS_SENTFAIL
- for (var/obj/machinery/message_server/MS in machines)
- if(!MS.active) continue
- MS.send_rc_message(ckey(href_list["department"]),department,log_msg,msgStamped,msgVerified,priority)
- pass = 1
- if(pass)
- screen = RCS_SENTPASS
- message_log += "Message sent to [recipient]
[message]"
- else
- audible_message(text("[bicon(src)] *The Requests Console beeps: 'NOTICE: No server detected!'"),,4)
+ //Handle screen switching
+ if("setScreen")
+ var/tempScreen = text2num(params["setScreen"])
+ if(tempScreen == RCS_ANNOUNCE && !announcementConsole)
+ return
+ if(tempScreen == RCS_VIEWMSGS)
+ for (var/obj/machinery/requests_console/Console in allConsoles)
+ if(Console.department == department)
+ Console.newmessagepriority = 0
+ Console.icon_state = "req_comp0"
+ Console.set_light(1)
+ if(tempScreen == RCS_MAINMENU)
+ reset_message()
+ screen = tempScreen
+ . = TRUE
- //Handle printing
- if (href_list["print"])
- var/msg = message_log[text2num(href_list["print"])];
- if(msg)
- msg = replacetext(msg, "
", "\n")
- msg = strip_html_properly(msg)
- var/obj/item/weapon/paper/R = new(src.loc)
- R.name = "[department] Message"
- R.info = "[department] Requests Console
[msg]
"
-
- //Handle screen switching
- if(href_list["setScreen"])
- var/tempScreen = text2num(href_list["setScreen"])
- if(tempScreen == RCS_ANNOUNCE && !announcementConsole)
- return
- if(tempScreen == RCS_VIEWMSGS)
- for (var/obj/machinery/requests_console/Console in allConsoles)
- if(Console.department == department)
- Console.newmessagepriority = 0
- Console.icon_state = "req_comp0"
- Console.set_light(1)
- if(tempScreen == RCS_MAINMENU)
- reset_message()
- screen = tempScreen
-
- //Handle silencing the console
- if(href_list["toggleSilent"])
- silent = !silent
-
- updateUsrDialog()
- return
+ //Handle silencing the console
+ if("toggleSilent")
+ silent = !silent
+ . = TRUE
//err... hacking code, which has no reason for existing... but anyway... it was once supposed to unlock priority 3 messaging on that console (EXTREME priority...), but the code for that was removed.
/obj/machinery/requests_console/attackby(var/obj/item/weapon/O as obj, var/mob/user as mob)
@@ -238,7 +254,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
if(screen == RCS_MESSAUTH)
var/obj/item/weapon/card/id/T = O
msgVerified = text("Verified by [T.registered_name] ([T.assignment])")
- updateUsrDialog()
+ SStgui.update_uis(src)
if(screen == RCS_ANNOUNCE)
var/obj/item/weapon/card/id/ID = O
if(access_RC_announce in ID.GetAccess())
@@ -247,13 +263,13 @@ var/list/obj/machinery/requests_console/allConsoles = list()
else
reset_message()
to_chat(user, "You are not authorized to send announcements.")
- updateUsrDialog()
+ SStgui.update_uis(src)
if(istype(O, /obj/item/weapon/stamp))
if(inoperable(MAINT)) return
if(screen == RCS_MESSAUTH)
var/obj/item/weapon/stamp/T = O
msgStamped = text("Stamped with the [T.name]")
- updateUsrDialog()
+ SStgui.update_uis(src)
return
/obj/machinery/requests_console/proc/reset_message(var/mainmenu = 0)
diff --git a/code/modules/research/message_server.dm b/code/modules/research/message_server.dm
index bbcda60927..81f888155d 100644
--- a/code/modules/research/message_server.dm
+++ b/code/modules/research/message_server.dm
@@ -113,15 +113,15 @@ var/global/list/obj/machinery/message_server/message_servers = list()
/obj/machinery/message_server/proc/send_rc_message(var/recipient = "",var/sender = "",var/message = "",var/stamp = "", var/id_auth = "", var/priority = 1)
rc_msgs += new/datum/data_rc_msg(recipient,sender,message,stamp,id_auth)
- var/authmsg = "[message]
"
+ var/authmsg = "[message]\n"
if (id_auth)
- authmsg += "[id_auth]
"
+ authmsg += "([id_auth])\n"
if (stamp)
- authmsg += "[stamp]
"
+ authmsg += "([stamp])\n"
for (var/obj/machinery/requests_console/Console in allConsoles)
if (ckey(Console.department) == ckey(recipient))
if(Console.inoperable())
- Console.message_log += "Message lost due to console failure.
Please contact [station_name()] system adminsitrator or AI for technical assistance.
"
+ Console.message_log += list(list("Message lost due to console failure.","Please contact [station_name()] system adminsitrator or AI for technical assistance."))
continue
if(Console.newmessagepriority < priority)
Console.newmessagepriority = priority
@@ -131,12 +131,12 @@ var/global/list/obj/machinery/message_server/message_servers = list()
if(!Console.silent)
playsound(Console, 'sound/machines/twobeep.ogg', 50, 1)
Console.audible_message(text("[bicon(Console)] *The Requests Console beeps: 'PRIORITY Alert in [sender]'"),,5)
- Console.message_log += "High Priority message from [sender]
[authmsg]"
+ Console.message_log += list(list("High Priority message from [sender]", "[authmsg]"))
else
if(!Console.silent)
playsound(Console, 'sound/machines/twobeep.ogg', 50, 1)
Console.audible_message(text("[bicon(Console)] *The Requests Console beeps: 'Message from [sender]'"),,4)
- Console.message_log += "Message from [sender]
[authmsg]"
+ Console.message_log += list(list("Message from [sender]", "[authmsg]"))
Console.set_light(2)
diff --git a/code/modules/tgui/external.dm b/code/modules/tgui/external.dm
index 19f039869e..bb39c721d0 100644
--- a/code/modules/tgui/external.dm
+++ b/code/modules/tgui/external.dm
@@ -141,6 +141,26 @@
*/
/datum/proc/tgui_close(mob/user)
+/**
+ * verb
+ *
+ * Used by a client to fix broken TGUI windows caused by opening a UI window before assets load.
+ * Probably not very performant and forcibly destroys a bunch of windows, so it has some warnings attached.
+ * Conveniently, also allows devs to force a dev server reattach without relogging, since it yeets windows.
+ */
+/client/verb/tgui_fix_white()
+ set desc = "Only use this if you have a broken TGUI window occupying your screen!"
+ set name = "Fix TGUI"
+ set category = "OOC"
+
+ if(alert(src, "Only use this verb if you have a white TGUI window stuck on your screen.", "Fix TGUI", "Continue", "Nevermind") != "Continue")
+ return
+
+ SStgui.close_user_uis(mob)
+ if(alert(src, "Did that fix the problem?", "Fix TGUI", "Yes", "No") == "No")
+ SStgui.force_close_all_windows(mob)
+ alert(src, "UIs should be fixed now. If not, please cry to your nearest coder.", "Fix TGUI")
+
/**
* verb
*
diff --git a/nano/templates/request_console.tmpl b/nano/templates/request_console.tmpl
deleted file mode 100644
index 5750bbe2b0..0000000000
--- a/nano/templates/request_console.tmpl
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-{{if data.screen == 1}}
- Request assistance from another department.
-
- {{for data.assist_dept}}
- {{if value != data.department}}
-
- {{:value}} - |
- {{:helper.link('Message', null, { 'write' : value , 'priority' : 1 })}} |
- {{:helper.link('High Priority', null, { 'write' : value , 'priority' : 2 })}} |
-
- {{/if}}
- {{empty}}
- There are no available departments to request assistance from. |
- {{/for}}
-
- {{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
-{{else data.screen == 2}}
- Request supplies from another department.
-
- {{for data.supply_dept}}
- {{if value != data.department}}
-
- {{:value}} - |
- {{:helper.link('Message', null, { 'write' : value , 'priority' : 1 })}} |
- {{:helper.link('High Priority', null, { 'write' : value , 'priority' : 2 })}} |
-
- {{/if}}
- {{empty}}
- There are no available departments to request supplies from. |
- {{/for}}
-
- {{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
-{{else data.screen == 3}}
- Relay info to another department.
-
- {{for data.info_dept}}
- {{if value != data.department}}
-
- {{:value}} - |
- {{:helper.link('Message', null, { 'write' : value , 'priority' : 1 })}} |
- {{:helper.link('High Priority', null, { 'write' : value , 'priority' : 2 })}} |
-
- {{/if}}
- {{empty}}
- There are no available departments to relay information to. |
- {{/for}}
-
- {{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
-{{else data.screen == 4}}
- Message sent successfully.
- {{:helper.link('Continue', 'arrowthick-1-e', { 'setScreen' : 0 })}}
-{{else data.screen == 5}}
- An Error occured. Message not sent.
- {{:helper.link('Continue', 'arrowthick-1-e', { 'setScreen' : 0 })}}
-{{else data.screen == 6}}
-
- {{for data.message_log}}
-
{{:value}}
-
{{:helper.link('Print', null, { 'print' : index + 1 })}}
- {{empty}}
-
No messages have been received.
- {{/for}}
-
- {{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
-{{else data.screen == 7}}
- Message Authentication
-
-
Message for {{:data.recipient}}: {{:data.message}}
-
Validated by: {{:data.msgVerified}}
-
Stamped by: {{:data.msgStamped}}
-
-
- {{:helper.link('Send Message', 'arrowthick-1-e', { 'department' : data.recipient })}}
- {{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
-
-{{else data.screen == 8}}
- Station wide announcement
- Message: {{:data.message}} {{:helper.link('Write Message', 'pencil', { 'writeAnnouncement' : 1 })}}
-
- {{if data.announceAuth}}
- ID verified. Authentication accepted.
- {{else}}
- Swipe your ID card to authenticate yourself.
- {{/if}}
-
-
- {{:helper.link('Announce', 'signal-diag', { 'sendAnnouncement' : 1 }, (data.announceAuth && data.message) ? null : 'disabled' )}}
- {{:helper.link('Back', 'arrowreturnthick-1-w', { 'setScreen' : 0 })}}
-
-{{else}}
- {{if data.newmessagepriority == 1}}
- There are new messages
- {{else data.newmessagepriority == 2}}
- NEW PRIORITY MESSAGES
- {{/if}}
- {{:helper.link('View Messages', data.newmessagepriority ? 'mail-closed' : 'mail-open', { 'setScreen' : 6 })}}
-
- {{:helper.link('Request Assistance', 'gear', { 'setScreen' : 1 })}}
- {{:helper.link('Request Supplies', 'gear', { 'setScreen' : 2 })}}
- {{:helper.link('Relay Anonymous Information', 'gear', { 'setScreen' : 3})}}
-
- {{if data.announcementConsole}}
- {{:helper.link('Send Station-wide Announcement', 'signal-diag', { 'setScreen' : 8})}}
-
- {{/if}}
- {{:helper.link(data.silent ? 'Speaker OFF' : 'Speaker ON', data.silent ? 'volume-off' : 'volume-on', { 'toggleSilent' : 1})}}
-{{/if}}
\ No newline at end of file
diff --git a/tgui/packages/tgui/interfaces/RequestConsole.js b/tgui/packages/tgui/interfaces/RequestConsole.js
new file mode 100644
index 0000000000..04b7fb402c
--- /dev/null
+++ b/tgui/packages/tgui/interfaces/RequestConsole.js
@@ -0,0 +1,332 @@
+import { decodeHtmlEntities } from 'common/string';
+import { Fragment } from 'inferno';
+import { useBackend } from "../backend";
+import { Box, Button, Flex, Icon, LabeledList, ProgressBar, Section, Tabs } from "../components";
+import { Window } from "../layouts";
+
+const RCS_MAINMENU = 0; // Settings menu
+const RCS_RQASSIST = 1; // Request supplies
+const RCS_RQSUPPLY = 2; // Request assistance
+const RCS_SENDINFO = 3; // Relay information
+const RCS_SENTPASS = 4; // Message sent successfully
+const RCS_SENTFAIL = 5; // Message sent unsuccessfully
+const RCS_VIEWMSGS = 6; // View messages
+const RCS_MESSAUTH = 7; // Authentication before sending
+const RCS_ANNOUNCE = 8; // Send announcement
+
+const RequestConsoleSettings = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ silent,
+ } = data;
+ return (
+
+
+
+ );
+};
+
+const RequestConsoleSupplies = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ department,
+ supply_dept,
+ } = data;
+ return (
+
+ );
+};
+
+const RequestConsoleAssistance = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ department,
+ assist_dept,
+ } = data;
+ return (
+
+ );
+};
+
+const RequestConsoleRelay = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ department,
+ info_dept,
+ } = data;
+ return (
+
+ );
+};
+
+const RequestConsoleSendMenu = (props, context) => {
+ const { act } = useBackend(context);
+ const {
+ dept_list,
+ department,
+ } = props;
+ return (
+
+ {dept_list.sort().map(dept => dept !== department && (
+
+
+
+
+ } />
+ ) || null)}
+
+ );
+};
+
+const RequestConsoleSendPass = (props, context) => {
+ const { act, data } = useBackend(context);
+ return (
+
+
+ Message Sent Successfully
+
+
+
+
+
+ );
+};
+
+const RequestConsoleSendFail = (props, context) => {
+ const { act, data } = useBackend(context);
+ return (
+
+
+ An error occured. Message Not Sent.
+
+
+
+
+
+ );
+};
+
+const RequestConsoleViewMessages = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ message_log,
+ } = data;
+ return (
+
+ {(message_log.length && message_log.map((msg, i) => (
+ act("print", { print: i + 1 })}>
+ Print
+
+ }>
+ {decodeHtmlEntities(msg[1])}
+
+ ))) || (
+
+ No messages.
+
+ )}
+
+ );
+};
+
+const RequestConsoleMessageAuth = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ message,
+ recipient,
+ priority,
+ msgStamped,
+ msgVerified,
+ } = data;
+ return (
+
+
+
+ {message}
+
+
+ {priority === 2 ? "High Priority" : (priority === 1 ? "Normal Priority" : "Unknown")}
+
+
+ {decodeHtmlEntities(msgVerified) || "No Validation"}
+
+
+ {decodeHtmlEntities(msgStamped) || "No Stamp"}
+
+
+
+
+
+ );
+};
+
+const RequestConsoleAnnounce = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ department,
+ screen,
+ message_log,
+ newmessagepriority,
+ silent,
+ announcementConsole,
+ assist_dept,
+ supply_dept,
+ info_dept,
+ message,
+ recipient,
+ priority,
+ msgStamped,
+ msgVerified,
+ announceAuth,
+ } = data;
+ return (
+
+ {announceAuth && (
+
+
+ ID Verified. Authentication Accepted.
+
+ act("writeAnnouncement")}>
+ Edit
+
+ }>
+ {message || "No Message"}
+
+
+ ) || (
+
+ Swipe your ID card to authenticate yourself.
+
+ )}
+
+
+
+ );
+};
+
+let screenToTemplate = {};
+screenToTemplate[RCS_MAINMENU] = RequestConsoleSettings;
+screenToTemplate[RCS_RQASSIST] = RequestConsoleAssistance;
+screenToTemplate[RCS_RQSUPPLY] = RequestConsoleSupplies;
+screenToTemplate[RCS_SENDINFO] = RequestConsoleRelay;
+screenToTemplate[RCS_SENTPASS] = RequestConsoleSendPass;
+screenToTemplate[RCS_SENTFAIL] = RequestConsoleSendFail;
+screenToTemplate[RCS_VIEWMSGS] = RequestConsoleViewMessages;
+screenToTemplate[RCS_MESSAUTH] = RequestConsoleMessageAuth;
+screenToTemplate[RCS_ANNOUNCE] = RequestConsoleAnnounce;
+
+export const RequestConsole = (props, context) => {
+ const { act, data } = useBackend(context);
+ const {
+ screen,
+ newmessagepriority,
+ announcementConsole,
+ } = data;
+
+ let BodyElement = screenToTemplate[screen];
+
+ return (
+
+
+
+ act("setScreen", { setScreen: RCS_VIEWMSGS })}
+ icon="envelope-open-text">
+ Messages
+
+ act("setScreen", { setScreen: RCS_RQASSIST })}
+ icon="share-square">
+ Assistance
+
+ act("setScreen", { setScreen: RCS_RQSUPPLY })}
+ icon="share-square">
+ Supplies
+
+ act("setScreen", { setScreen: RCS_SENDINFO })}
+ icon="share-square-o">
+ Report
+
+ {announcementConsole && (
+ act("setScreen", { setScreen: RCS_ANNOUNCE })}
+ icon="volume-up">
+ Announce
+
+ ) || null}
+ act("setScreen", { setScreen: RCS_MAINMENU })}
+ icon="cog" />
+
+ {newmessagepriority && (
+ 1 ? "NEW PRIORITY MESSAGES" : "There are new messages!"}
+ color={newmessagepriority > 1 ? "bad" : "average"} bold={newmessagepriority > 1} />
+ ) || null}
+
+
+
+ );
+};
\ No newline at end of file