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:
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user