Skip to content

Commit

Permalink
Add an Alt verb to handicomms, to allow more convenient toggling (#2590)
Browse files Browse the repository at this point in the history
* Added alt verb to toggle handicomms

* remove extraneous conditional on the alt verb

* Comment alt verb subscription

* RadioDeviceSystem: check intercom access, state

---------

Co-authored-by: Dvir <[email protected]>
Co-authored-by: Whatstone <[email protected]>
Co-authored-by: Whatstone <[email protected]>
  • Loading branch information
4 people authored Dec 24, 2024
1 parent 626515d commit 6242d7d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
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

0 comments on commit 6242d7d

Please sign in to comment.