Skip to content

Commit

Permalink
Adds a voice log to the wideband (#2307)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## 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)

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## 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
<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl:
add: Added a voice log for the wideband
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Signed-off-by: BarteG44 <[email protected]>
Co-authored-by: Mark Suckerberg <[email protected]>
  • Loading branch information
BarteG44 and MarkSuckerberg authored Sep 13, 2023
1 parent c37d319 commit 77ea22e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
9 changes: 8 additions & 1 deletion code/game/machinery/telecomms/broadcasting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/devices/radio/intercom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions code/game/objects/items/devices/radio/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -372,6 +376,11 @@
on = TRUE
return TRUE

/obj/item/radio/proc/log_trim()
if(loglist.len <= 50)
return
loglist.Cut(51)

///////////////////////////////
//////////Borg Radios//////////
///////////////////////////////
Expand Down
43 changes: 41 additions & 2 deletions tgui/packages/tgui/interfaces/Radio.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -18,6 +26,8 @@ export const Radio = (props, context) => {
useCommand,
subspace,
subspaceSwitchable,
chatlog,
chatloglist = [],
} = data;
const tunedChannel = RADIO_CHANNELS.find(
(channel) => channel.freq === frequency
Expand All @@ -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 (
<Window width={360} height={height}>
<Window width={width} height={height}>
<Window.Content>
<Section>
<LabeledList>
Expand Down Expand Up @@ -127,6 +141,31 @@ export const Radio = (props, context) => {
)}
</LabeledList>
</Section>
{!!chatlog && (
<Section
title="Voice Log"
height="400px"
width="460px"
overflowY="scroll"
>
<Table>
<Table.Row header>
<Table.Cell>Timestamp</Table.Cell>
<Table.Cell>Transcript</Table.Cell>
<Divider />
</Table.Row>
{chatloglist.map((log) => (
<Table.Row key={log.message} className="candystripe">
<Table.Cell>{log.time}</Table.Cell>
<Table bold color="blue">
{log.name}
</Table>
<Table>{log.message}</Table>
</Table.Row>
))}
</Table>
</Section>
)}
</Window.Content>
</Window>
);
Expand Down

0 comments on commit 77ea22e

Please sign in to comment.