diff --git a/osu.Game/Graphics/Containers/OsuClickableContainer.cs b/osu.Game/Graphics/Containers/OsuClickableContainer.cs index 2cae413de8..8df533ad6e 100644 --- a/osu.Game/Graphics/Containers/OsuClickableContainer.cs +++ b/osu.Game/Graphics/Containers/OsuClickableContainer.cs @@ -8,7 +8,7 @@ using osu.Game.Graphics.UserInterface; namespace osu.Game.Graphics.Containers { - public class OsuClickableContainer : ClickableContainer, IHasHoverSounds + public class OsuClickableContainer : ClickableContainer { private readonly HoverSampleSet sampleSet; @@ -16,8 +16,6 @@ namespace osu.Game.Graphics.Containers protected override Container Content => content; - public bool ShouldPlayHoverSound => true; - public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Normal) { this.sampleSet = sampleSet; diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index ea452650b4..ccdb5a50e0 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -9,7 +9,6 @@ using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; -using static osu.Game.Online.Chat.ChatLink; namespace osu.Game.Graphics.UserInterface { @@ -20,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface public class HoverSounds : CompositeDrawable { private SampleChannel sampleHover; - + protected readonly HoverSampleSet SampleSet; public HoverSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) @@ -31,7 +30,8 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { - if ((Parent as IHasHoverSounds).ShouldPlayHoverSound) sampleHover?.Play(); + // If Parent does not implement the interface, still play the sample + if ((Parent as ICanDisableHoverSounds)?.ShouldPlayHoverSound != false) sampleHover?.Play(); return base.OnHover(state); } @@ -52,7 +52,11 @@ namespace osu.Game.Graphics.UserInterface Soft } - public interface IHasHoverSounds + /// + /// Classes implementing this interface can choose whether or not the HoverSounds should be played. + /// If this is not implemented, the sounds will always be played when OnHover is triggered. + /// + public interface ICanDisableHoverSounds { bool ShouldPlayHoverSound { get; } } diff --git a/osu.Game/Online/Chat/ChatLink.cs b/osu.Game/Online/Chat/ChatLink.cs index b9e13e3464..42f5ea3e16 100644 --- a/osu.Game/Online/Chat/ChatLink.cs +++ b/osu.Game/Online/Chat/ChatLink.cs @@ -221,7 +221,7 @@ namespace osu.Game.Online.Chat Content.Colour = urlColour; } - private class ChatHoverContainer : OsuHoverContainer, IHasHoverSounds + private class ChatHoverContainer : OsuHoverContainer, ICanDisableHoverSounds { public bool ShouldPlayHoverSound => ((ChatLink)Parent).SameLinkSprites.All(sprite => !sprite.IsHovered); }