Files
tbd-station-14/Content.Client/Radio/Ui/IntercomBoundUserInterface.cs
metalgearsloth cbf329a82d Remove some BUI boilerplate (#28399)
* Remove some BUI boilerplate

- The disposals overrides got removed due to the helper method handling it.
- Replace window creation with CreateWindow helper.
- Fixed some stinky code which would cause exceptions.

* More

* moar

* weh

* done

* More BUIs

* More updates

* weh

* moar

* look who it is

* weh

* merge

* weh

* fixes
2024-07-20 15:40:16 +10:00

50 lines
1.2 KiB
C#

using Content.Shared.Radio;
using Content.Shared.Radio.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
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 = this.CreateWindow<IntercomMenu>();
if (EntMan.TryGetComponent(Owner, out IntercomComponent? intercom))
{
_menu.Update((Owner, intercom));
}
_menu.OnMicPressed += enabled =>
{
SendMessage(new ToggleIntercomMicMessage(enabled));
};
_menu.OnSpeakerPressed += enabled =>
{
SendMessage(new ToggleIntercomSpeakerMessage(enabled));
};
_menu.OnChannelSelected += channel =>
{
SendMessage(new SelectIntercomChannelMessage(channel));
};
}
public void Update(Entity<IntercomComponent> ent)
{
_menu?.Update(ent);
}
}