diff --git a/osu.Game/Audio/ISamplePlaybackDisabler.cs b/osu.Game/Audio/ISamplePlaybackDisabler.cs
index 2f49e94f34..4167316780 100644
--- a/osu.Game/Audio/ISamplePlaybackDisabler.cs
+++ b/osu.Game/Audio/ISamplePlaybackDisabler.cs
@@ -10,6 +10,7 @@ namespace osu.Game.Audio
///
/// Allows a component to disable sample playback dynamically as required.
/// Automatically handled by .
+ /// May also be manually handled locally to particular components.
///
[Cached]
public interface ISamplePlaybackDisabler
diff --git a/osu.Game/Overlays/Mods/ModPanel.cs b/osu.Game/Overlays/Mods/ModPanel.cs
index f2a97da3b2..4c4951307d 100644
--- a/osu.Game/Overlays/Mods/ModPanel.cs
+++ b/osu.Game/Overlays/Mods/ModPanel.cs
@@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+#nullable enable
+
using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@@ -12,6 +14,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
+using osu.Game.Audio;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
@@ -21,8 +24,6 @@ using osu.Game.Rulesets.UI;
using osuTK;
using osuTK.Input;
-#nullable enable
-
namespace osu.Game.Overlays.Mods
{
public class ModPanel : OsuClickableContainer
@@ -50,6 +51,7 @@ namespace osu.Game.Overlays.Mods
private Colour4 activeColour;
+ private readonly Bindable samplePlaybackDisabled = new BindableBool();
private Sample? sampleOff;
private Sample? sampleOn;
@@ -139,13 +141,16 @@ namespace osu.Game.Overlays.Mods
Action = Active.Toggle;
}
- [BackgroundDependencyLoader]
- private void load(AudioManager audio, OsuColour colours)
+ [BackgroundDependencyLoader(true)]
+ private void load(AudioManager audio, OsuColour colours, ISamplePlaybackDisabler? samplePlaybackDisabler)
{
sampleOn = audio.Samples.Get(@"UI/check-on");
sampleOff = audio.Samples.Get(@"UI/check-off");
activeColour = colours.ForModType(Mod.Type);
+
+ if (samplePlaybackDisabler != null)
+ ((IBindable)samplePlaybackDisabled).BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
}
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds(sampleSet);
@@ -166,6 +171,9 @@ namespace osu.Game.Overlays.Mods
private void playStateChangeSamples()
{
+ if (samplePlaybackDisabled.Value)
+ return;
+
if (Active.Value)
sampleOn?.Play();
else