Files
tbd-station-14/Content.Client/Radio/Ui/IntercomBoundUserInterface.cs
Nemanja 6dbfbc52c0 Good Intercoms (#17950)
* crystal anomaly

* Good intercoms

* fixes

* fix construction fail

* Revert "crystal anomaly"

This reverts commit 0d9e3f62ff82c79e72f882b9c7f4ca1b9c6e6dd8.

* migration
2023-07-11 17:58:18 -06:00

59 lines
1.3 KiB
C#

using Content.Shared.Radio;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.Radio.Ui;
[UsedImplicitly]
public sealed class IntercomBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private IntercomMenu? _menu;
public IntercomBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = new();
_menu.OnMicPressed += enabled =>
{
SendMessage(new ToggleIntercomMicMessage(enabled));
};
_menu.OnSpeakerPressed += enabled =>
{
SendMessage(new ToggleIntercomSpeakerMessage(enabled));
};
_menu.OnChannelSelected += channel =>
{
SendMessage(new SelectIntercomChannelMessage(channel));
};
_menu.OnClose += Close;
_menu.OpenCentered();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Close();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not IntercomBoundUIState msg)
return;
_menu?.Update(msg);
}
}