From 2b99b5e738258b6835d52b6c9c189ecf79c7055d Mon Sep 17 00:00:00 2001 From: poeMota Date: Fri, 26 Apr 2024 14:47:04 +0300 Subject: [PATCH] radio rework --- .../Ui/HandheldRadioBoundUserInterface.cs | 59 +++++++++++++++++ .../Radio/Ui/HandheldRadioMenu.xaml | 29 +++++++++ .../Radio/Ui/HandheldRadioMenu.xaml.cs | 36 ++++++++++ .../Components/RadioMicrophoneComponent.cs | 7 ++ .../Radio/EntitySystems/RadioDeviceSystem.cs | 65 ++++++++++++++++++- .../Radio/EntitySystems/RadioSystem.cs | 21 +++++- Content.Shared/Radio/SharedHandheldRadio.cs | 57 ++++++++++++++++ .../ss14-ru/radio/components/handheld.ftl | 6 ++ .../ru-RU/radio/components/handheld.ftl | 6 ++ .../Entities/Objects/Devices/radio.yml | 9 +++ 10 files changed, 291 insertions(+), 4 deletions(-) create mode 100644 Content.Client/Radio/Ui/HandheldRadioBoundUserInterface.cs create mode 100644 Content.Client/Radio/Ui/HandheldRadioMenu.xaml create mode 100644 Content.Client/Radio/Ui/HandheldRadioMenu.xaml.cs create mode 100644 Content.Shared/Radio/SharedHandheldRadio.cs create mode 100644 Resources/Locale/en-US/ss14-ru/radio/components/handheld.ftl create mode 100644 Resources/Locale/ru-RU/radio/components/handheld.ftl diff --git a/Content.Client/Radio/Ui/HandheldRadioBoundUserInterface.cs b/Content.Client/Radio/Ui/HandheldRadioBoundUserInterface.cs new file mode 100644 index 00000000000..c16d1649026 --- /dev/null +++ b/Content.Client/Radio/Ui/HandheldRadioBoundUserInterface.cs @@ -0,0 +1,59 @@ +using Content.Shared.Radio; +using JetBrains.Annotations; +using Robust.Client.GameObjects; + +namespace Content.Client.Radio.Ui; + + +[UsedImplicitly] +public sealed class HandheldRadioBoundUserInterface : BoundUserInterface +{ + [ViewVariables] + private HandheldRadioMenu? _menu; + + public HandheldRadioBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + + } + + protected override void Open() + { + base.Open(); + + _menu = new(); + + _menu.OnMicPressed += enabled => + { + SendMessage(new ToggleHandheldRadioMicMessage(enabled)); + }; + _menu.OnSpeakerPressed += enabled => + { + SendMessage(new ToggleHandheldRadioSpeakerMessage(enabled)); + }; + _menu.OnFrequencyChanged += frequency => + { + SendMessage(new SelectHandheldRadioFrequencyMessage(frequency)); + }; + + _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 HandheldRadioBoundUIState msg) + return; + + _menu?.Update(msg); + } +} diff --git a/Content.Client/Radio/Ui/HandheldRadioMenu.xaml b/Content.Client/Radio/Ui/HandheldRadioMenu.xaml new file mode 100644 index 00000000000..3877d1ead23 --- /dev/null +++ b/Content.Client/Radio/Ui/HandheldRadioMenu.xaml @@ -0,0 +1,29 @@ + + + + + + +