Skip to content

Commit

Permalink
Add option to disable bwoink sound. (#33782)
Browse files Browse the repository at this point in the history
* Add option to disable bwoink sound.

* Now it's working only with active admin status.

* No bwoink, only "notification sound"

* Moar changes

* Another one
  • Loading branch information
c4llv07e authored Jan 17, 2025
1 parent 5d9311d commit 4809ee2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/AudioTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<CheckBox Name="RestartSoundsCheckBox" Text="{Loc 'ui-options-restart-sounds'}" />
<CheckBox Name="EventMusicCheckBox" Text="{Loc 'ui-options-event-music'}" />
<CheckBox Name="AdminSoundsCheckBox" Text="{Loc 'ui-options-admin-sounds'}" />
<CheckBox Name="BwoinkSoundCheckBox" Text="{Loc 'ui-options-bwoink-sound'}" />
</BoxContainer>
</BoxContainer>
<ui:OptionsTabControlRow Name="Control" Access="Public" />
Expand Down
24 changes: 23 additions & 1 deletion Content.Client/Options/UI/Tabs/AudioTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Client.Administration.Managers;
using Content.Client.Audio;
using Content.Shared.CCVar;
using Robust.Client.Audio;
Expand All @@ -12,8 +13,9 @@ namespace Content.Client.Options.UI.Tabs;
[GenerateTypedNameReferences]
public sealed partial class AudioTab : Control
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IAudioManager _audio = default!;
[Dependency] private readonly IClientAdminManager _admin = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

public AudioTab()
{
Expand Down Expand Up @@ -61,10 +63,30 @@ public AudioTab()
Control.AddOptionCheckBox(CCVars.RestartSoundsEnabled, RestartSoundsCheckBox);
Control.AddOptionCheckBox(CCVars.EventMusicEnabled, EventMusicCheckBox);
Control.AddOptionCheckBox(CCVars.AdminSoundsEnabled, AdminSoundsCheckBox);
Control.AddOptionCheckBox(CCVars.BwoinkSoundEnabled, BwoinkSoundCheckBox);

Control.Initialize();
}

protected override void EnteredTree()
{
base.EnteredTree();
_admin.AdminStatusUpdated += UpdateAdminButtonsVisibility;
UpdateAdminButtonsVisibility();
}

protected override void ExitedTree()
{
base.ExitedTree();
_admin.AdminStatusUpdated -= UpdateAdminButtonsVisibility;
}


private void UpdateAdminButtonsVisibility()
{
BwoinkSoundCheckBox.Visible = _admin.IsActive();
}

private void OnMasterVolumeSliderChanged(float value)
{
// TODO: I was thinking of giving OptionsTabControlRow a flag to "set CVar immediately", but I'm deferring that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
public IAHelpUIHandler? UIHelper;
private bool _discordRelayActive;
private bool _hasUnreadAHelp;
private bool _bwoinkSoundEnabled;
private string? _aHelpSound;

public override void Initialize()
Expand All @@ -56,6 +57,7 @@ public override void Initialize()

_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
_config.OnValueChanged(CCVars.AHelpSound, v => _aHelpSound = v, true);
_config.OnValueChanged(CCVars.BwoinkSoundEnabled, v => _bwoinkSoundEnabled = v, true);
}

public void UnloadButton()
Expand Down Expand Up @@ -135,7 +137,7 @@ private void ReceivedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage
}
if (message.PlaySound && localPlayer.UserId != message.TrueSender)
{
if (_aHelpSound != null)
if (_aHelpSound != null && (_bwoinkSoundEnabled || !_adminManager.IsActive()))
_audio.PlayGlobal(_aHelpSound, Filter.Local(), false);
_clyde.RequestWindowAttention();
}
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/CCVar/CCVars.Sounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public sealed partial class CCVars
public static readonly CVarDef<bool> AdminSoundsEnabled =
CVarDef.Create("audio.admin_sounds_enabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);

public static readonly CVarDef<bool> BwoinkSoundEnabled =
CVarDef.Create("audio.bwoink_sound_enabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);

public static readonly CVarDef<string> AdminChatSoundPath =
CVarDef.Create("audio.admin_chat_sound_path",
"/Audio/Items/pop.ogg",
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ui-options-lobby-music = Lobby & Round-end Music
ui-options-restart-sounds = Round Restart Sounds
ui-options-event-music = Event Music
ui-options-admin-sounds = Play Admin Sounds
ui-options-bwoink-sound = Play AHelp Notification Sound
ui-options-volume-label = Volume
## Graphics menu
Expand Down

0 comments on commit 4809ee2

Please sign in to comment.