aac tablet cleanup (#3483)

* localized AAC tablet window

* no writing novels

* gleep

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas 2025-04-16 19:12:13 +01:00 committed by GitHub
parent ae2e430c0d
commit 0cef9216d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 5 deletions

View File

@ -1,15 +1,15 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="AAC Tablet"
Title="acc-tablet-title"
Resizable="True"
SetSize="540 300"
MinSize="540 300">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<CheckBox Name="ShouldBuffer" Text="Combine"/>
<CheckBox Name="ShouldBuffer" Text="aac-tablet-combine"/>
<LineEdit Name="BufferedString" Editable="False" HorizontalExpand="True"/>
<Button Name="ClearButton" Text="Backspace" TextAlign="Center"/>
<Button Name="SendButton" Text="Send" TextAlign="Center"/>
<Button Name="ClearButton" Text="aac-tablet-backspace" TextAlign="Center"/>
<Button Name="SendButton" Text="aac-tablet-send" TextAlign="Center"/>
</BoxContainer>
<TabContainer Name="WindowBody" TabTitle="Search" VerticalExpand="True" MouseFilter="Pass">
<BoxContainer Orientation="Vertical" Name="Search" MinSize="540 200">

View File

@ -25,6 +25,8 @@ public sealed partial class AACWindow : FancyWindow
private const int ButtonWidth =
(int)((ParentWidth - SpaceWidth * 2) / ColumnCount - SpaceWidth * ((ColumnCount - 1f) / ColumnCount));
public const int MaxPhrases = 10; // no writing novels
private readonly List<ProtoId<QuickPhrasePrototype>> _phraseBuffer = [];
private readonly List<ProtoId<QuickPhrasePrototype>> _phraseSingle = [];
@ -32,6 +34,7 @@ public sealed partial class AACWindow : FancyWindow
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_phrases = _prototype.EnumeratePrototypes<QuickPhrasePrototype>().ToList();
_phrases.Sort((a, b) => string.CompareOrdinal(a.Group, b.Group));
SearchBar.OnTextChanged += FilterSearch;
@ -217,6 +220,10 @@ public sealed partial class AACWindow : FancyWindow
{
if (ShouldBuffer.Pressed)
{
// there's no user feedback but you shouldn't be writing novels anyway
if (_phraseBuffer.Count >= MaxPhrases)
return;
_phraseBuffer.Add(phraseId);
UpdateBufferText();
}

View File

@ -15,6 +15,8 @@ public sealed class AACTabletSystem : EntitySystem
private readonly List<string> _localisedPhrases = [];
public const int MaxPhrases = 10; // no writing novels
public override void Initialize()
{
base.Initialize();
@ -23,7 +25,7 @@ public sealed class AACTabletSystem : EntitySystem
private void OnSendPhrase(Entity<AACTabletComponent> ent, ref AACTabletSendPhraseMessage message)
{
if (ent.Comp.NextPhrase > _timing.CurTime)
if (ent.Comp.NextPhrase > _timing.CurTime || message.PhraseIds.Count > MaxPhrases)
return;
var senderName = Identity.Entity(message.Actor, EntityManager);

View File

@ -0,0 +1,4 @@
aac-tablet-title = AAC Tablet
aac-tablet-combine = Combine
aac-tablet-backspace = Backspace
aac-tablet-send = Send