This commit is contained in:
Stxcking 2026-05-10 11:43:47 +00:00 committed by GitHub
commit 015ce5fbd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 136 additions and 14 deletions

View File

@ -7,7 +7,7 @@ using Robust.Shared.Prototypes;
namespace Content.Client._DV.AACTablet.UI;
public sealed class AACBoundUserInterface : BoundUserInterface
public sealed partial class AACBoundUserInterface : BoundUserInterface // starcup: made partial
{
[ViewVariables]
private AACWindow? _window;
@ -23,16 +23,20 @@ public sealed class AACBoundUserInterface : BoundUserInterface
protected override void Open()
{
base.Open();
_window?.Close();
if (_window is { Disposed: false })
_window.Close();
_window = this.CreateWindow<AACWindow>();
_window.OnClose += Close;
_window.PhraseButtonPressed += OnPhraseButtonPressed;
_window.Typing += OnTyping;
_window.SubmitPressed += OnSubmit;
}
private void OnPhraseButtonPressed(List<ProtoId<QuickPhrasePrototype>> phraseId)
private void OnPhraseButtonPressed(List<ProtoId<QuickPhrasePrototype>> phraseId, string prefix)
{
SendMessage(new AACTabletSendPhraseMessage(phraseId));
SendMessage(new AACTabletSendPhraseMessage(phraseId, prefix)); // starcup: prefix parameter
}
private void OnTyping()

View File

@ -18,7 +18,14 @@
StyleClasses="AacCheckbox"
Margin="0 0 8 0"/>
<Control HorizontalExpand="True"/>
</BoxContainer>
<Control SetWidth="170" Margin="8 0 0 0"/>
<OptionButton Name="RadioChannels"
StyleClasses="OpenBoth"
SetWidth="120"
Margin="8 0 0 0"/>
</BoxContainer>
<!-- Buffer Display and Controls -->
<BoxContainer Orientation="Horizontal">
@ -29,7 +36,6 @@
StyleClasses="AacBufferText"
Margin="8 4"/>
</PanelContainer>
<Button Name="ClearButton"
Text="{Loc 'aac-tablet-backspace'}"
TextAlign="Center"

View File

@ -16,7 +16,7 @@ public sealed partial class AACWindow : FancyWindow
[Dependency] private readonly IPrototypeManager _prototype = default!;
private readonly List<QuickPhrasePrototype> _phrases;
private readonly Dictionary<string, List<QuickPhrasePrototype>> _filteredPhrases = new();
public event Action<List<ProtoId<QuickPhrasePrototype>>>? PhraseButtonPressed;
public event Action<List<ProtoId<QuickPhrasePrototype>>, string>? PhraseButtonPressed; // starcup: radio second parameter
public event Action? Typing;
public event Action? SubmitPressed;
@ -42,6 +42,7 @@ public sealed partial class AACWindow : FancyWindow
SearchBar.OnTextChanged += FilterSearch;
SendButton.OnPressed += SendBuffer;
ClearButton.OnPressed += BackspaceBuffer;
RadioChannels.OnItemSelected += OnChannelSelected; // starcup
PopulateGui();
FilterSearch(null);
}
@ -68,7 +69,7 @@ public sealed partial class AACWindow : FancyWindow
private void SendBuffer(BaseButton.ButtonEventArgs obj)
{
PhraseButtonPressed?.Invoke(_phraseBuffer);
PhraseButtonPressed?.Invoke(_phraseBuffer, Prefix); // starcup: Prefix
_phraseBuffer.Clear();
BufferedString.Text = string.Empty;
SubmitPressed?.Invoke();
@ -236,7 +237,7 @@ public sealed partial class AACWindow : FancyWindow
{
_phraseSingle.Clear();
_phraseSingle.Add(phraseId);
PhraseButtonPressed?.Invoke(_phraseSingle);
PhraseButtonPressed?.Invoke(_phraseSingle, Prefix); // starcup: Prefix parameter
SubmitPressed?.Invoke();
}
}

View File

@ -0,0 +1,16 @@
using Content.Shared._DV.AACTablet;
namespace Content.Client._DV.AACTablet.UI;
public sealed partial class AACBoundUserInterface
{
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not AACTabletBuiState msg)
return;
_window?.Update(msg);
}
}

View File

@ -0,0 +1,32 @@
using Content.Shared._DV.AACTablet;
using Content.Shared.Chat;
using Content.Shared.Radio;
using Robust.Client.UserInterface.Controls;
namespace Content.Client._DV.AACTablet.UI;
public sealed partial class AACWindow
{
private string Prefix => (string?)RadioChannels.SelectedMetadata ?? SharedChatSystem.LocalPrefix.ToString();
internal void Update(AACTabletBuiState msg)
{
RadioChannels.Clear();
var id = 0;
RadioChannels.AddItem("Local", id);
RadioChannels.SetItemMetadata(RadioChannels.GetIdx(id), SharedChatSystem.LocalPrefix.ToString());
foreach (var channel in msg.RadioChannels)
{
var channelProto = _prototype.Index<RadioChannelPrototype>(channel);
RadioChannels.AddItem(channelProto.LocalizedName, ++id);
RadioChannels.SetItemMetadata(RadioChannels.GetIdx(id), string.Concat(SharedChatSystem.RadioChannelPrefix, channelProto.KeyCode));
}
}
private void OnChannelSelected(OptionButton.ItemSelectedEventArgs args)
{
RadioChannels.SelectId(args.Id);
}
}

View File

@ -5,17 +5,20 @@ using Content.Server.Speech.Components;
using Content.Shared._DV.AACTablet;
using Content.Shared.Database;
using Content.Shared.IdentityManagement;
using Content.Shared.Radio.Components;
using Robust.Server.GameObjects; // starcup
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Server._DV.AACTablet;
public sealed class AACTabletSystem : EntitySystem
public sealed partial class AACTabletSystem : EntitySystem // starcup: made partial
{
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly UserInterfaceSystem _userInterface = default!; // starcup
private readonly List<string> _localisedPhrases = [];
@ -25,6 +28,13 @@ public sealed class AACTabletSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<AACTabletComponent, AACTabletSendPhraseMessage>(OnSendPhrase);
// begin starcup
Subs.BuiEvents<AACTabletComponent>(AACTabletKey.Key, subs =>
{
subs.Event<BoundUIOpenedEvent>(OnBoundUIOpened);
});
// end starcup
}
private void OnSendPhrase(Entity<AACTabletComponent> ent, ref AACTabletSendPhraseMessage message)
@ -49,14 +59,20 @@ public sealed class AACTabletSystem : EntitySystem
if (_localisedPhrases.Count <= 0)
return;
// begin starcup: Radio support
EnsureComp<VoiceOverrideComponent>(ent).NameOverride = speakerName;
// Set the player's currently available channels before sending the message
EnsureComp(ent, out IntrinsicRadioTransmitterComponent transmitter);
transmitter.Channels = GetAvailableChannels(message.Actor);
// end starcup
// L5 — save the message for logging
var messageToSend = string.Join(" ", _localisedPhrases);
_chat.TrySendInGameICMessage(ent,
messageToSend,
message.Prefix + messageToSend,
InGameICChatType.Speak,
hideChat: false,
nameOverride: speakerName);

View File

@ -0,0 +1,31 @@
using Content.Shared.Radio.Components; // Delta-V
using Content.Shared._DV.AACTablet;
using Robust.Shared.Prototypes; // Delta-V
using Content.Shared.Radio; // Delta-V
namespace Content.Server._DV.AACTablet;
public sealed partial class AACTabletSystem
{
private HashSet<ProtoId<RadioChannelPrototype>> GetAvailableChannels(EntityUid entity) // Delta-V
{
var channels = new HashSet<ProtoId<RadioChannelPrototype>>(); // Delta-V
// Get all the intrinsic radio channels (IPCs, implants)
if (TryComp(entity, out ActiveRadioComponent? intrinsicRadio))
channels.UnionWith(intrinsicRadio.Channels);
// Get the user's headset channels, if any
if (TryComp(entity, out WearingHeadsetComponent? headset)
&& TryComp(headset.Headset, out ActiveRadioComponent? headsetRadio))
channels.UnionWith(headsetRadio.Channels);
return channels;
}
private void OnBoundUIOpened(Entity<AACTabletComponent> ent, ref BoundUIOpenedEvent args)
{
var state = new AACTabletBuiState(GetAvailableChannels(args.Actor));
_userInterface.SetUiState(args.Entity, AACTabletKey.Key, state);
}
}

View File

@ -0,0 +1,11 @@
using Content.Shared.Radio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared._DV.AACTablet;
[Serializable, NetSerializable]
public sealed class AACTabletBuiState(HashSet<ProtoId<RadioChannelPrototype>> radioChannels) : BoundUserInterfaceState
{
public HashSet<ProtoId<RadioChannelPrototype>> RadioChannels = radioChannels;
}

View File

@ -11,7 +11,8 @@ public enum AACTabletKey : byte
}
[Serializable, NetSerializable]
public sealed class AACTabletSendPhraseMessage(List<ProtoId<QuickPhrasePrototype>> phraseIds) : BoundUserInterfaceMessage
public sealed class AACTabletSendPhraseMessage(List<ProtoId<QuickPhrasePrototype>> phraseIds, string prefix) : BoundUserInterfaceMessage // starcup: added prefix
{
public List<ProtoId<QuickPhrasePrototype>> PhraseIds = phraseIds;
public string Prefix = prefix; // starcup: radio-enabled aac
}

View File

@ -40,5 +40,9 @@
type: AACBoundUserInterface
- type: Speech
speechSounds: Alto
- type: AACTablet
- type: VoiceMask
- type: AACTablet
- type: IntrinsicRadioTransmitter # starcup
- type: Grammar # starcup
attributes:
proper: True