1
0

RoundEndSummaryUIController.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Content.Client.GameTicking.Managers;
  2. using Content.Shared.GameTicking;
  3. using Content.Shared.Input;
  4. using JetBrains.Annotations;
  5. using Robust.Client.Input;
  6. using Robust.Client.UserInterface.Controllers;
  7. using Robust.Shared.Input.Binding;
  8. using Robust.Shared.Player;
  9. namespace Content.Client.RoundEnd;
  10. [UsedImplicitly]
  11. public sealed class RoundEndSummaryUIController : UIController,
  12. IOnSystemLoaded<ClientGameTicker>
  13. {
  14. [Dependency] private readonly IInputManager _input = default!;
  15. private RoundEndSummaryWindow? _window;
  16. private void ToggleScoreboardWindow(ICommonSession? session = null)
  17. {
  18. if (_window == null)
  19. return;
  20. if (_window.IsOpen)
  21. {
  22. _window.Close();
  23. }
  24. else
  25. {
  26. _window.OpenCenteredRight();
  27. _window.MoveToFront();
  28. }
  29. }
  30. public void OpenRoundEndSummaryWindow(RoundEndMessageEvent message)
  31. {
  32. // Don't open duplicate windows (mainly for replays).
  33. if (_window?.RoundId == message.RoundId)
  34. return;
  35. _window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText,
  36. message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, EntityManager);
  37. }
  38. public void OnSystemLoaded(ClientGameTicker system)
  39. {
  40. _input.SetInputCommand(ContentKeyFunctions.ToggleRoundEndSummaryWindow,
  41. InputCmdHandler.FromDelegate(ToggleScoreboardWindow));
  42. }
  43. }