Predict and cleanup RingerComponent (#35907)

* clean up most stuff

* move to shared

* works

* shuffle shit around

* oops! access

* fixes

* todo: everything

* SUFFERING

* curse you
This commit is contained in:
Milon
2025-04-19 15:55:05 +02:00
committed by GitHub
parent e214eb7a28
commit 6138fcdce9
18 changed files with 645 additions and 405 deletions

View File

@@ -1,6 +1,6 @@
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Content.Shared.PDA;
using Robust.Client.UserInterface.Controls;
@@ -8,15 +8,21 @@ using Robust.Client.UserInterface.Controls;
namespace Content.Client.PDA.Ringer
{
[GenerateTypedNameReferences]
public sealed partial class RingtoneMenu : DefaultWindow
public sealed partial class RingtoneMenu : FancyWindow
{
public string[] PreviousNoteInputs = new[] { "A", "A", "A", "A", "A", "A" };
public LineEdit[] RingerNoteInputs = default!;
public LineEdit[] RingerNoteInputs;
public event Action? SetRingtoneButtonPressed;
public event Action? TestRingtoneButtonPressed;
public RingtoneMenu()
{
RobustXamlLoader.Load(this);
SetRingerButton.OnPressed += _ => SetRingtoneButtonPressed?.Invoke();
TestRingerButton.OnPressed += _ => TestRingtoneButtonPressed?.Invoke();
RingerNoteInputs = new[] { RingerNoteOneInput, RingerNoteTwoInput, RingerNoteThreeInput, RingerNoteFourInput, RingerNoteFiveInput, RingerNoteSixInput };
for (var i = 0; i < RingerNoteInputs.Length; ++i)
@@ -43,14 +49,28 @@ namespace Content.Client.PDA.Ringer
foo();
input.CursorPosition = input.Text.Length; // Resets caret position to the end of the typed input
};
input.OnTextChanged += _ =>
{
input.Text = input.Text.ToUpper();
if (!IsNote(input.Text))
input.OnTextChanged += args =>
{
// Convert to uppercase
var upperText = args.Text.ToUpper();
// Filter to only valid notes
var newText = upperText;
if (!IsNote(newText))
{
newText = PreviousNoteInputs[index];
input.AddStyleClass("Caution");
}
else
{
PreviousNoteInputs[index] = newText;
input.RemoveStyleClass("Caution");
}
// Only update if there's a change
if (newText != input.Text)
input.Text = newText;
};
}
}