From c336a7faf8358339b69c5d69f55a3a7f0340461c Mon Sep 17 00:00:00 2001 From: FeudeyTF <72273449+FeudeyTF@users.noreply.github.com> Date: Sun, 28 May 2023 23:00:05 +0300 Subject: [PATCH] UI updating of pda message console and telecommuncations monitor. (#75460) ## About The Pull Request Updating the UI of the server communication viewing console and the pda message monitoring console. I have kept all the functions of previous versions of consoles. ### **Consoles before:** ![MessageBefore](https://github.com/tgstation/tgstation/assets/72273449/c5671a4a-8ace-4c90-a3ef-a58cec8bf228) ![TelecommsBefore](https://github.com/tgstation/tgstation/assets/72273449/85fc6bdc-7c12-424e-9677-b4c9f18153ed) ### **Console after:** ![MessageAfter](https://github.com/tgstation/tgstation/assets/72273449/d78e2ce8-a6d1-4882-8fca-49477add3003) ![TelecommsAfter](https://github.com/tgstation/tgstation/assets/72273449/a4ded23a-b1db-4dda-9e9d-1433a2ba7115) ## Why It's Good For The Game The interface has become more understandable, and most importantly beautiful (in my opinion), and has also become more canonical. ## Changelog :cl: FeudeyTF code: Updated the UI of the console for viewing message logs and console for view server communications /:cl: --------- Co-authored-by: unknown <777@U01.gorchakov.local> Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- .../machinery/telecomms/computers/message.dm | 574 ++++++------------ .../telecomms/computers/telemonitor.dm | 192 +++--- .../tgui/interfaces/MessageMonitor.tsx | 380 ++++++++++++ .../tgui/interfaces/TelecommsMonitor.tsx | 164 +++++ 4 files changed, 826 insertions(+), 484 deletions(-) create mode 100644 tgui/packages/tgui/interfaces/MessageMonitor.tsx create mode 100644 tgui/packages/tgui/interfaces/TelecommsMonitor.tsx diff --git a/code/game/machinery/telecomms/computers/message.dm b/code/game/machinery/telecomms/computers/message.dm index e69b66711628..72a5bd3a7f92 100644 --- a/code/game/machinery/telecomms/computers/message.dm +++ b/code/game/machinery/telecomms/computers/message.dm @@ -7,39 +7,29 @@ #define MSG_MON_SCREEN_MAIN 0 #define MSG_MON_SCREEN_LOGS 1 -#define MSG_MON_SCREEN_HACKED 2 -#define MSG_MON_SCREEN_CUSTOM_MSG 3 -#define MSG_MON_SCREEN_REQUEST_LOGS 4 +#define MSG_MON_SCREEN_REQUEST_LOGS 2 +#define MSG_MON_SCREEN_HACKED 3 -// The monitor itself. /obj/machinery/computer/message_monitor name = "message monitor console" desc = "Used to monitor the crew's PDA messages, as well as request console messages." icon_screen = "comm_logs" circuit = /obj/item/circuitboard/computer/message_monitor light_color = LIGHT_COLOR_GREEN - //Server linked to. + /// Server linked to. var/obj/machinery/telecomms/message_server/linkedServer = null - //Sparks effect - For emag + /// Sparks effect - For emag var/datum/effect_system/spark_spread/spark_system - //Messages - Saves me time if I want to change something. - var/noserver = "ALERT: No server detected." - var/incorrectkey = "ALERT: Incorrect decryption key!" - var/defaultmsg = "Welcome. Please select an option." - var/rebootmsg = "%$&(£: Critical %$$@ Error // !RestArting! - ?pLeaSe wAit!" - //Computer properties + /// Computer properties var/screen = MSG_MON_SCREEN_MAIN // 0 = Main menu, 1 = Message Logs, 2 = Hacked screen, 3 = Custom Message - var/hacking = FALSE // Is it being hacked into by the AI/Cyborg - var/message = "System bootup complete. Please select an option." // The message that shows on the main menu. + var/message = "System bootup complete. Please select an option." // The message that shows on the main menu. var/auth = FALSE // Are they authenticated? - var/optioncount = 7 - // Custom Message Properties - var/customsender = "System Administrator" - var/customrecepient = null - var/customjob = "Admin" - var/custommessage = "This is a test, please ignore." - - + /// Error, Success & Notice messages + var/error_message = "" + var/notice_message = "" + var/success_message = "" + /// Decrypt password + var/password = "" /obj/machinery/computer/message_monitor/screwdriver_act(mob/living/user, obj/item/I) if(obj_flags & EMAGGED) @@ -60,11 +50,19 @@ // Will help make emagging the console not so easy to get away with. monitor_key_paper.add_raw_text("

£%@%(*$%&(£&?*(%&£/{}") var/time = 100 * length(linkedServer.decryptkey) - addtimer(CALLBACK(src, PROC_REF(UnmagConsole)), time) - message = rebootmsg + addtimer(CALLBACK(src, PROC_REF(unemag_console)), time) + error_message = "%$&(£: Critical %$$@ Error // !RestArting! - ?pLeaSe wAit!" + linkedServer.toggled = FALSE else to_chat(user, span_notice("A no server error appears on the screen.")) +/// Remove the emag effect from the console +/obj/machinery/computer/message_monitor/proc/unemag_console() + screen = MSG_MON_SCREEN_MAIN + linkedServer.toggled = TRUE + error_message = "" + obj_flags &= ~EMAGGED + /obj/machinery/computer/message_monitor/Initialize(mapload) ..() spark_system = new @@ -74,398 +72,206 @@ /obj/machinery/computer/message_monitor/LateInitialize() //Is the server isn't linked to a server, and there's a server available, default it to the first one in the list. if(!linkedServer) - for(var/obj/machinery/telecomms/message_server/S in GLOB.telecomms_list) - linkedServer = S + for(var/obj/machinery/telecomms/message_server/message_server in GLOB.telecomms_list) + linkedServer = message_server break /obj/machinery/computer/message_monitor/Destroy() GLOB.telecomms_list -= src + linkedServer = null return ..() -/obj/machinery/computer/message_monitor/ui_interact(mob/living/user) - . = ..() - //If the computer is being hacked or is emagged, display the reboot message. - if(hacking || (obj_flags & EMAGGED)) - message = rebootmsg - var/dat = "
" - - if(auth) - dat += "

\[Authenticated\] /" - dat += " Server Power: [linkedServer?.on ? "\[On\]":"\[Off\]"]

" - else - dat += "

\[Unauthenticated\] /" - dat += " Server Power: [linkedServer?.on ? "\[On\]":"\[Off\]"]

" - - if(hacking || (obj_flags & EMAGGED)) - screen = MSG_MON_SCREEN_HACKED - else if(!auth || LINKED_SERVER_NONRESPONSIVE) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - screen = MSG_MON_SCREEN_MAIN +/obj/machinery/computer/message_monitor/ui_data(mob/user) + var/list/data = list( + "screen" = screen, + "error_message" = error_message, + "notice_message" = notice_message, + "success_message" = success_message, + "auth" = auth, + "server_status" = !LINKED_SERVER_NONRESPONSIVE, + ) switch(screen) - //Main menu if(MSG_MON_SCREEN_MAIN) - // = TAB - var/i = 0 - dat += "
[++i]. Link To A Server
" - if(auth) - if(LINKED_SERVER_NONRESPONSIVE) - dat += "
ERROR: Server not found!
" - else - dat += "
[++i]. View Message Logs
" - dat += "
[++i]. View Request Console Logs
" - dat += "
[++i]. Clear Message Logs
" - dat += "
[++i]. Clear Request Console Logs
" - dat += "
[++i]. Set Custom Key
" - dat += "
[++i]. Send Admin Message
" - else - for(var/n = ++i; n <= optioncount; n++) - dat += "
[n]. ---------------
" - var/mob/living/silicon/S = usr - if(istype(S) && S.hack_software) - //Malf/Traitor AIs can bruteforce into the system to gain the Key. - dat += "
*&@#. Bruteforce Key
" - else - dat += "
" - - //Bottom message - if(!auth) - dat += "

[span_notice("Please authenticate with the server in order to show additional options.")]" - else - dat += "

[span_warning("Reg, #514 forbids sending messages to a Head of Staff containing Erotic Rendering Properties.")]" + data["password"] = password + data["status"] = linkedServer.on + // Check is AI or cyborg malf + var/mob/living/silicon/silicon_user = user + data["is_malf"] = istype(silicon_user) && silicon_user.hack_software - //Message Logs if(MSG_MON_SCREEN_LOGS) - var/index = 0 - dat += "
Back - Refresh

" - dat += "" + var/list/message_list = list() for(var/datum/data_tablet_msg/pda in linkedServer.pda_msgs) - index++ - if(index > 3000) - break - // Del - Sender - Recepient - Message - // X - Al Green - Your Mom - WHAT UP!? - dat += "" - dat += "
XSenderRecipientMessage
X
[pda.sender][pda.recipient][pda.message][pda.picture ? " (Photo)":""]
" - //Hacking screen. - if(MSG_MON_SCREEN_HACKED) - if(isAI(user) || iscyborg(user)) - dat += "Brute-forcing for server key.
It will take 20 seconds for every character that the password has." - dat += "In the meantime, this console can reveal your true intentions if you let someone access it. Make sure no humans enter the room during that time." - else - //It's the same message as the one above but in binary. Because robots understand binary and humans don't... well I thought it was clever. - dat += {"01000010011100100111010101110100011001010010110
- 10110011001101111011100100110001101101001011011100110011
- 10010000001100110011011110111001000100000011100110110010
- 10111001001110110011001010111001000100000011010110110010
- 10111100100101110001000000100100101110100001000000111011
- 10110100101101100011011000010000001110100011000010110101
- 10110010100100000001100100011000000100000011100110110010
- 10110001101101111011011100110010001110011001000000110011
- 00110111101110010001000000110010101110110011001010111001
- 00111100100100000011000110110100001100001011100100110000
- 10110001101110100011001010111001000100000011101000110100
- 00110000101110100001000000111010001101000011001010010000
- 00111000001100001011100110111001101110111011011110111001
- 00110010000100000011010000110000101110011001011100010000
- 00100100101101110001000000111010001101000011001010010000
- 00110110101100101011000010110111001110100011010010110110
- 10110010100101100001000000111010001101000011010010111001
- 10010000001100011011011110110111001110011011011110110110
- 00110010100100000011000110110000101101110001000000111001
- 00110010101110110011001010110000101101100001000000111100
- 10110111101110101011100100010000001110100011100100111010
- 10110010100100000011010010110111001110100011001010110111
- 00111010001101001011011110110111001110011001000000110100
- 10110011000100000011110010110111101110101001000000110110
- 00110010101110100001000000111001101101111011011010110010
- 10110111101101110011001010010000001100001011000110110001
- 10110010101110011011100110010000001101001011101000010111
- 00010000001001101011000010110101101100101001000000111001
- 10111010101110010011001010010000001101110011011110010000
- 00110100001110101011011010110000101101110011100110010000
- 00110010101101110011101000110010101110010001000000111010
- 00110100001100101001000000111001001101111011011110110110
- 10010000001100100011101010111001001101001011011100110011
- 10010000001110100011010000110000101110100001000000111010
- 001101001011011010110010100101110"} - - //Fake messages - if(MSG_MON_SCREEN_CUSTOM_MSG) - dat += "
Back - Reset

" - - dat += {" - - - - "} - //Sender - Sender's Job - Recepient - Message - //Al Green- Your Dad - Your Mom - WHAT UP!? - - dat += {" - - - "} - dat += "
SenderSender's JobRecipientMessage
[customsender][customjob][customrecepient ? customrecepient : "NONE"][custommessage]

Send" - - //Request Console Logs + message_list += list(list("ref" = REF(pda), "sender" = pda.sender, "recipient" = pda.recipient, "message" = pda.message)) + data["messages"] = message_list if(MSG_MON_SCREEN_REQUEST_LOGS) - - var/index = 0 - /* data_rc_msg - X - 5% - var/rec_dpt = "Unspecified" //name of the person - 15% - var/send_dpt = "Unspecified" //name of the sender- 15% - var/message = "Blank" //transferred message - 300px - var/stamp = "Unstamped" - 15% - var/id_auth = "Unauthenticated" - 15% - var/priority = "Normal" - 10% - */ - dat += "
Back - Refresh

" - dat += {" - "} + var/list/request_list = list() for(var/datum/data_rc_msg/rc in linkedServer.rc_msgs) - index++ - if(index > 3000) - break - // Del - Sender - Recepient - Message - // X - Al Green - Your Mom - WHAT UP!? - dat += {" - "} - dat += "
XSending Dep.Receiving Dep.MessageStampID Auth.Priority.
X
[rc.send_dpt][rc.rec_dpt][rc.message][rc.stamp][rc.id_auth][rc.priority]
" - - message = defaultmsg - var/datum/browser/popup = new(user, "hologram_console", name, 700, 700) - popup.set_content(dat) - popup.open() - -/obj/machinery/computer/message_monitor/proc/BruteForce(mob/user) - if(isnull(linkedServer)) - to_chat(user, span_warning("Could not complete brute-force: Linked Server Disconnected!")) - else - var/currentKey = linkedServer.decryptkey - to_chat(user, span_warning("Brute-force completed! The key is '[currentKey]'.")) - hacking = FALSE - screen = MSG_MON_SCREEN_MAIN // Return the screen back to normal + request_list += list(list("ref" = REF(rc), "message" = rc.message, "stamp" = rc.stamp, "id_auth" = rc.id_auth, "departament" = rc.send_dpt)) + data["requests"] = request_list + return data -/obj/machinery/computer/message_monitor/proc/UnmagConsole() - obj_flags &= ~EMAGGED +/obj/machinery/computer/message_monitor/ui_act(action, params) + . = ..() + if(.) + return . -/obj/machinery/computer/message_monitor/proc/ResetMessage() - customsender = "System Administrator" - customrecepient = null - custommessage = "This is a test, please ignore." - customjob = "Admin" + error_message = "" + success_message = "" + notice_message = "" -/obj/machinery/computer/message_monitor/Topic(href, href_list) - if(..()) - return + switch(action) + if("auth") + var/authPass = params["auth_password"] - if(usr.contents.Find(src) || (in_range(src, usr) && isturf(loc)) || issilicon(usr)) - //Authenticate - if (href_list["auth"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) + if(auth) auth = FALSE - screen = MSG_MON_SCREEN_MAIN - else - var/dkey = tgui_input_text(usr, "Please enter the decryption key", "Telecomms Decryption") - if(dkey && dkey != "") - if(linkedServer.decryptkey == dkey) - auth = TRUE - else - message = incorrectkey - - //Turn the server on/off. - if (href_list["active"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) - linkedServer.toggled = !linkedServer.toggled - //Find a server - if (href_list["find"]) + return TRUE + + if(linkedServer.decryptkey != authPass) + error_message = "ALERT: Incorrect decryption key!" + return TRUE + + auth = TRUE + success_message = "YOU SUCCESFULLY LOGGED IN!" + + return TRUE + if("link_server") var/list/message_servers = list() - for (var/obj/machinery/telecomms/message_server/M in GLOB.telecomms_list) - message_servers += M + for (var/obj/machinery/telecomms/message_server/message_server in GLOB.telecomms_list) + message_servers += message_server if(length(message_servers) > 1) linkedServer = tgui_input_list(usr, "Please select a server", "Server Selection", message_servers) if(linkedServer) - message = span_alert("NOTICE: Server selected.") - else if(length(message_servers) > 0) - linkedServer = message_servers[1] - message = span_notice("NOTICE: Only Single Server Detected - Server selected.") - else - message = noserver - - //View the logs - KEY REQUIRED - if (href_list["view_logs"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) - screen = MSG_MON_SCREEN_LOGS - - //Clears the logs - KEY REQUIRED - if (href_list["clear_logs"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) - linkedServer.pda_msgs = list() - message = span_notice("NOTICE: Logs cleared.") - //Clears the request console logs - KEY REQUIRED - if (href_list["clear_requests"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) - linkedServer.rc_msgs = list() - message = span_notice("NOTICE: Logs cleared.") - //Change the password - KEY REQUIRED - if (href_list["pass"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) - var/dkey = tgui_input_text(usr, "Please enter the decryption key", "Telecomms Decryption") - if(dkey && dkey != "") - if(linkedServer.decryptkey == dkey) - var/newkey = tgui_input_text(usr, "Please enter the new key (3 - 16 characters max)", "New Key", 16) - if(length(newkey) <= 3) - message = span_notice("NOTICE: Decryption key too short!") - else if(newkey && newkey != "") - linkedServer.decryptkey = newkey - message = span_notice("NOTICE: Decryption key set.") - else - message = incorrectkey - - //Hack the Console to get the password - if (href_list["hack"]) - var/mob/living/silicon/S = usr - if(istype(S) && S.hack_software) - hacking = TRUE - screen = MSG_MON_SCREEN_HACKED - //Time it takes to bruteforce is dependant on the password length. - addtimer(CALLBACK(src, PROC_REF(finish_bruteforce), usr), 100*length(linkedServer.decryptkey)) - - //Delete the log. - if (href_list["delete_logs"]) - //Are they on the view logs screen? - if(screen == MSG_MON_SCREEN_LOGS) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(istype(href_list["delete_logs"], /datum/data_tablet_msg)) - linkedServer.pda_msgs -= locate(href_list["delete_logs"]) in linkedServer.pda_msgs - message = span_notice("NOTICE: Log Deleted!") - //Delete the request console log. - if (href_list["delete_requests"]) - //Are they on the view logs screen? - if(screen == MSG_MON_SCREEN_REQUEST_LOGS) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(istype(href_list["delete_logs"], /datum/data_tablet_msg)) - linkedServer.rc_msgs -= locate(href_list["delete_requests"]) in linkedServer.rc_msgs - message = span_notice("NOTICE: Log Deleted!") - - //Create a custom message - if (href_list["msg"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) - screen = MSG_MON_SCREEN_CUSTOM_MSG - - //Fake messaging selection - KEY REQUIRED - if (href_list["select"]) - if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - screen = MSG_MON_SCREEN_MAIN - else - switch(href_list["select"]) - - //Reset - if("Reset") - ResetMessage() - - //Select Your Name - if("Sender") - customsender = tgui_input_text(usr, "Please enter the sender's name.", "Sender") || customsender - - //Select Receiver - if("Recepient") - // Get out list of viable tablets - var/list/viewable_tablets = list() - for (var/obj/item/modular_computer/tablet as anything in GLOB.TabletMessengers) - var/datum/computer_file/program/messenger/message_app = locate() in tablet.stored_files - if(!message_app || message_app.invisible) - continue - if(!tablet.saved_identification) - continue - viewable_tablets += tablet - if(length(viewable_tablets) > 0) - customrecepient = tgui_input_list(usr, "Select a tablet from the list", "Tablet Selection", viewable_tablets) - else - customrecepient = null - - //Enter custom job - if("RecJob") - customjob = tgui_input_text(usr, "Please enter the sender's job.", "Job") || customjob - - //Enter message - if("Message") - custommessage = tgui_input_text(usr, "Please enter your message.", "Message") || custommessage - - //Send message - if("Send") - if(isnull(customsender) || customsender == "") - customsender = "UNKNOWN" - - if(isnull(customrecepient)) - message = span_notice("NOTICE: No recepient selected!") - return attack_hand(usr) - - if(isnull(custommessage) || custommessage == "") - message = span_notice("NOTICE: No message entered!") - return attack_hand(usr) - - var/datum/signal/subspace/messaging/tablet_msg/signal = new(src, list( - "name" = "[customsender]", - "job" = "[customjob]", - "message" = html_decode(custommessage), - "ref" = REF(src), - "targets" = list(customrecepient), - "rigged" = FALSE, - "automated" = FALSE, - )) - // this will log the signal and transmit it to the target - linkedServer.receive_information(signal, null) - usr.log_message("(Tablet: [name] | [usr.real_name]) sent \"[custommessage]\" to [signal.format_target()]", LOG_PDA) - - //Request Console Logs - KEY REQUIRED - if(href_list["view_requests"]) + notice_message = "NOTICE: Server selected." + else if(length(message_servers) > 0) + linkedServer = message_servers[1] + notice_message = "NOTICE: Only Single Server Detected - Server selected." + else + error_message = "ALERT: No server detected." + screen = MSG_MON_SCREEN_MAIN + return TRUE + if("turn_server") if(LINKED_SERVER_NONRESPONSIVE) - message = noserver - else if(auth) - screen = MSG_MON_SCREEN_REQUEST_LOGS - - if (href_list["back"]) + error_message = "ALERT: No server detected." + return TRUE + + linkedServer.toggled = !linkedServer.toggled + return TRUE + if("view_message_logs") + screen = MSG_MON_SCREEN_LOGS + return + if("view_request_logs") + screen = MSG_MON_SCREEN_REQUEST_LOGS + return TRUE + if("clear_message_logs") + linkedServer.pda_msgs = list() + notice_message = "NOTICE: Logs cleared." + return TRUE + if("clear_request_logs") + linkedServer.rc_msgs = list() + notice_message = "NOTICE: Logs cleared." + return TRUE + if("set_key") + var/dkey = tgui_input_text(usr, "Please enter the decryption key", "Telecomms Decryption") + if(dkey && dkey != "") + if(linkedServer.decryptkey == dkey) + var/newkey = tgui_input_text(usr, "Please enter the new key (3 - 16 characters max)", "New Key") + if(length(newkey) <= 3) + notice_message = "NOTICE: Decryption key too short!" + else if(newkey && newkey != "") + linkedServer.decryptkey = newkey + notice_message = "NOTICE: Decryption key set." + else + error_message = "ALERT: Incorrect decryption key!" + return TRUE + if("return_home") screen = MSG_MON_SCREEN_MAIN + return TRUE + if("delete_message") + linkedServer.pda_msgs -= locate(params["ref"]) in linkedServer.pda_msgs + success_message = "Log Deleted!" + return TRUE + if("delete_request") + linkedServer.rc_msgs -= locate(params["ref"]) in linkedServer.rc_msgs + success_message = "Log Deleted!" + return TRUE + if("connect_server") + if(!linkedServer) + for(var/obj/machinery/telecomms/message_server/S in GLOB.telecomms_list) + linkedServer = S + break + return TRUE + if("send_fake_message") + var/sender = tgui_input_text(usr, "What is the sender's name?", "Sender") + var/job = tgui_input_text(usr, "What is the sender's job?", "Job") + + var/recipient + var/list/viewable_tablets = list() + for (var/obj/item/modular_computer/tablet as anything in GLOB.TabletMessengers) + var/datum/computer_file/program/messenger/message_app = locate() in tablet.stored_files + if(!message_app || message_app.invisible) + continue + if(!tablet.saved_identification) + continue + viewable_tablets += tablet + if(length(viewable_tablets) > 0) + recipient = tgui_input_list(usr, "Select a tablet from the list", "Tablet Selection", viewable_tablets) + else + recipient = null + + var/message = tgui_input_text(usr, "Please enter your message", "Message") + if(isnull(sender) || sender == "") + sender = "UNKNOWN" + + if(isnull(recipient)) + notice_message = "NOTICE: No recipient selected!" + return attack_hand(usr) + if(isnull(message) || message == "") + notice_message = "NOTICE: No message entered!" + return attack_hand(usr) + + var/datum/signal/subspace/messaging/tablet_msg/signal = new(src, list( + "name" = "[sender]", + "job" = "[job]", + "message" = html_decode(message), + "ref" = REF(src), + "targets" = list(recipient), + "rigged" = FALSE, + "automated" = FALSE, + )) + // This will log the signal and transmit it to the target + linkedServer.receive_information(signal, null) + usr.log_message("(Tablet: [name] | [usr.real_name]) sent \"[message]\" to [signal.format_target()]", LOG_PDA) + return TRUE + // Malfunction AI and cyborgs can hack console. This will auth console, but you need to wait password selection + if("hack") + var/time = 10 SECONDS * length(linkedServer.decryptkey) + addtimer(CALLBACK(src, PROC_REF(unemag_console)), time) + screen = MSG_MON_SCREEN_HACKED + error_message = "%$&(£: Critical %$$@ Error // !RestArting! - ?pLeaSe wAit!" + linkedServer.toggled = FALSE + auth = TRUE + return TRUE + return TRUE + +/obj/machinery/computer/message_monitor/ui_interact(mob/user, datum/tgui/ui) + . = ..() + ui = SStgui.try_update_ui(user, src, ui) + if (!ui) + ui = new(user, src, "MessageMonitor", name) + ui.open() - return attack_hand(usr) - -/obj/machinery/computer/message_monitor/proc/finish_bruteforce(mob/user) - if(!QDELETED(user)) - BruteForce(user) - return - hacking = FALSE - screen = MSG_MON_SCREEN_MAIN #undef MSG_MON_SCREEN_MAIN #undef MSG_MON_SCREEN_LOGS -#undef MSG_MON_SCREEN_HACKED -#undef MSG_MON_SCREEN_CUSTOM_MSG #undef MSG_MON_SCREEN_REQUEST_LOGS - +#undef MSG_MON_SCREEN_HACKED #undef LINKED_SERVER_NONRESPONSIVE +/// Monitor decryption key paper + /obj/item/paper/monitorkey name = "monitor decryption key" @@ -478,7 +284,7 @@ return INITIALIZE_HINT_LATELOAD /obj/item/paper/monitorkey/proc/print(obj/machinery/telecomms/message_server/server) - add_raw_text("

Daily Key Reset


The new message monitor key is '[server.decryptkey]'.
Please keep this a secret and away from the clown.
If necessary, change the password to a more secure one.") + add_raw_text("

Daily Key Reset


The new message monitor key is [server.decryptkey].
Please keep this a secret and away from the clown.
If necessary, change the password to a more secure one.") add_overlay("paper_words") update_appearance() diff --git a/code/game/machinery/telecomms/computers/telemonitor.dm b/code/game/machinery/telecomms/computers/telemonitor.dm index cc92e41b15bb..3d12932d99da 100644 --- a/code/game/machinery/telecomms/computers/telemonitor.dm +++ b/code/game/machinery/telecomms/computers/telemonitor.dm @@ -1,122 +1,114 @@ - /* Telecomms monitor tracks the overall trafficing of a telecommunications network and displays a heirarchy of linked machines. */ +#define MAIN_VIEW 0 +#define MACHINE_VIEW 1 +#define MAX_NETWORK_ID_LENGTH 15 /obj/machinery/computer/telecomms/monitor name = "telecommunications monitoring console" icon_screen = "comm_monitor" desc = "Monitors the details of the telecommunications network it's synced with." - var/screen = 0 // the screen number: - var/list/machinelist = list() // the machines located by the computer + /// Current screen the user is viewing + var/screen = MAIN_VIEW + /// The machines located by the computer + var/list/machinelist = list() + /// the currently selected machine var/obj/machinery/telecomms/SelectedMachine - - var/network = "NULL" // the network to probe - - var/temp = "" // temporary feedback messages + /// The network to probe + var/network = "NULL" + /// Error message to show + var/error_message = "" circuit = /obj/item/circuitboard/computer/comm_monitor -/obj/machinery/computer/telecomms/monitor/ui_interact(mob/user) - . = ..() - var/dat = "Telecommunications Monitor
Telecommunications Monitor
" +/obj/machinery/computer/telecomms/monitor/ui_data(mob/user) + var/list/data = list( + "screen" = screen, + "network" = network, + "error_message" = error_message, + ) switch(screen) - - - // --- Main Menu --- - - if(0) - dat += "
[temp]

" - dat += "
Current Network: [network]
" - if(machinelist.len) - dat += "
Detected Network Entities:
    " - for(var/obj/machinery/telecomms/T in machinelist) - dat += "
  • [REF(T)] [T.name] ([T.id])
  • " - dat += "
" - dat += "
\[Flush Buffer\]" - else - dat += "\[Probe Network\]" - - - // --- Viewing Machine --- - - if(1) - dat += "
[temp]
" - dat += "
\[Main Menu\]
" - dat += "
Current Network: [network]
" - dat += "Selected Network Entity: [SelectedMachine.name] ([SelectedMachine.id])
" - dat += "Linked Entities:
    " + // --- Main Menu --- + if(MAIN_VIEW) + var/list/found_machinery = list() + for(var/obj/machinery/telecomms/telecomms in machinelist) + found_machinery += list(list("ref" = REF(telecomms), "name" = telecomms.name, "id" = telecomms.id)) + data["machinery"] = found_machinery + // --- Viewing Machine --- + if(MACHINE_VIEW) + // Send selected machinery data + var/list/machine_out = list() + machine_out["name"] = SelectedMachine.name + // Get the linked machinery + var/list/linked_machinery = list() for(var/obj/machinery/telecomms/T in SelectedMachine.links) - if(!T.hide) - dat += "
  1. [REF(T.id)] [T.name] ([T.id])
  2. " - dat += "
" - - - - user << browse(dat, "window=comm_monitor;size=575x400") - onclose(user, "server_control") - - temp = "" - return - - -/obj/machinery/computer/telecomms/monitor/Topic(href, href_list) - if(..()) - return - + linked_machinery += list(list("ref" = REF(T.id), "name" = T.name, "id" = T.id)) + machine_out["linked_machinery"] = linked_machinery + data["machine"] = machine_out + return data - add_fingerprint(usr) - usr.set_machine(src) - - if(href_list["viewmachine"]) - screen = 1 - for(var/obj/machinery/telecomms/T in machinelist) - if(T.id == href_list["viewmachine"]) - SelectedMachine = T - break - - if(href_list["operation"]) - switch(href_list["operation"]) - - if("release") - machinelist = list() - screen = 0 - - if("mainmenu") - screen = 0 - - if("probe") - if(machinelist.len > 0) - temp = "- FAILED: CANNOT PROBE WHEN BUFFER FULL -" - - else - for(var/obj/machinery/telecomms/T in urange(25, src)) - if(T.network == network) - machinelist.Add(T) - - if(!machinelist.len) - temp = "- FAILED: UNABLE TO LOCATE NETWORK ENTITIES IN \[[network]\] -" - else - temp = "- [machinelist.len] ENTITIES LOCATED & BUFFERED -" - - screen = 0 - - - if(href_list["network"]) - - var/newnet = tgui_input_text(usr, "Which network do you want to view?", "Comm Monitor", network, 15) - if(newnet && ((usr in range(1, src)) || issilicon(usr))) - network = newnet - screen = 0 +/obj/machinery/computer/telecomms/monitor/ui_act(action, params) + . = ..() + if(.) + return . + + error_message = "" + + switch(action) + // Scan for a network + if("probe_network") + var/new_network = params["network_id"] + + if(length(new_network) > MAX_NETWORK_ID_LENGTH) + error_message = "OPERATION FAILED: NETWORK ID TOO LONG." + return TRUE + + if(machinelist.len > 0) + error_message = "OPERATION FAILED: CANNOT PROBE WHEN BUFFER FULL." + return TRUE + + network = new_network + + for(var/obj/machinery/telecomms/T in urange(25, src)) + if(T.network == network) + machinelist.Add(T) + if(machinelist.len == 0) + error_message = "OPERATION FAILED: UNABLE TO LOCATE NETWORK ENTITIES IN [network]." + return TRUE + error_message = "[machinelist.len] ENTITIES LOCATED & BUFFERED"; + return TRUE + if("flush_buffer") machinelist = list() - temp = "- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -" - - updateUsrDialog() - return - + network = "" + return TRUE + if("view_machine") + for(var/obj/machinery/telecomms/T in machinelist) + if(T.id == params["id"]) + SelectedMachine = T + if(!SelectedMachine) + error_message = "OPERATION FAILED: UNABLE TO LOCATE MACHINERY." + screen = MACHINE_VIEW + return TRUE + if("return_home") + SelectedMachine = null + screen = MAIN_VIEW + return TRUE + return TRUE /obj/machinery/computer/telecomms/monitor/attackby() . = ..() updateUsrDialog() + +/obj/machinery/computer/telecomms/monitor/ui_interact(mob/user, datum/tgui/ui) + . = ..() + ui = SStgui.try_update_ui(user, src, ui) + if (!ui) + ui = new(user, src, "TelecommsMonitor", name) + ui.open() + +#undef MAIN_VIEW +#undef MACHINE_VIEW +#undef MAX_NETWORK_ID_LENGTH diff --git a/tgui/packages/tgui/interfaces/MessageMonitor.tsx b/tgui/packages/tgui/interfaces/MessageMonitor.tsx new file mode 100644 index 000000000000..ea5216365a2e --- /dev/null +++ b/tgui/packages/tgui/interfaces/MessageMonitor.tsx @@ -0,0 +1,380 @@ +import { BooleanLike } from 'common/react'; +import { useBackend, useLocalState } from '../backend'; +import { Section, Stack, Input, Button, Table, NoticeBox, Box } from '../components'; +import { Window } from '../layouts'; + +enum Screen { + Main, + MessageLogs, + RequestLogs, + Hacked, +} + +type Data = { + screen: Screen; + status: BooleanLike; + server_status: BooleanLike; + auth: BooleanLike; + password: string; + is_malf: BooleanLike; + error_message: string; + success_message: string; + notice_message: string; + requests: Request[]; + messages: Message[]; +}; + +type Request = { + ref: string; + message: string; + stamp: string; + send_dpt: string; + id_auth: string; +}; + +type Message = { + ref: string; + message: string; + sender: string; + recipient: string; +}; + +const RequestLogsScreen = (props, context) => { + const { act, data } = useBackend(context); + const { requests = [] } = data; + return ( + + +
act('return_home')} + /> + }> + + + Delete + Message + Stamp + Departament + Authentication + + {requests?.map((request) => ( + + +
+
+
+
+ ); +}; + +const MessageLogsScreen = (props, context) => { + const { act, data } = useBackend(context); + const { messages = [] } = data; + return ( + + +
act('return_home')} + /> + }> + + + Delete + Sender + Recipient + Message + + {messages?.map((message) => ( + + +
+
+
+
+ ); +}; + +const HackedScreen = (props, context) => { + return ( + + + + + + E%*#OR: CRIT#%^CAL Ss&@STEM Fai++~|URE... + + + EN*bLING u&*E REB-00T ProT/.\;L... + + + + + ); +}; + +const MainScreenAuth = (props, context) => { + const { act, data } = useBackend(context); + const { status, is_malf, password } = data; + const [auth_password, setPassword] = useLocalState( + context, + 'input_password', + password + ); + return ( + <> + +
+ setPassword(value)} + placeholder="Password" + /> +
+
+ + + Option + Description + + + +
+ + ); +}; + +const MainScreenNotAuth = (props, context) => { + const { act, data } = useBackend(context); + const { status, is_malf, password } = data; + const [auth_password, setPassword] = useLocalState( + context, + 'input_password', + password + ); + + return ( + <> + +
+ setPassword(value)} + placeholder="Password" + /> +
+
+ +
+ + + Option + Description + + + +
+
+
+ + ); +}; + +const MainScreen = (props, context) => { + const { act, data } = useBackend(context); + const { auth } = data; + return ( + + {auth ? : } + + ); +}; + +export const MessageMonitor = (props, context) => { + const { act, data } = useBackend(context); + const { + screen, + error_message, + success_message, + notice_message, + server_status, + } = data; + return ( + + + + {server_status ? ( + <> + + {!!error_message && ( + {error_message} + )} + + + {!!success_message && ( + {success_message} + )} + + + {(screen === Screen.Main && ) || + (screen === Screen.MessageLogs && ) || + (screen === Screen.RequestLogs && ) || + (screen === Screen.Hacked && )} + + + {!!notice_message && ( + {notice_message} + )} + + + + ) : ( + <> + + + Server not found, click button to scan the network + + + +