VoteUIController.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Content.Client.UserInterface.Screens;
  2. using Content.Client.UserInterface.Systems.Gameplay;
  3. using Content.Client.Voting;
  4. using JetBrains.Annotations;
  5. using Robust.Client.UserInterface.Controllers;
  6. namespace Content.Client.UserInterface.Systems.Vote;
  7. [UsedImplicitly]
  8. public sealed class VoteUIController : UIController
  9. {
  10. [Dependency] private readonly IVoteManager _votes = default!;
  11. public override void Initialize()
  12. {
  13. base.Initialize();
  14. var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
  15. gameplayStateLoad.OnScreenLoad += OnScreenLoad;
  16. gameplayStateLoad.OnScreenUnload += OnScreenUnload;
  17. }
  18. private void OnScreenLoad()
  19. {
  20. switch (UIManager.ActiveScreen)
  21. {
  22. case DefaultGameScreen game:
  23. _votes.SetPopupContainer(game.VoteMenu);
  24. break;
  25. case SeparatedChatGameScreen separated:
  26. _votes.SetPopupContainer(separated.VoteMenu);
  27. break;
  28. }
  29. }
  30. private void OnScreenUnload()
  31. {
  32. _votes.ClearPopupContainer();
  33. }
  34. }