From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Wed, 19 Apr 2023 07:47:01 +0000 (-0400) Subject: [Entity] Brig Timers (#15285) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=31851e5468de067679ef88e925165e0f28ca64a1;p=space-station-14.git [Entity] Brig Timers (#15285) * brigtimer * ok * TextScreen w timer implementation * second commit * working brig timer * signal timers near completion * soon done * removed licenses, fixes noRotation on screens, minor edits * no message * no message * removed my last todos * removed csproj.rej?? * missed a thing with .yml and tests * fix tests * Update base_structureairlocks.yml * timespan type serialize * activation turned into comp * sloth review * Update timer.yml * small changes --------- Co-authored-by: CommieFlowers Co-authored-by: rolfero <45628623+rolfero@users.noreply.github.com> --- diff --git a/Content.Client/MachineLinking/UI/SignalTimerBoundUserInterface.cs b/Content.Client/MachineLinking/UI/SignalTimerBoundUserInterface.cs new file mode 100644 index 0000000000..e9cfba697f --- /dev/null +++ b/Content.Client/MachineLinking/UI/SignalTimerBoundUserInterface.cs @@ -0,0 +1,81 @@ +using Content.Shared.MachineLinking; +using Robust.Client.GameObjects; +using Robust.Shared.Timing; + +namespace Content.Client.MachineLinking.UI; + +public sealed class SignalTimerBoundUserInterface : BoundUserInterface +{ + [Dependency] private readonly IGameTiming _gameTiming = default!; + + private SignalTimerWindow? _window; + + public SignalTimerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + + _window = new SignalTimerWindow(this); + + if (State != null) + UpdateState(State); + + _window.OpenCentered(); + _window.OnClose += Close; + _window.OnCurrentTextChanged += OnTextChanged; + _window.OnCurrentDelayMinutesChanged += OnDelayChanged; + _window.OnCurrentDelaySecondsChanged += OnDelayChanged; + } + + public void OnStartTimer() + { + SendMessage(new SignalTimerStartMessage()); + } + + private void OnTextChanged(string newText) + { + SendMessage(new SignalTimerTextChangedMessage(newText)); + } + + private void OnDelayChanged(string newDelay) + { + if (_window == null) + return; + SendMessage(new SignalTimerDelayChangedMessage(_window.GetDelay())); + } + + public TimeSpan GetCurrentTime() + { + return _gameTiming.CurTime; + } + + /// + /// Update the UI state based on server-sent info + /// + /// + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (_window == null || state is not SignalTimerBoundUserInterfaceState cast) + return; + + _window.SetCurrentText(cast.CurrentText); + _window.SetCurrentDelayMinutes(cast.CurrentDelayMinutes); + _window.SetCurrentDelaySeconds(cast.CurrentDelaySeconds); + _window.SetShowText(cast.ShowText); + _window.SetTriggerTime(cast.TriggerTime); + _window.SetTimerStarted(cast.TimerStarted); + _window.SetHasAccess(cast.HasAccess); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (!disposing) return; + _window?.Dispose(); + } +} diff --git a/Content.Client/MachineLinking/UI/SignalTimerWindow.xaml b/Content.Client/MachineLinking/UI/SignalTimerWindow.xaml new file mode 100644 index 0000000000..b30bd1c5f2 --- /dev/null +++ b/Content.Client/MachineLinking/UI/SignalTimerWindow.xaml @@ -0,0 +1,17 @@ + + + + + + +