1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 11:53:21 +08:00

Completely remove click sound debounce

This commit is contained in:
Min 2019-11-28 16:03:59 +11:00 committed by GitHub
parent 786fb9ede3
commit 92ab8026a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.
using System.Linq;
@ -7,7 +7,6 @@ using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osuTK.Input;
namespace osu.Game.Graphics.UserInterface
@ -21,11 +20,6 @@ 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>
@ -40,19 +34,10 @@ namespace osu.Game.Graphics.UserInterface
this.buttons = buttons ?? new[] { MouseButton.Left };
}
private ScheduledDelegate playDelegate;
protected override bool OnClick(ClickEvent e)
{
playDelegate?.Cancel();
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
{
if (ClickDebounceTime <= 0)
sampleClick?.Play();
else
playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), ClickDebounceTime);
}
sampleClick?.Play();
return base.OnClick(e);
}