diff --git a/osu.Android.props b/osu.Android.props
index 8711ceec64..b3c48da2bf 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -51,7 +51,7 @@
-
+
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledSliderBar.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledSliderBar.cs
index e5f3aea2f7..5548375af2 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledSliderBar.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledSliderBar.cs
@@ -38,6 +38,14 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("revert back", () => this.ChildrenOfType>().ForEach(l => l.ResizeWidthTo(1, 200, Easing.OutQuint)));
}
+ [Test]
+ public void TestDisable()
+ {
+ createSliderBar();
+ AddStep("set disabled", () => this.ChildrenOfType>().ForEach(l => l.Current.Disabled = true));
+ AddStep("unset disabled", () => this.ChildrenOfType>().ForEach(l => l.Current.Disabled = false));
+ }
+
private void createSliderBar()
{
AddStep("create component", () =>
diff --git a/osu.Game/Graphics/Containers/OsuClickableContainer.cs b/osu.Game/Graphics/Containers/OsuClickableContainer.cs
index 61ec9dfc24..03a1cfcc13 100644
--- a/osu.Game/Graphics/Containers/OsuClickableContainer.cs
+++ b/osu.Game/Graphics/Containers/OsuClickableContainer.cs
@@ -20,7 +20,7 @@ namespace osu.Game.Graphics.Containers
protected override Container Content => content;
- protected virtual HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet);
+ protected virtual HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet) { Enabled = { BindTarget = Enabled } };
public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Default)
{
diff --git a/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
index b469c21ab0..6c8eeed391 100644
--- a/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
+++ b/osu.Game/Graphics/UserInterface/DrawableOsuMenuItem.cs
@@ -24,6 +24,7 @@ namespace osu.Game.Graphics.UserInterface
private const int transition_length = 80;
private TextContainer text;
+ private HoverClickSounds hoverClickSounds;
public DrawableOsuMenuItem(MenuItem item)
: base(item)
@@ -36,7 +37,7 @@ namespace osu.Game.Graphics.UserInterface
BackgroundColour = Color4.Transparent;
BackgroundColourHover = Color4Extensions.FromHex(@"172023");
- AddInternal(new HoverClickSounds());
+ AddInternal(hoverClickSounds = new HoverClickSounds());
updateTextColour();
@@ -76,6 +77,7 @@ namespace osu.Game.Graphics.UserInterface
private void updateState()
{
+ hoverClickSounds.Enabled.Value = !Item.Action.Disabled;
Alpha = Item.Action.Disabled ? 0.2f : 1;
if (IsHovered && !Item.Action.Disabled)
diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs
index dab4390ede..89d1570cd4 100644
--- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs
+++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs
@@ -7,6 +7,7 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
+using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
@@ -20,7 +21,11 @@ namespace osu.Game.Graphics.UserInterface
///
public class HoverClickSounds : HoverSounds
{
+ public Bindable Enabled = new Bindable(true);
+
private Sample sampleClick;
+ private Sample sampleClickDisabled;
+
private readonly MouseButton[] buttons;
///
@@ -41,8 +46,13 @@ namespace osu.Game.Graphics.UserInterface
{
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
{
- sampleClick.Frequency.Value = 0.99 + RNG.NextDouble(0.02);
- sampleClick.Play();
+ var channel = Enabled.Value ? sampleClick?.GetChannel() : sampleClickDisabled?.GetChannel();
+
+ if (channel != null)
+ {
+ channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02);
+ channel.Play();
+ }
}
return base.OnClick(e);
@@ -53,6 +63,9 @@ namespace osu.Game.Graphics.UserInterface
{
sampleClick = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-select")
?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
+
+ sampleClickDisabled = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-select-disabled")
+ ?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select-disabled");
}
}
}
diff --git a/osu.Game/Graphics/UserInterface/LoadingButton.cs b/osu.Game/Graphics/UserInterface/LoadingButton.cs
index 8be50a4b43..44067bac8b 100644
--- a/osu.Game/Graphics/UserInterface/LoadingButton.cs
+++ b/osu.Game/Graphics/UserInterface/LoadingButton.cs
@@ -41,6 +41,7 @@ namespace osu.Game.Graphics.UserInterface
private readonly LoadingSpinner loading;
protected LoadingButton()
+ : base(HoverSampleSet.Button)
{
Add(loading = new LoadingSpinner
{
diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs
index 291ff644fd..88f3ccd191 100644
--- a/osu.Game/Graphics/UserInterface/OsuButton.cs
+++ b/osu.Game/Graphics/UserInterface/OsuButton.cs
@@ -104,7 +104,7 @@ namespace osu.Game.Graphics.UserInterface
});
if (hoverSounds.HasValue)
- AddInternal(new HoverClickSounds(hoverSounds.Value));
+ AddInternal(new HoverClickSounds(hoverSounds.Value) { Enabled = { BindTarget = Enabled } });
}
[BackgroundDependencyLoader]
diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs
index 9acb0c7f94..392740690a 100644
--- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs
+++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs
@@ -46,6 +46,8 @@ namespace osu.Game.Graphics.UserInterface
public bool PlaySamplesOnAdjust { get; set; } = true;
+ private readonly HoverClickSounds hoverClickSounds;
+
///
/// Whether to format the tooltip as a percentage or the actual value.
///
@@ -127,7 +129,7 @@ namespace osu.Game.Graphics.UserInterface
Current = { Value = true }
},
},
- new HoverClickSounds()
+ hoverClickSounds = new HoverClickSounds()
};
Current.DisabledChanged += disabled => { Alpha = disabled ? 0.3f : 1; };
@@ -152,6 +154,7 @@ namespace osu.Game.Graphics.UserInterface
{
base.LoadComplete();
CurrentNumber.BindValueChanged(current => TooltipText = getTooltipText(current.NewValue), true);
+ Current.DisabledChanged += disabled => hoverClickSounds.Enabled.Value = !disabled;
}
protected override bool OnHover(HoverEvent e)
diff --git a/osu.Game/Graphics/UserInterface/ShearedButton.cs b/osu.Game/Graphics/UserInterface/ShearedButton.cs
index 0c25d06cd4..e406e273e6 100644
--- a/osu.Game/Graphics/UserInterface/ShearedButton.cs
+++ b/osu.Game/Graphics/UserInterface/ShearedButton.cs
@@ -138,7 +138,7 @@ namespace osu.Game.Graphics.UserInterface
}
}
- protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet);
+ protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet) { Enabled = { BindTarget = Enabled } };
protected override void LoadComplete()
{
diff --git a/osu.Game/Overlays/Comments/CancellableCommentEditor.cs b/osu.Game/Overlays/Comments/CancellableCommentEditor.cs
index 853171ea4a..7ba6de86b7 100644
--- a/osu.Game/Overlays/Comments/CancellableCommentEditor.cs
+++ b/osu.Game/Overlays/Comments/CancellableCommentEditor.cs
@@ -12,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
+using osu.Game.Graphics.UserInterface;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Comments
@@ -38,6 +39,7 @@ namespace osu.Game.Overlays.Comments
private readonly Box background;
public CancelButton()
+ : base(HoverSampleSet.Button)
{
AutoSizeAxes = Axes.Both;
Child = new CircularContainer
diff --git a/osu.Game/Overlays/Toolbar/ToolbarClock.cs b/osu.Game/Overlays/Toolbar/ToolbarClock.cs
index c5add6eee2..3fd37d9a62 100644
--- a/osu.Game/Overlays/Toolbar/ToolbarClock.cs
+++ b/osu.Game/Overlays/Toolbar/ToolbarClock.cs
@@ -13,6 +13,7 @@ using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
+using osu.Game.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
@@ -123,6 +124,8 @@ namespace osu.Game.Overlays.Toolbar
base.OnHoverLost(e);
}
+ protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(sampleSet);
+
private void cycleDisplayMode()
{
switch (clockDisplayMode.Value)
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index 8d45ebec57..fe44ed3688 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -36,7 +36,7 @@
-
+
diff --git a/osu.iOS.props b/osu.iOS.props
index 76d2e727c8..b5b488d82e 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -61,7 +61,7 @@
-
+