Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Content.Server/Radio/EntitySystems/HeadsetSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Robust.Shared.Player;
using Content.Server.Speech; // Starlight
using Content.Server._Starlight.Language; // Starlight
Comment thread
Rinary1 marked this conversation as resolved.
Outdated
using Content.Shared._Starlight.Clothing;

namespace Content.Server.Radio.EntitySystems;

Expand Down Expand Up @@ -55,16 +56,23 @@ private void UpdateRadioChannels(EntityUid uid, HeadsetComponent headset, Encryp

private void OnSpeak(EntityUid uid, WearingHeadsetComponent component, EntitySpokeEvent args)
{
#region Starlight
HeadsetLoudModeComponent? loudComp = null;
if(TryComp<HeadsetLoudModeComponent>(component.Headset, out var comp) && comp.Active)
{
loudComp = comp;
}
#endregion Starlight
Comment thread
Rinary1 marked this conversation as resolved.
Outdated
if (args.Channel != null
&& TryComp(component.Headset, out EncryptionKeyHolderComponent? keys)
&& keys.Channels.Contains(args.Channel.ID))
{
_radio.SendRadioMessage(uid, args.Message, args.Channel, component.Headset, args.Language); // Starlight-edit: This literally never specified language??? bruh.
_radio.SendRadioMessage(uid, args.Message, args.Channel, component.Headset, args.Language, loudComp: loudComp); // Starlight-edit: This literally never specified language??? bruh.
args.Channel = null; // prevent duplicate messages from other listeners.
}
//Starlight begin
if (args.UsingCustomChannel && args.CustomChannel is not null)
_radio.SendCustomRadioMessage(uid, args.Message.Text, args.CustomChannel, component.Headset, args.Language); // Custom channel data is already confirmed to exist on this headset
_radio.SendCustomRadioMessage(uid, args.Message.Text, args.CustomChannel, component.Headset, args.Language, loudComp: loudComp); // Custom channel data is already confirmed to exist on this headset
//Starlight end
}

Expand Down
41 changes: 27 additions & 14 deletions Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using Content.Shared._Starlight.Language.Components;
using Content.Shared.Ghost;
using Content.Server._Starlight.TextToSpeech; //Starlight
Comment thread
Rinary1 marked this conversation as resolved.
Outdated
using Content.Shared._Starlight.Clothing;

namespace Content.Server.Radio.EntitySystems;

Expand Down Expand Up @@ -117,9 +118,10 @@ public void SendRadioMessage(
EntityUid radioSource,
LanguagePrototype? language = null, // Starlight
bool suppressTTS = false, // Starlight
bool escapeMarkup = true)
bool escapeMarkup = true,
HeadsetLoudModeComponent? loudComp = null) // Starlight
{
SendRadioMessage(messageSource, message, _prototype.Index(channel), radioSource, escapeMarkup: escapeMarkup, language: language, suppressTTS: suppressTTS); // Starlight
SendRadioMessage(messageSource, message, _prototype.Index(channel), radioSource, escapeMarkup: escapeMarkup, language: language, suppressTTS: suppressTTS, loudComp: loudComp); // Starlight
}

/// <summary>
Expand All @@ -134,7 +136,8 @@ public void SendRadioMessage(
EntityUid radioSource,
LanguagePrototype? language = null, // Starlight
bool suppressTTS = false, // Starlight
bool escapeMarkup = true)
bool escapeMarkup = true,
HeadsetLoudModeComponent? loudComp = null) // Starlight
{
// Starlight - start
if (channel.AutoTranslate is not null)
Expand Down Expand Up @@ -182,18 +185,18 @@ public void SendRadioMessage(

_chime.TryGetSenderHeadsetChime(messageSource, out var chime);

var wrappedMessage = WrapRadioMessage(messageSource, channel, selectedName, content, language, false);
var wrappedMessage = WrapRadioMessage(messageSource, channel, selectedName, content, language, false, loudComp); // Starlight

// most radios are relayed to chat, so lets parse the chat message beforehand

var msg = new ChatMessage(ChatChannel.Radio, content, wrappedMessage, NetEntity.Invalid, null); // Starlight

var obfuscated = _language.ObfuscateSpeech(content, language);
var obfuscatedWrapped = WrapRadioMessage(messageSource, channel, selectedName, obfuscated, language, true);
var obfuscatedWrapped = WrapRadioMessage(messageSource, channel, selectedName, obfuscated, language, true, loudComp);
var notUdsMsg = new ChatMessage(ChatChannel.Radio, obfuscated, obfuscatedWrapped, NetEntity.Invalid, null) { Chime = chime, };
var ev = new RadioReceiveEvent(messageSource, channel, msg, notUdsMsg, language, radioSource, []);

var ghostwrappedMessage = WrapRadioMessage(messageSource, channel, name, content, language, false);
var ghostwrappedMessage = WrapRadioMessage(messageSource, channel, name, content, language, false, loudComp);
var ghostmsg = new ChatMessage(ChatChannel.Radio, content, ghostwrappedMessage, NetEntity.Invalid, null);
var ghostev = new RadioReceiveEvent(messageSource, channel, ghostmsg, notUdsMsg, language, radioSource, []);
// Starlight - End
Expand Down Expand Up @@ -300,7 +303,8 @@ public void SendCustomRadioMessage(
CustomRadioChannelData channel,
EntityUid radioSource,
LanguagePrototype? language = null,
bool escapeMarkup = true)
bool escapeMarkup = true,
HeadsetLoudModeComponent? loudComp = null)
{
if (language == null)
language = _language.GetLanguage(messageSource);
Expand Down Expand Up @@ -335,12 +339,12 @@ public void SendCustomRadioMessage(

_chime.TryGetSenderHeadsetChime(messageSource, out var chime);

var wrappedMessage = WrapCustomRadioMessage(messageSource, channel, name, content, language, false);
var wrappedMessage = WrapCustomRadioMessage(messageSource, channel, name, content, language, false, loudComp);

var msg = new ChatMessage(ChatChannel.Radio, content, wrappedMessage, NetEntity.Invalid, null);

var obfuscated = _language.ObfuscateSpeech(content, language);
var obfuscatedWrapped = WrapCustomRadioMessage(messageSource, channel, name, obfuscated, language, true);
var obfuscatedWrapped = WrapCustomRadioMessage(messageSource, channel, name, obfuscated, language, true, loudComp);
var notUdsMsg = new ChatMessage(ChatChannel.Radio, obfuscated, obfuscatedWrapped, NetEntity.Invalid, null) { Chime = chime, };
var ev = new RadioReceiveEvent(messageSource, null, msg, notUdsMsg, language, radioSource, []);

Expand Down Expand Up @@ -446,8 +450,8 @@ private string WrapRadioMessage(
string name,
string message,
LanguagePrototype language,
bool obfuscated
)
bool obfuscated,
HeadsetLoudModeComponent? loudComp = null) // Starlight
{
// TODO: code duplication with ChatSystem.WrapMessage
var speech = _chat.GetSpeechVerb(source, message);
Expand All @@ -473,11 +477,15 @@ bool obfuscated
if ((language.Speech.ObfuscationFont ?? false) && !obfuscated)
fonttype = speech.FontId;

bool isYelling = false;
if (speech.ID == "DefaultExclamationStrong")
isYelling = true;

return Loc.GetString(speech.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap",
("color", channel.Color),
("languageColor", languageColor),
("fontType", fonttype),
("fontSize", language.Speech.FontSize ?? speech.FontSize),
("fontSize", loudComp is not null ? loudComp.FontSize + speech.FontSize : isYelling ? speech.FontSize : language.Speech.FontSize ?? speech.FontSize), // starlight edit: loud mode
("verb", Loc.GetString(verbId)),
("channel", $"\\[{channel.LocalizedName}\\]"),
("name", namestring),
Expand All @@ -490,7 +498,8 @@ private string WrapCustomRadioMessage(
string name,
string message,
LanguagePrototype language,
bool obfuscated
bool obfuscated,
HeadsetLoudModeComponent? loudComp = null
)
{
// TODO: code duplication with ChatSystem.WrapMessage
Expand All @@ -510,11 +519,15 @@ bool obfuscated
if ((language.Speech.ObfuscationFont ?? false) && !obfuscated)
fonttype = speech.FontId;

bool isYelling = false;
if (speech.ID == "DefaultExclamationStrong")
isYelling = true;

return Loc.GetString(speech.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap",
("color", channel.Color),
("languageColor", languageColor),
("fontType", fonttype),
("fontSize", language.Speech.FontSize ?? speech.FontSize),
("fontSize", loudComp is not null ? loudComp.FontSize + speech.FontSize : isYelling ? speech.FontSize : language.Speech.FontSize ?? speech.FontSize),
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
("channel", $"\\[{channel.LocalizedName}\\]"),
("name", namestring),
Expand Down
31 changes: 31 additions & 0 deletions Content.Shared/Radio/EntitySystems/SharedHeadsetSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Content.Shared.Emp;
using Content.Shared.Inventory;
using Content.Shared.Verbs;
using Content.Shared.Inventory.Events;
using Content.Shared.Radio.Components;
using Content.Shared._Starlight.Clothing;
using Robust.Shared.Utility;
using Content.Shared.Examine;

namespace Content.Shared.Radio.EntitySystems;

Expand All @@ -15,6 +19,8 @@ public override void Initialize()
SubscribeLocalEvent<HeadsetComponent, GotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<HeadsetComponent, GotUnequippedEvent>(OnGotUnequipped);
SubscribeLocalEvent<HeadsetComponent, EmpPulseEvent>(OnEmpPulse);
SubscribeLocalEvent<HeadsetLoudModeComponent, ExaminedEvent>(OnExamined); // starlight
SubscribeLocalEvent<HeadsetLoudModeComponent, GetVerbsEvent<Verb>>(GetVerb); // starlight
}

private void OnGetDefault(EntityUid uid, HeadsetComponent component, InventoryRelayedEvent<GetDefaultRadioChannelEvent> args)
Expand Down Expand Up @@ -49,4 +55,29 @@ private void OnEmpPulse(Entity<HeadsetComponent> ent, ref EmpPulseEvent args)
args.Disabled = true;
}
}
#region Starlight
private void OnExamined(EntityUid uid, HeadsetLoudModeComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString(component.Active ? "headset-loud-mode-examine-active" : "headset-loud-mode-examine-inactive"));
}

private void GetVerb(EntityUid uid, HeadsetLoudModeComponent component, GetVerbsEvent<Verb> args)
{
if (!args.CanInteract)
return;

args.Verbs.Add(new Verb
{
Act = () => ToggleLoudMode(uid, component),
Text = Loc.GetString("ui-verb-toggle-loud-mode"),
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/_Starlight/Interface/VerbIcons/voice.192dpi.png")),
});
}

private void ToggleLoudMode(EntityUid uid, HeadsetLoudModeComponent component)
{
component.Active = !component.Active;
Dirty(uid, component);
}
#endregion Starlight
}
18 changes: 18 additions & 0 deletions Content.Shared/_Starlight/Clothing/HeadsetLoudModeComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;
using Content.Shared.Radio.EntitySystems;

namespace Content.Shared._Starlight.Clothing;

[RegisterComponent, NetworkedComponent, Access(typeof(SharedHeadsetSystem)), AutoGenerateComponentState]
public sealed partial class HeadsetLoudModeComponent : Component
{
[DataField, AutoNetworkedField]
public bool Active;

/// <summary>
/// The font size to add to the radio message when loud mode is active. (Keep this low, as it can break the chatbox if it's too high.)
/// </summary>

[DataField, AutoNetworkedField]
public int FontSize = 4;
}
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_Starlight/ui/verbs.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ui-verb-roll-up = Roll up sleeves
ui-verb-toggle-loud-mode = Toggle Loud mode

speed-potion-apply-text = Apply speed potion
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/headset/headset-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ chat-radio-message-wrap = [color={$color}]{$channel} [bold]{$name}[/bold] {$verb
# Starlight-edit: Languages
chat-radio-message-wrap-bold = [color={$color}]{$channel} [bold]{$name}[/bold] {$verb}, "[/color][font="{$fontType}" size={$fontSize}][color={$languageColor}][bold]{$message}[/bold][/font][/color][color={$color}]"[/color]

# Starlight-edit: inactive/active
headset-loud-mode-examine-active = The headset's loudmode speaker is [color=green]ACTIVE[/color].
headset-loud-mode-examine-inactive = The headset's loudmode speaker is [color=red]INACTIVE[/color].

Comment thread
Rinary1 marked this conversation as resolved.
Outdated
examine-headset-default-channel = Use {$prefix} for the default channel ([color={$color}]{$channel}[/color]).

chat-radio-common = Common
Expand Down
6 changes: 6 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Ears/headsets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/qm.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ ClothingHeadset, BaseCentcommContraband ]
Expand All @@ -109,6 +110,7 @@
- type: RadioChime #Starlight
sound:
path: /Audio/_Starlight/Effects/Radio/marauder.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadset, BaseCommandContraband]
Expand All @@ -127,6 +129,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/captain.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: ClothingHeadset
Expand Down Expand Up @@ -159,6 +162,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/ce.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: ClothingHeadset
Expand Down Expand Up @@ -191,6 +195,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/cmo.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: ClothingHeadset
Expand Down Expand Up @@ -255,6 +260,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/rd.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadset, BaseSecurityContraband]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/qm.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadsetAlt, BaseCommandContraband]
Expand All @@ -52,6 +53,7 @@
path: /Audio/_Starlight/Effects/Radio/captain.ogg
- type: StealTarget # Starlight
stealGroup: ClothingHeadsetAltCommand # Starlight
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadsetAlt, BaseCommandContraband]
Expand All @@ -71,6 +73,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/ce.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadsetAlt, BaseCommandContraband]
Expand All @@ -92,6 +95,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/cmo.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadsetAlt, BaseCommandContraband]
Expand All @@ -111,6 +115,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/hos.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadsetAlt, BaseCommandContraband]
Expand All @@ -130,6 +135,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/rd.ogg
- type: HeadsetLoudMode #Starlight

- type: entity
parent: [ClothingHeadsetAlt, BaseSyndicateContraband]
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Voice/speech_verbs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
speechVerbStrings:
- chat-speech-verb-exclamation-strong
priority: 10
fontSize: 14 #starlight, yelling

- type: speechVerb
id: Arachnid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- EncryptionKeyCommon
- type: Sprite
sprite: _Starlight/Clothing/Ears/Headsets/magi.rsi
- type: HeadsetLoudMode

- type: entity
parent: ClothingHeadset
Expand Down Expand Up @@ -168,6 +169,7 @@
- type: RadioChime
sound:
path: /Audio/_Starlight/Effects/Radio/marauder.ogg
- type: HeadsetLoudMode

- type: entity
parent: ClothingHeadsetCargo
Expand Down
Loading
Loading