From a8599a1b75c59f39ee7e329d5a5f70f8e1fda2c7 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 7 Dec 2017 13:12:36 +0100 Subject: [PATCH] Implemented new interface which allows parent containers to decide on whether a "OnHover" sound should be played. --- osu.Game/Graphics/Containers/OsuClickableContainer.cs | 4 +++- osu.Game/Graphics/UserInterface/HoverSounds.cs | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuClickableContainer.cs b/osu.Game/Graphics/Containers/OsuClickableContainer.cs index 8df533ad6e..2cae413de8 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 + public class OsuClickableContainer : ClickableContainer, IHasHoverSounds { private readonly HoverSampleSet sampleSet; @@ -16,6 +16,8 @@ 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 24dbe37567..ea452650b4 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -9,6 +9,7 @@ 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 { @@ -30,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { - sampleHover?.Play(); + if ((Parent as IHasHoverSounds).ShouldPlayHoverSound) sampleHover?.Play(); return base.OnHover(state); } @@ -50,4 +51,9 @@ namespace osu.Game.Graphics.UserInterface [Description("-softer")] Soft } + + public interface IHasHoverSounds + { + bool ShouldPlayHoverSound { get; } + } }