mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 21:13:01 +08:00
Implemented new interface which allows parent containers to decide on whether a "OnHover" sound should be played.
This commit is contained in:
parent
f4f1291919
commit
a8599a1b75
@ -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<Drawable> Content => content;
|
||||
|
||||
public bool ShouldPlayHoverSound => true;
|
||||
|
||||
public OsuClickableContainer(HoverSampleSet sampleSet = HoverSampleSet.Normal)
|
||||
{
|
||||
this.sampleSet = sampleSet;
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user