|
| 1 | +using Content.Client.UserInterface.Controls; |
| 2 | +using Content.Shared._Sunrise.Boss.Systems; |
| 3 | +using Robust.Client.AutoGenerated; |
| 4 | +using Robust.Client.UserInterface.XAML; |
| 5 | +using Robust.Shared.Timing; |
| 6 | + |
| 7 | +namespace Content.Client._Sunrise.Boss.UI; |
| 8 | + |
| 9 | +[GenerateTypedNameReferences] |
| 10 | +public sealed partial class HellSpawnArenaConsoleWindow : FancyWindow |
| 11 | +{ |
| 12 | + private readonly IGameTiming _timing; |
| 13 | + |
| 14 | + public TimeSpan? ActivationTime; |
| 15 | + public HellSpawnBossStatus State = HellSpawnBossStatus.Idle; |
| 16 | + |
| 17 | + public HellSpawnArenaConsoleWindow() |
| 18 | + { |
| 19 | + IoCManager.InjectDependencies(this); |
| 20 | + RobustXamlLoader.Load(this); |
| 21 | + |
| 22 | + _timing = IoCManager.Resolve<IGameTiming>(); |
| 23 | + |
| 24 | + TravelButton.OnPressed += _ => TravelButtonPressed?.Invoke(); |
| 25 | + |
| 26 | + StatusLabel.Text = Loc.GetString("hellspawn-arena-console-status-idle"); |
| 27 | + } |
| 28 | + |
| 29 | + public event Action? TravelButtonPressed; |
| 30 | + |
| 31 | + public void UpdateState(HellSpawnArenaConsoleUiState state) |
| 32 | + { |
| 33 | + // TravelButton.Disabled = state.Status == HellSpawnBossStatus.InProgress; |
| 34 | + |
| 35 | + if (state.ActivationTime != null) |
| 36 | + ActivationTime = state.ActivationTime; |
| 37 | + |
| 38 | + State = state.CurrentStatus; |
| 39 | + } |
| 40 | + |
| 41 | + protected override void FrameUpdate(FrameEventArgs args) |
| 42 | + { |
| 43 | + base.FrameUpdate(args); |
| 44 | + StatusLabel.Text = State switch |
| 45 | + { |
| 46 | + HellSpawnBossStatus.Idle => Loc.GetString("hellspawn-arena-console-status-idle"), |
| 47 | + HellSpawnBossStatus.Cooldown => Loc.GetString("hellspawn-arena-console-status-cooldown"), |
| 48 | + HellSpawnBossStatus.InProgress => Loc.GetString("hellspawn-arena-console-status-inprogress"), |
| 49 | + _ => StatusLabel.Text, |
| 50 | + }; |
| 51 | + switch (State) |
| 52 | + { |
| 53 | + case HellSpawnBossStatus.Idle: |
| 54 | + if (ActivationTime != null && ActivationTime.Value > _timing.CurTime) |
| 55 | + { |
| 56 | + TravelButton.Text = $"{(ActivationTime.Value - _timing.CurTime).TotalSeconds.ToString()}"; |
| 57 | + TravelButton.Disabled = true; |
| 58 | + } |
| 59 | + else |
| 60 | + { |
| 61 | + TravelButton.Text = Loc.GetString("hellspawn-arena-console-ready"); |
| 62 | + TravelButton.Disabled = false; |
| 63 | + } |
| 64 | + |
| 65 | + break; |
| 66 | + case HellSpawnBossStatus.Cooldown: |
| 67 | + if (ActivationTime != null && ActivationTime.Value > _timing.CurTime) |
| 68 | + { |
| 69 | + TravelButton.Text = $"{(ActivationTime.Value - _timing.CurTime).TotalSeconds.ToString()}"; |
| 70 | + TravelButton.Disabled = true; |
| 71 | + } |
| 72 | + else |
| 73 | + { |
| 74 | + TravelButton.Text = Loc.GetString("hellspawn-arena-console-ready"); |
| 75 | + TravelButton.Disabled = false; |
| 76 | + } |
| 77 | + |
| 78 | + break; |
| 79 | + case HellSpawnBossStatus.InProgress: |
| 80 | + break; |
| 81 | + } |
| 82 | + } |
| 83 | +} |
0 commit comments