Files
crystall-punk-14/Content.Client/Fax/UI/FaxBoundUi.cs

68 lines
1.5 KiB
C#
Raw Normal View History

2022-12-11 21:06:11 +03:00
using Content.Shared.Fax;
2023-04-16 23:20:57 -07:00
using JetBrains.Annotations;
2022-12-11 21:06:11 +03:00
using Robust.Client.GameObjects;
namespace Content.Client.Fax.UI;
2023-04-16 23:20:57 -07:00
[UsedImplicitly]
2022-12-11 21:06:11 +03:00
public sealed class FaxBoundUi : BoundUserInterface
{
2023-07-08 09:02:17 -07:00
[ViewVariables]
2022-12-11 21:06:11 +03:00
private FaxWindow? _window;
2023-04-16 23:20:57 -07:00
2023-07-08 09:02:17 -07:00
public FaxBoundUi(EntityUid owner, Enum uiKey) : base(owner, uiKey)
2022-12-11 21:06:11 +03:00
{
}
protected override void Open()
{
base.Open();
_window = new FaxWindow();
_window.OpenCentered();
_window.OnClose += Close;
_window.CopyButtonPressed += OnCopyButtonPressed;
2022-12-11 21:06:11 +03:00
_window.SendButtonPressed += OnSendButtonPressed;
_window.RefreshButtonPressed += OnRefreshButtonPressed;
_window.PeerSelected += OnPeerSelected;
}
private void OnSendButtonPressed()
{
SendMessage(new FaxSendMessage());
}
private void OnCopyButtonPressed()
{
SendMessage(new FaxCopyMessage());
}
2022-12-11 21:06:11 +03:00
private void OnRefreshButtonPressed()
{
SendMessage(new FaxRefreshMessage());
}
private void OnPeerSelected(string address)
{
SendMessage(new FaxDestinationMessage(address));
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
2023-04-16 23:20:57 -07:00
2022-12-11 21:06:11 +03:00
if (_window == null || state is not FaxUiState cast)
return;
_window.UpdateState(cast);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
_window?.Dispose();
}
}