AmeControllerBoundUserInterface.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Content.Shared.Ame.Components;
  2. using JetBrains.Annotations;
  3. using Robust.Client.UserInterface;
  4. namespace Content.Client.Ame.UI
  5. {
  6. [UsedImplicitly]
  7. public sealed class AmeControllerBoundUserInterface : BoundUserInterface
  8. {
  9. private AmeWindow? _window;
  10. public AmeControllerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
  11. {
  12. }
  13. protected override void Open()
  14. {
  15. base.Open();
  16. _window = this.CreateWindow<AmeWindow>();
  17. _window.OnAmeButton += ButtonPressed;
  18. }
  19. /// <summary>
  20. /// Update the ui each time new state data is sent from the server.
  21. /// </summary>
  22. /// <param name="state">
  23. /// Data of the <see cref="SharedReagentDispenserComponent"/> that this ui represents.
  24. /// Sent from the server.
  25. /// </param>
  26. protected override void UpdateState(BoundUserInterfaceState state)
  27. {
  28. base.UpdateState(state);
  29. var castState = (AmeControllerBoundUserInterfaceState) state;
  30. _window?.UpdateState(castState); //Update window state
  31. }
  32. public void ButtonPressed(UiButton button)
  33. {
  34. SendMessage(new UiButtonPressedMessage(button));
  35. }
  36. }
  37. }