GasAnalyzerBoundUserInterface.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Robust.Client.GameObjects;
  2. using Robust.Client.UserInterface;
  3. using static Content.Shared.Atmos.Components.GasAnalyzerComponent;
  4. namespace Content.Client.Atmos.UI
  5. {
  6. public sealed class GasAnalyzerBoundUserInterface : BoundUserInterface
  7. {
  8. [ViewVariables]
  9. private GasAnalyzerWindow? _window;
  10. public GasAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
  11. {
  12. }
  13. protected override void Open()
  14. {
  15. base.Open();
  16. _window = this.CreateWindowCenteredLeft<GasAnalyzerWindow>();
  17. }
  18. protected override void ReceiveMessage(BoundUserInterfaceMessage message)
  19. {
  20. if (_window == null)
  21. return;
  22. if (message is not GasAnalyzerUserMessage cast)
  23. return;
  24. _window.Populate(cast);
  25. }
  26. /// <summary>
  27. /// Closes UI and tells the server to disable the analyzer
  28. /// </summary>
  29. private void OnClose()
  30. {
  31. SendMessage(new GasAnalyzerDisableMessage());
  32. Close();
  33. }
  34. protected override void Dispose(bool disposing)
  35. {
  36. base.Dispose(disposing);
  37. if (disposing)
  38. _window?.Dispose();
  39. }
  40. }
  41. }