From 0c14dc20c45b7824cbdad6470a6961cd6736f183 Mon Sep 17 00:00:00 2001 From: BarteG44 <105491762+BarteG44@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:42:42 +0200 Subject: [PATCH] Adds a voice log to the wideband (#2307) ## About The Pull Request Adds a voice log to the wideband that stores the last 50 messages spoken along with their timestamps to make the wideband more usable without having to be glued to it ![image](https://github.com/shiptest-ss13/Shiptest/assets/105491762/e2897056-4cb2-4530-b6ed-464b7f48157c) ## Why It's Good For The Game it's sure to make ships interact more with each other by taking on a role similar to a chatroom ## Changelog :cl: add: Added a voice log for the wideband /:cl: --------- Signed-off-by: BarteG44 <105491762+BarteG44@users.noreply.github.com> Co-authored-by: Mark Suckerberg --- code/game/machinery/telecomms/broadcasting.dm | 9 +++- .../objects/items/devices/radio/intercom.dm | 1 + .../game/objects/items/devices/radio/radio.dm | 9 ++++ tgui/packages/tgui/interfaces/Radio.js | 43 ++++++++++++++++++- 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/telecomms/broadcasting.dm b/code/game/machinery/telecomms/broadcasting.dm index e3e9534a384f7..9f2711ebb7a7e 100644 --- a/code/game/machinery/telecomms/broadcasting.dm +++ b/code/game/machinery/telecomms/broadcasting.dm @@ -179,7 +179,14 @@ if(radio.last_chatter_time + 1 SECONDS < world.time && source != radio) playsound(radio, "sound/effects/radio_chatter.ogg", 20, FALSE) radio.last_chatter_time = world.time - //WS edit end + if(radio.log) + var/name = data["name"] + var/list/log_details = list() + log_details["name"] = "[name]▸" + log_details["message"] = "\"[html_decode(message)]\"" + log_details["time"] = station_time_timestamp() + radio.loglist.Insert(1, list(log_details)) + radio.log_trim() // From the list of radios, find all mobs who can hear those. var/list/receive = get_mobs_in_radio_ranges(radios) diff --git a/code/game/objects/items/devices/radio/intercom.dm b/code/game/objects/items/devices/radio/intercom.dm index 35d8be6efa551..3c35294f8e3f1 100644 --- a/code/game/objects/items/devices/radio/intercom.dm +++ b/code/game/objects/items/devices/radio/intercom.dm @@ -167,6 +167,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/item/radio/intercom, 31) frequency = FREQ_WIDEBAND freqlock = TRUE freerange = TRUE + log = TRUE wallframe = /obj/item/wallframe/intercom/wideband /obj/item/radio/intercom/wideband/Initialize(mapload, ndir, building) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index a46f6e2ea55de..2a5a043656c29 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -34,6 +34,8 @@ var/freqlock = FALSE // Frequency lock to stop the user from untuning specialist radios. var/use_command = FALSE // If true, broadcasts will be large and BOLD. var/command = FALSE // If true, use_command can be toggled at will. + var/log = FALSE // If true, the UI will display the voice log for the frequency + var/list/loglist = list() //the voice log // Encryption key handling var/obj/item/encryptionkey/keyslot @@ -140,6 +142,8 @@ data["useCommand"] = use_command data["subspace"] = subspace_transmission data["subspaceSwitchable"] = subspace_switchable + data["chatlog"] = log + data["chatloglist"] = loglist data["headset"] = FALSE return data @@ -372,6 +376,11 @@ on = TRUE return TRUE +/obj/item/radio/proc/log_trim() + if(loglist.len <= 50) + return + loglist.Cut(51) + /////////////////////////////// //////////Borg Radios////////// /////////////////////////////// diff --git a/tgui/packages/tgui/interfaces/Radio.js b/tgui/packages/tgui/interfaces/Radio.js index 6d3df1ff64fd6..1783933bf4681 100644 --- a/tgui/packages/tgui/interfaces/Radio.js +++ b/tgui/packages/tgui/interfaces/Radio.js @@ -1,7 +1,15 @@ import { map } from 'common/collections'; import { toFixed } from 'common/math'; import { useBackend } from '../backend'; -import { Box, Button, LabeledList, NumberInput, Section } from '../components'; +import { + Box, + Button, + LabeledList, + NumberInput, + Section, + Divider, + Table, +} from '../components'; import { RADIO_CHANNELS } from '../constants'; import { Window } from '../layouts'; @@ -18,6 +26,8 @@ export const Radio = (props, context) => { useCommand, subspace, subspaceSwitchable, + chatlog, + chatloglist = [], } = data; const tunedChannel = RADIO_CHANNELS.find( (channel) => channel.freq === frequency @@ -28,15 +38,19 @@ export const Radio = (props, context) => { }))(data.channels); // Calculate window height let height = 106; + let width = 360; if (subspace) { if (channels.length > 0) { height += channels.length * 21 + 6; } else { height += 24; } + } else if (chatlog) { + height += 400; + width += 110; } return ( - +
@@ -127,6 +141,31 @@ export const Radio = (props, context) => { )}
+ {!!chatlog && ( +
+ + + Timestamp + Transcript + + + {chatloglist.map((log) => ( + + {log.time} +
+ {log.name} +
+ {log.message}
+ + ))} + +
+ )}
);