Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an Alt verb to handicomms, to allow more convenient toggling #2590

Merged
merged 8 commits into from
Dec 24, 2024
41 changes: 41 additions & 0 deletions Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Robust.Server.GameObjects; // Nuclear-14
using Robust.Shared.Prototypes;
using Content.Shared.Access.Systems; // Frontier
using Content.Shared.Verbs; //Frontier
using Robust.Shared.Utility; //Frontier

namespace Content.Server.Radio.EntitySystems;

Expand Down Expand Up @@ -51,6 +53,7 @@ public override void Initialize()
SubscribeLocalEvent<RadioMicrophoneComponent, ListenEvent>(OnListen);
SubscribeLocalEvent<RadioMicrophoneComponent, ListenAttemptEvent>(OnAttemptListen);
SubscribeLocalEvent<RadioMicrophoneComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<RadioMicrophoneComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs); // Frontier

SubscribeLocalEvent<RadioSpeakerComponent, ComponentInit>(OnSpeakerInit);
SubscribeLocalEvent<RadioSpeakerComponent, ActivateInWorldEvent>(OnActivateSpeaker);
Expand Down Expand Up @@ -366,6 +369,44 @@ private void UpdateHandheldRadioUi(Entity<RadioMicrophoneComponent> radio)
#endregion
// Nuclear-14-End

// Frontier Start
/// <summary>
/// Adds an alt verb allowing for the mic to be toggled easily.
/// </summary>
private void OnGetAltVerbs(EntityUid uid, RadioMicrophoneComponent microphone, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
return;

AlternativeVerb verb = new()
{
Text = Loc.GetString("handheld-radio-component-toggle"),
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
Act = () => ToggleRadioOrIntercomMic(uid, microphone, args.User)
};
args.Verbs.Add(verb);
}

/// <summary>
/// A mic toggle for both radios and intercoms.
/// </summary>
private void ToggleRadioOrIntercomMic(EntityUid uid, RadioMicrophoneComponent microphone, EntityUid user)
{
if (!_access.IsAllowed(user, uid))
return;
if (microphone.PowerRequired && !this.IsPowered(uid, EntityManager))
return;

ToggleRadioMicrophone(uid, user, false, microphone);
if (TryComp<IntercomComponent>(uid, out var intercom))
{
intercom.MicrophoneEnabled = microphone.Enabled;
Dirty<IntercomComponent>((uid, intercom));
}
}
// Frontier End


// Frontier: init intercom with map
private void OnMapInit(EntityUid uid, IntercomComponent ent, MapInitEvent args)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ handheld-radio-component-off-state = off
handheld-radio-component-channel-set = Channel set to {$channel}
handheld-radio-component-chennel-examine = The current channel is {$channel}.

# Frontier
handheld-radio-component-toggle = Toggle Mic

# Nuclear-14-Start
handheld-radio-menu-title = Handheld radio
handheld-radio-current-text-frequency = Broadcast frequency
handheld-radio-button-text-mic = Mic.
handheld-radio-button-text-speaker = Spkr.
handheld-radio-flavor-text-left = HandiComms, 1000-3000 kHz
# Nuclear-14-End
# Nuclear-14-End
Loading