1
0

IFFConsoleBoundUserInterface.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Content.Client.Shuttles.UI;
  2. using Content.Shared.Shuttles.BUIStates;
  3. using Content.Shared.Shuttles.Events;
  4. using JetBrains.Annotations;
  5. using Robust.Client.GameObjects;
  6. using Robust.Client.UserInterface;
  7. namespace Content.Client.Shuttles.BUI;
  8. [UsedImplicitly]
  9. public sealed class IFFConsoleBoundUserInterface : BoundUserInterface
  10. {
  11. [ViewVariables]
  12. private IFFConsoleWindow? _window;
  13. public IFFConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
  14. {
  15. }
  16. protected override void Open()
  17. {
  18. base.Open();
  19. _window = this.CreateWindowCenteredLeft<IFFConsoleWindow>();
  20. _window.ShowIFF += SendIFFMessage;
  21. _window.ShowVessel += SendVesselMessage;
  22. }
  23. protected override void UpdateState(BoundUserInterfaceState state)
  24. {
  25. base.UpdateState(state);
  26. if (state is not IFFConsoleBoundUserInterfaceState bState)
  27. return;
  28. _window?.UpdateState(bState);
  29. }
  30. private void SendIFFMessage(bool obj)
  31. {
  32. SendMessage(new IFFShowIFFMessage()
  33. {
  34. Show = obj,
  35. });
  36. }
  37. private void SendVesselMessage(bool obj)
  38. {
  39. SendMessage(new IFFShowVesselMessage()
  40. {
  41. Show = obj,
  42. });
  43. }
  44. protected override void Dispose(bool disposing)
  45. {
  46. base.Dispose(disposing);
  47. if (disposing)
  48. {
  49. _window?.Close();
  50. _window = null;
  51. }
  52. }
  53. }