mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Adds frequencies to handheld radios. Ports [this PR](https://github.com/new-frontiers-14/frontier-station-14/pull/1833) with changes.  --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Added handheld radio frequencies, accessible by pressing your "Use Item" key while holding one. --------- Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com> (cherry picked from commit 19a350fc9ae0d958406b3d6018f71ab8af5447c4)
63 lines
1.5 KiB
C#
63 lines
1.5 KiB
C#
using Content.Shared._NC.Radio;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client._NC.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 =>
|
|
{
|
|
if (int.TryParse(frequency.Trim(), out var intFreq) && intFreq > 0)
|
|
SendMessage(new SelectHandheldRadioFrequencyMessage(intFreq));
|
|
else
|
|
SendMessage(new SelectHandheldRadioFrequencyMessage(-1)); // Query the current 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);
|
|
}
|
|
}
|