Files
crystall-punk-14/Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2022-09-28 19:22:27 -07:00
using Content.Shared.VoiceMask;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
2022-09-28 19:22:27 -07:00
namespace Content.Client.VoiceMask;
public sealed class VoiceMaskBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _proto = default!;
2023-07-08 09:02:17 -07:00
[ViewVariables]
private VoiceMaskNameChangeWindow? _window;
public VoiceMaskBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
2022-09-28 19:22:27 -07:00
{
}
protected override void Open()
{
base.Open();
_window = new(_proto);
2022-09-28 19:22:27 -07:00
_window.OpenCentered();
_window.OnNameChange += OnNameSelected;
_window.OnVerbChange += verb => SendMessage(new VoiceMaskChangeVerbMessage(verb));
2022-09-28 19:22:27 -07:00
_window.OnClose += Close;
}
private void OnNameSelected(string name)
{
SendMessage(new VoiceMaskChangeNameMessage(name));
}
protected override void UpdateState(BoundUserInterfaceState state)
{
if (state is not VoiceMaskBuiState cast || _window == null)
{
return;
}
_window.UpdateState(cast.Name, cast.Verb);
2022-09-28 19:22:27 -07:00
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Close();
}
}