diff --git a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs index 77a31074a62..42eec583f81 100644 --- a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs @@ -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; @@ -51,6 +53,7 @@ public override void Initialize() SubscribeLocalEvent(OnListen); SubscribeLocalEvent(OnAttemptListen); SubscribeLocalEvent(OnPowerChanged); + SubscribeLocalEvent>(OnGetAltVerbs); // Frontier SubscribeLocalEvent(OnSpeakerInit); SubscribeLocalEvent(OnActivateSpeaker); @@ -366,6 +369,44 @@ private void UpdateHandheldRadioUi(Entity radio) #endregion // Nuclear-14-End + // Frontier Start + /// + /// Adds an alt verb allowing for the mic to be toggled easily. + /// + private void OnGetAltVerbs(EntityUid uid, RadioMicrophoneComponent microphone, GetVerbsEvent 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); + } + + /// + /// A mic toggle for both radios and intercoms. + /// + 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(uid, out var intercom)) + { + intercom.MicrophoneEnabled = microphone.Enabled; + Dirty((uid, intercom)); + } + } + // Frontier End + + // Frontier: init intercom with map private void OnMapInit(EntityUid uid, IntercomComponent ent, MapInitEvent args) { diff --git a/Resources/Locale/en-US/radio/components/handheld-radio-component.ftl b/Resources/Locale/en-US/radio/components/handheld-radio-component.ftl index ad637b0c56d..1933c19a935 100644 --- a/Resources/Locale/en-US/radio/components/handheld-radio-component.ftl +++ b/Resources/Locale/en-US/radio/components/handheld-radio-component.ftl @@ -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 \ No newline at end of file +# Nuclear-14-End