mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 19:53:23 +08:00
Completely remove click sound debounce
This commit is contained in:
parent
786fb9ede3
commit
92ab8026a0
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -7,7 +7,6 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Threading;
|
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
@ -21,11 +20,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private SampleChannel sampleClick;
|
private SampleChannel sampleClick;
|
||||||
private readonly MouseButton[] buttons;
|
private readonly MouseButton[] buttons;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Length of debounce for click sound playback, in milliseconds. Default is 0ms.
|
|
||||||
/// </summary>
|
|
||||||
public double ClickDebounceTime { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a container which plays sounds on hover and click for any specified <see cref="MouseButton"/>s.
|
/// a container which plays sounds on hover and click for any specified <see cref="MouseButton"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -40,19 +34,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
this.buttons = buttons ?? new[] { MouseButton.Left };
|
this.buttons = buttons ?? new[] { MouseButton.Left };
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate playDelegate;
|
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
playDelegate?.Cancel();
|
|
||||||
|
|
||||||
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
|
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
|
||||||
{
|
|
||||||
if (ClickDebounceTime <= 0)
|
|
||||||
sampleClick?.Play();
|
sampleClick?.Play();
|
||||||
else
|
|
||||||
playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), ClickDebounceTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnClick(e);
|
return base.OnClick(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user