From e844c5e9103ddf6a727764ef4f4e47fbc9ae7cdf Mon Sep 17 00:00:00 2001 From: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Date: Tue, 22 Nov 2022 02:00:19 -0500 Subject: [PATCH] NTnrc improvements (pings, messages, spellcheck & category) (#70885) ## About The Pull Request Changes in this PR: - Anyone can ping others, not only the Administrator. More people than just the Admin need to get people's attention. - Pings now have a 3 second cooldown delay, so you can no longer spam it. You also can't ping if you're muted. - The chat program is now under the Crew section of the store, rather than 'Misc', because it's a crew thing wtf? - Messages are now shown with the latest on top, removing the need in the past to scroll down to see new messages. - I also increased the channel name character limit by 6 so people have some more leeway in their names. ![image](https://user-images.githubusercontent.com/53777086/198833518-44af276c-9600-4e1c-b15e-484eb93fc8ec.png) ## Why It's Good For The Game Makes the NTnrc app more bearable to use and makes people actually able to get other client's attention, and gives the Admins more 'power' over their channel. ## Changelog :cl: qol: The chat client is now listed under 'Crew' instead of 'Misc' in the store. qol: The chat client now allows anyone to use the ping feature, as long as they aren't server muted. qol: The chat client's messaging system now shows the latest messages on top, rather than bottom. No more scrolling! qol: The chat client now has a ping spam-prevention feature. /:cl: --- .../file_system/programs/ntnrc_client.dm | 19 ++++++++++++++----- tgui/packages/tgui/interfaces/NtosNetChat.js | 11 ++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/code/modules/modular_computers/file_system/programs/ntnrc_client.dm b/code/modules/modular_computers/file_system/programs/ntnrc_client.dm index 2761b504950..3c4a922b49b 100644 --- a/code/modules/modular_computers/file_system/programs/ntnrc_client.dm +++ b/code/modules/modular_computers/file_system/programs/ntnrc_client.dm @@ -1,11 +1,13 @@ #define USERNAME_SIZE 32 -#define CHANNELNAME_SIZE 12 +#define CHANNELNAME_SIZE 18 #define MESSAGE_SIZE 2048 +#define PING_COOLDOWN_TIME (3 SECONDS) + /datum/computer_file/program/chatclient filename = "ntnrc_client" filedesc = "Chat Client" - category = PROGRAM_CATEGORY_MISC + category = PROGRAM_CATEGORY_CREW program_icon_state = "command" extended_desc = "This program allows communication over NTNRC network" size = 8 @@ -27,6 +29,8 @@ var/netadmin_mode = FALSE ///All NTnet conversations the application is apart of. var/list/datum/ntnet_conversation/conversations = list() + ///Cooldown timer between pings. + COOLDOWN_DECLARE(ping_cooldown) /datum/computer_file/program/chatclient/New() username = "DefaultUser[rand(100, 999)]" @@ -165,10 +169,13 @@ channel.mute_user(src, muted) return TRUE if("PRG_ping_user") - if(!authed) + if(!COOLDOWN_FINISHED(src, ping_cooldown)) + return + if(src in channel.muted_clients) return var/datum/computer_file/program/chatclient/pinged = locate(params["ref"]) in channel.active_clients + channel.offline_clients channel.ping_user(src, pinged) + COOLDOWN_START(src, ping_cooldown, PING_COOLDOWN_TIME) return TRUE /datum/computer_file/program/chatclient/process_tick(delta_time) @@ -249,9 +256,9 @@ data["strong"] = channel.strong data["clients"] = clients var/list/messages = list() - for(var/message in channel.messages) + for(var/i=channel.messages.len to 1 step -1) messages.Add(list(list( - "msg" = message, + "msg" = channel.messages[i], ))) data["messages"] = messages data["is_operator"] = (channel.channel_operator == src) || netadmin_mode @@ -262,3 +269,5 @@ #undef USERNAME_SIZE #undef CHANNELNAME_SIZE #undef MESSAGE_SIZE + +#undef PING_COOLDOWN_TIME diff --git a/tgui/packages/tgui/interfaces/NtosNetChat.js b/tgui/packages/tgui/interfaces/NtosNetChat.js index bf9dfc4e763..8b401f9c149 100644 --- a/tgui/packages/tgui/interfaces/NtosNetChat.js +++ b/tgui/packages/tgui/interfaces/NtosNetChat.js @@ -7,15 +7,7 @@ const CLIENT_ONLINE = 2; const CLIENT_AWAY = 1; const CLIENT_OFFLINE = 0; -const STATUS2TEXT = { - 0: 'Offline', - 1: 'Away', - 2: 'Online', -}; - const NoChannelDimmer = (props, context) => { - const { act, data } = useBackend(context); - const { owner } = data; return ( @@ -36,7 +28,8 @@ const NoChannelDimmer = (props, context) => { Click a channel to start chatting! - (If you're new, you may wannaa set your name in the bottom left!) + (If you're new, you may want to set your name in the bottom + left!)