From bf42602a7062096cb1d3c490c3158a2bdfd8a0de Mon Sep 17 00:00:00 2001 From: Alkheemist Date: Thu, 19 Dec 2024 22:03:35 +1100 Subject: [PATCH 1/4] Added alt verb to toggle handicomms --- .../Radio/EntitySystems/RadioDeviceSystem.cs | 24 +++++++++++++++++++ .../components/handheld-radio-component.ftl | 5 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs index 77a31074a62..b7b3dee3e46 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); SubscribeLocalEvent(OnSpeakerInit); SubscribeLocalEvent(OnActivateSpeaker); @@ -366,6 +369,27 @@ 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 || args.Hands == null) + 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 = () => ToggleRadioMicrophone(uid, args.User, false, microphone) + }; + args.Verbs.Add(verb); + } + + // 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 From 12a1c67f432607ed3dc62cb147e247391e0ddbe5 Mon Sep 17 00:00:00 2001 From: Alkheemist Date: Thu, 19 Dec 2024 22:37:27 +1100 Subject: [PATCH 2/4] remove extraneous conditional on the alt verb --- Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs index b7b3dee3e46..06cac0f15c0 100644 --- a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs @@ -375,7 +375,7 @@ private void UpdateHandheldRadioUi(Entity radio) /// private void OnGetAltVerbs(EntityUid uid, RadioMicrophoneComponent microphone, GetVerbsEvent args) { - if (!args.CanInteract || !args.CanAccess || args.Hands == null) + if (!args.CanInteract || !args.CanAccess) return; AlternativeVerb verb = new() From 26306db84a2e7b65a19afdb687e9e45acc26e9ae Mon Sep 17 00:00:00 2001 From: Whatstone Date: Tue, 24 Dec 2024 11:11:15 -0500 Subject: [PATCH 3/4] Comment alt verb subscription --- Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs index 06cac0f15c0..0c36bccaf2e 100644 --- a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs @@ -53,7 +53,7 @@ public override void Initialize() SubscribeLocalEvent(OnListen); SubscribeLocalEvent(OnAttemptListen); SubscribeLocalEvent(OnPowerChanged); - SubscribeLocalEvent>(OnGetAltVerbs); + SubscribeLocalEvent>(OnGetAltVerbs); // Frontier SubscribeLocalEvent(OnSpeakerInit); SubscribeLocalEvent(OnActivateSpeaker); From a4dc608ef224a7120e0fd7fda8cd492a2950cc88 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Tue, 24 Dec 2024 11:47:57 -0500 Subject: [PATCH 4/4] RadioDeviceSystem: check intercom access, state --- .../Radio/EntitySystems/RadioDeviceSystem.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs index 0c36bccaf2e..42eec583f81 100644 --- a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs @@ -382,11 +382,28 @@ private void OnGetAltVerbs(EntityUid uid, RadioMicrophoneComponent microphone, G { Text = Loc.GetString("handheld-radio-component-toggle"), Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")), - Act = () => ToggleRadioMicrophone(uid, args.User, false, microphone) + 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