Remove some BUI boilerplate (#28399)

* Remove some BUI boilerplate

- The disposals overrides got removed due to the helper method handling it.
- Replace window creation with CreateWindow helper.
- Fixed some stinky code which would cause exceptions.

* More

* moar

* weh

* done

* More BUIs

* More updates

* weh

* moar

* look who it is

* weh

* merge

* weh

* fixes
This commit is contained in:
metalgearsloth
2024-07-20 15:40:16 +10:00
committed by GitHub
parent 4aba9ec131
commit cbf329a82d
137 changed files with 1094 additions and 1753 deletions

View File

@@ -9,42 +9,44 @@ namespace Content.Client.MachineLinking.UI;
[GenerateTypedNameReferences]
public sealed partial class SignalTimerWindow : DefaultWindow
{
[Dependency] private readonly IGameTiming _timing = default!;
private const int MaxTextLength = 5;
public event Action<string>? OnCurrentTextChanged;
public event Action<string>? OnCurrentDelayMinutesChanged;
public event Action<string>? OnCurrentDelaySecondsChanged;
private readonly SignalTimerBoundUserInterface _owner;
private TimeSpan? _triggerTime;
private bool _timerStarted;
public SignalTimerWindow(SignalTimerBoundUserInterface owner)
public event Action? OnStartTimer;
public SignalTimerWindow()
{
RobustXamlLoader.Load(this);
_owner = owner;
IoCManager.InjectDependencies(this);
CurrentTextEdit.OnTextChanged += e => OnCurrentTextChange(e.Text);
CurrentDelayEditMinutes.OnTextChanged += e => OnCurrentDelayMinutesChange(e.Text);
CurrentDelayEditSeconds.OnTextChanged += e => OnCurrentDelaySecondsChange(e.Text);
StartTimer.OnPressed += _ => OnStartTimer();
StartTimer.OnPressed += _ => StartTimerWeh();
}
public void OnStartTimer()
private void StartTimerWeh()
{
if (!_timerStarted)
{
_timerStarted = true;
_triggerTime = _owner.GetCurrentTime() + GetDelay();
_triggerTime = _timing.CurTime + GetDelay();
}
else
{
SetTimerStarted(false);
}
_owner.OnStartTimer();
OnStartTimer?.Invoke();
}
protected override void FrameUpdate(FrameEventArgs args)
@@ -54,9 +56,9 @@ public sealed partial class SignalTimerWindow : DefaultWindow
if (!_timerStarted || _triggerTime == null)
return;
if (_owner.GetCurrentTime() < _triggerTime.Value)
if (_timing.CurTime < _triggerTime.Value)
{
StartTimer.Text = TextScreenSystem.TimeToString(_triggerTime.Value - _owner.GetCurrentTime());
StartTimer.Text = TextScreenSystem.TimeToString(_triggerTime.Value - _timing.CurTime);
}
else
{