Files
crystall-punk-14/Content.Client/Disposal/UI/DisposalRouterBoundUserInterface.cs

50 lines
1.4 KiB
C#
Raw Normal View History

using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
2021-06-09 22:19:39 +02:00
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
2021-06-09 22:19:39 +02:00
namespace Content.Client.Disposal.UI
{
/// <summary>
/// Initializes a <see cref="DisposalRouterWindow"/> and updates it when new server messages are received.
/// </summary>
[UsedImplicitly]
public sealed class DisposalRouterBoundUserInterface : BoundUserInterface
{
2023-07-08 09:02:17 -07:00
[ViewVariables]
private DisposalRouterWindow? _window;
2023-07-08 09:02:17 -07:00
public DisposalRouterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = this.CreateWindow<DisposalRouterWindow>();
_window.Confirm.OnPressed += _ => ButtonPressed(UiAction.Ok, _window.TagInput.Text);
_window.TagInput.OnTextEntered += args => ButtonPressed(UiAction.Ok, args.Text);
}
private void ButtonPressed(UiAction action, string tag)
{
SendMessage(new UiActionMessage(action, tag));
Close();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not DisposalRouterUserInterfaceState cast)
{
return;
}
_window?.UpdateState(cast);
}
}
}