Split click and hover and disable click debounce

This commit is contained in:
phosphene47
2019-11-28 00:44:01 +11:00
parent d4afea0b5e
commit 786fb9ede3
2 changed files with 11 additions and 6 deletions

View File

@ -21,6 +21,11 @@ namespace osu.Game.Graphics.UserInterface
private SampleChannel sampleClick;
private readonly MouseButton[] buttons;
/// <summary>
/// Length of debounce for click sound playback, in milliseconds. Default is 0ms.
/// </summary>
public double ClickDebounceTime { get; set; }
/// <summary>
/// a container which plays sounds on hover and click for any specified <see cref="MouseButton"/>s.
/// </summary>
@ -43,10 +48,10 @@ namespace osu.Game.Graphics.UserInterface
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
{
if (DebounceTime <= 0)
if (ClickDebounceTime <= 0)
sampleClick?.Play();
else
playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), DebounceTime);
playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), ClickDebounceTime);
}
return base.OnClick(e);

View File

@ -22,9 +22,9 @@ namespace osu.Game.Graphics.UserInterface
private SampleChannel sampleHover;
/// <summary>
/// Length of debounce for sound playback, in milliseconds. Default is 50ms.
/// Length of debounce for hover sound playback, in milliseconds. Default is 50ms.
/// </summary>
public double DebounceTime { get; set; } = 50;
public double HoverDebounceTime { get; set; } = 50;
protected readonly HoverSampleSet SampleSet;
@ -40,10 +40,10 @@ namespace osu.Game.Graphics.UserInterface
{
playDelegate?.Cancel();
if (DebounceTime <= 0)
if (HoverDebounceTime <= 0)
sampleHover?.Play();
else
playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), DebounceTime);
playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), HoverDebounceTime);
return base.OnHover(e);
}