Files
tbd-station-14/Content.Client/Radio/Ui/IntercomBoundUserInterface.cs
Nemanja cb0ba66be3 Revert "Remove some BUI boilerplate" (#30214)
Revert "Remove some BUI boilerplate (#28399)"

This reverts commit cbf329a82d.
2024-07-20 20:42:27 -04:00

56 lines
1.2 KiB
C#

using Content.Shared.Radio;
using Content.Shared.Radio.Components;
using JetBrains.Annotations;
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();
var comp = EntMan.GetComponent<IntercomComponent>(Owner);
_menu = new((Owner, comp));
_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();
}
public void Update(Entity<IntercomComponent> ent)
{
_menu?.Update(ent);
}
}