1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:02:58 +08:00

Renamed the IHasHoverSounds interface to ICanDisableHoverSounds and made it so that if the interface is not implemented, it is just ignored (samples will always be played). If it is implemented, the ShouldPlayHoverSound bool is decisive of whether sounds are played or not

This commit is contained in:
FreezyLemon 2017-12-07 19:52:40 +01:00
parent c5a7f5b163
commit 68255095a6
3 changed files with 10 additions and 8 deletions

View File

@ -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<Drawable> Content => content;
public bool ShouldPlayHoverSound => true;
public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Normal)
{
this.sampleSet = sampleSet;

View File

@ -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
/// <summary>
/// Classes implementing this interface can choose whether or not the HoverSounds should be played.
/// <para>If this is not implemented, the sounds will always be played when OnHover is triggered.</para>
/// </summary>
public interface ICanDisableHoverSounds
{
bool ShouldPlayHoverSound { get; }
}

View File

@ -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);
}