1
0

EmergencyConsoleWindow.xaml.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Content.Client.Computer;
  2. using Content.Client.UserInterface.Controls;
  3. using Content.Shared.Shuttles.BUIStates;
  4. using Content.Shared.Shuttles.Events;
  5. using Robust.Client.AutoGenerated;
  6. using Robust.Client.Graphics;
  7. using Robust.Client.UserInterface.Controls;
  8. using Robust.Client.UserInterface.XAML;
  9. using Robust.Shared.Timing;
  10. namespace Content.Client.Shuttles.UI;
  11. [GenerateTypedNameReferences]
  12. public sealed partial class EmergencyConsoleWindow : FancyWindow,
  13. IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
  14. {
  15. private readonly IGameTiming _timing;
  16. private TimeSpan? _earlyLaunchTime;
  17. public EmergencyConsoleWindow()
  18. {
  19. _timing = IoCManager.Resolve<IGameTiming>();
  20. RobustXamlLoader.Load(this);
  21. }
  22. public void SetupComputerWindow(ComputerBoundUserInterfaceBase cb)
  23. {
  24. RepealAllButton.OnPressed += args =>
  25. {
  26. OnRepealAllPressed(cb, args);
  27. };
  28. AuthorizeButton.OnPressed += args =>
  29. {
  30. OnAuthorizePressed(cb, args);
  31. };
  32. RepealButton.OnPressed += args =>
  33. {
  34. OnRepealPressed(cb, args);
  35. };
  36. }
  37. private void OnRepealAllPressed(ComputerBoundUserInterfaceBase cb, BaseButton.ButtonEventArgs obj)
  38. {
  39. cb.SendMessage(new EmergencyShuttleRepealAllMessage());
  40. }
  41. private void OnRepealPressed(ComputerBoundUserInterfaceBase cb, BaseButton.ButtonEventArgs obj)
  42. {
  43. cb.SendMessage(new EmergencyShuttleRepealMessage());
  44. }
  45. private void OnAuthorizePressed(ComputerBoundUserInterfaceBase cb, BaseButton.ButtonEventArgs obj)
  46. {
  47. cb.SendMessage(new EmergencyShuttleAuthorizeMessage());
  48. }
  49. public void UpdateState(EmergencyConsoleBoundUserInterfaceState scc)
  50. {
  51. // TODO: Loc and cvar for this.
  52. _earlyLaunchTime = scc.EarlyLaunchTime;
  53. AuthorizationsContainer.DisposeAllChildren();
  54. var remainingAuths = scc.AuthorizationsRequired - scc.Authorizations.Count;
  55. AuthorizationCount.Text = Loc.GetString("emergency-shuttle-ui-remaining", ("remaining", remainingAuths));
  56. foreach (var auth in scc.Authorizations)
  57. {
  58. AuthorizationsContainer.AddChild(new Label
  59. {
  60. Text = auth,
  61. FontColorOverride = Color.Lime,
  62. });
  63. }
  64. }
  65. protected override void Draw(DrawingHandleScreen handle)
  66. {
  67. base.Draw(handle);
  68. if (_earlyLaunchTime == null)
  69. {
  70. Countdown.Text = "00:10";
  71. }
  72. else
  73. {
  74. var remaining = _earlyLaunchTime.Value - _timing.CurTime;
  75. if (remaining < TimeSpan.Zero)
  76. remaining = TimeSpan.Zero;
  77. Countdown.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
  78. }
  79. }
  80. }