AtmosAlertsComputerBoundUserInterface.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Content.Shared.Atmos.Components;
  2. namespace Content.Client.Atmos.Consoles;
  3. public sealed class AtmosAlertsComputerBoundUserInterface : BoundUserInterface
  4. {
  5. [ViewVariables]
  6. private AtmosAlertsComputerWindow? _menu;
  7. public AtmosAlertsComputerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { }
  8. protected override void Open()
  9. {
  10. base.Open();
  11. _menu = new AtmosAlertsComputerWindow(this, Owner);
  12. _menu.OpenCentered();
  13. _menu.OnClose += Close;
  14. }
  15. protected override void UpdateState(BoundUserInterfaceState state)
  16. {
  17. base.UpdateState(state);
  18. var castState = (AtmosAlertsComputerBoundInterfaceState) state;
  19. EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
  20. _menu?.UpdateUI(xform?.Coordinates, castState.AirAlarms, castState.FireAlarms, castState.FocusData);
  21. }
  22. public void SendFocusChangeMessage(NetEntity? netEntity)
  23. {
  24. SendMessage(new AtmosAlertsComputerFocusChangeMessage(netEntity));
  25. }
  26. public void SendDeviceSilencedMessage(NetEntity netEntity, bool silenceDevice)
  27. {
  28. SendMessage(new AtmosAlertsComputerDeviceSilencedMessage(netEntity, silenceDevice));
  29. }
  30. protected override void Dispose(bool disposing)
  31. {
  32. base.Dispose(disposing);
  33. if (!disposing)
  34. return;
  35. _menu?.Dispose();
  36. }
  37. }