отключение ттс рации у гостов (#2629)

This commit is contained in:
Ligyb 2025-07-22 21:54:25 +05:00 committed by GitHub
parent 4d5de1bbc8
commit 30f8e8d4d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 4 deletions

View file

@ -25,6 +25,7 @@
<Label Text="{Loc 'ui-options-sunrise-general-audio'}" StyleClasses="LabelKeyText"/>
<CheckBox Name="TtsClientCheckBox" Text="{Loc 'ui-options-tts-enabled'}" />
<CheckBox Name="TtsClientCheckBoxQueue" Text="{Loc 'ui-options-tts-queue'}" />
<CheckBox Name="TtsRadioGhostCheckBox" Text="{Loc 'ui-options-tts-radio-ghost-enabled'}" />
<ui:OptionSlider Name="SliderTts" Title="{Loc 'ui-options-tts-volume'}" />
<ui:OptionSlider Name="SliderTtsRadio" Title="{Loc 'ui-options-tts-radio-volume'}" />
<ui:OptionSlider Name="SliderTtsAnnounce" Title="{Loc 'ui-options-tts-announce-volume'}" />

View file

@ -39,6 +39,7 @@ public sealed partial class ExtraTab : Control
Control.AddOptionCheckBox(SunriseCCVars.TTSClientEnabled, TtsClientCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.TTSClientQueueEnabled, TtsClientCheckBoxQueue);
Control.AddOptionCheckBox(SunriseCCVars.TTSRadioGhostEnabled, TtsRadioGhostCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.TapePlayerClientEnabled, TapePlayerClientCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.JumpSoundDisable, JumpSoundDisableCheckBox);
Control.AddOptionCheckBox(SunriseCCVars.VoteMusicDisable, VoteMusicDisableCheckBox);

View file

@ -1,7 +1,9 @@
using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared._Sunrise.TTS;
using Content.Shared.CCVar;
using Content.Shared.Ghost;
using Robust.Client.Audio;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Shared;
using Robust.Shared.Audio;
@ -25,6 +27,7 @@ public sealed class TTSSystem : EntitySystem
[Dependency] private readonly SharedAudioSystem _sharedAudio = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IDependencyCollection _dependencyCollection = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private ISawmill _sawmill = default!;
private static readonly MemoryContentRoot ContentRoot = new();
@ -35,6 +38,7 @@ public sealed class TTSSystem : EntitySystem
private int _fileIdx;
private float _volumeAnnounce;
private bool _isQueueEnabled;
private bool _ghostRadioEnabled;
private readonly Queue<QueuedTts> _ttsQueue = new();
private (EntityUid Entity, AudioComponent Component)? _currentPlaying;
private static readonly AudioResource EmptyAudioResource = new();
@ -62,6 +66,7 @@ public sealed class TTSSystem : EntitySystem
_cfg.OnValueChanged(SunriseCCVars.TTSAnnounceVolume, OnTtsAnnounceVolumeChanged, true);
_cfg.OnValueChanged(SunriseCCVars.TTSClientEnabled, OnTtsClientOptionChanged, true);
_cfg.OnValueChanged(SunriseCCVars.TTSClientQueueEnabled, OnTTSQueueOptionChanged, true);
_cfg.OnValueChanged(SunriseCCVars.TTSRadioGhostEnabled, OnTtsRadioGhostChanged, true);
SubscribeNetworkEvent<PlayTTSEvent>(OnPlayTTS);
SubscribeNetworkEvent<AnnounceTtsEvent>(OnAnnounceTTSPlay);
}
@ -74,6 +79,7 @@ public sealed class TTSSystem : EntitySystem
_cfg.UnsubValueChanged(SunriseCCVars.TTSAnnounceVolume, OnTtsAnnounceVolumeChanged);
_cfg.UnsubValueChanged(SunriseCCVars.TTSClientEnabled, OnTtsClientOptionChanged);
_cfg.UnsubValueChanged(SunriseCCVars.TTSClientQueueEnabled, OnTTSQueueOptionChanged);
_cfg.UnsubValueChanged(SunriseCCVars.TTSRadioGhostEnabled, OnTtsRadioGhostChanged);
ContentRoot.Clear();
_currentPlaying = null;
@ -109,6 +115,11 @@ public sealed class TTSSystem : EntitySystem
RaiseNetworkEvent(new ClientOptionTTSEvent(option));
}
private void OnTtsRadioGhostChanged(bool option)
{
_ghostRadioEnabled = option;
}
private void OnAnnounceTTSPlay(AnnounceTtsEvent ev)
{
if (_volumeAnnounce == 0)
@ -158,12 +169,19 @@ public sealed class TTSSystem : EntitySystem
if (volume == 0)
return;
if (ev.IsRadio && _isQueueEnabled)
if (ev.IsRadio)
{
var entry = new QueuedTts(ev.Data, TtsType.Radio);
var localEntity = _playerManager.LocalEntity;
if(!_ghostRadioEnabled && localEntity.HasValue && HasComp<GhostComponent>(localEntity.Value))
return;
_ttsQueue.Enqueue(entry);
return;
if (_isQueueEnabled)
{
var entry = new QueuedTts(ev.Data, TtsType.Radio);
_ttsQueue.Enqueue(entry);
return;
}
}
volume = SharedAudioSystem.GainToVolume(volume * ev.VolumeModifier);

View file

@ -39,6 +39,9 @@ public sealed partial class SunriseCCVars : CVars
public static readonly CVarDef<bool> TTSClientEnabled =
CVarDef.Create("tts.client_enabled", true, CVar.CLIENTONLY | CVar.ARCHIVE);
public static readonly CVarDef<bool> TTSRadioGhostEnabled =
CVarDef.Create("tts.radio_ghost_enabled", false, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Option to disable TTS queue in radio for client
/// </summary>

View file

@ -41,6 +41,7 @@ ui-options-admin-sounds = Музыка админов
ui-options-bwoink-sound = Воспроизводить звук уведомления АХелп
ui-options-tts-enabled = ТТС интеграция
ui-options-tts-queue = Использовать очередь для TTS рации?
ui-options-tts-radio-ghost-enabled = ТТС рации в призраке
ui-options-volume-label = Громкость
## Graphics menu