mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 05:22:54 +08:00
Move sample playback debounce time to central const
This commit is contained in:
parent
473e15e8f3
commit
ab1c64591f
@ -15,11 +15,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public abstract class HoverSampleDebounceComponent : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Length of debounce for hover sound playback, in milliseconds.
|
||||
/// </summary>
|
||||
public double HoverDebounceTime { get; } = 20;
|
||||
|
||||
private Bindable<double?> lastPlaybackTime;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -34,7 +29,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
if (e.HasAnyButtonPressed)
|
||||
return false;
|
||||
|
||||
bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= HoverDebounceTime;
|
||||
bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= OsuGameBase.SAMPLE_DEBOUNCE_TIME;
|
||||
|
||||
if (enoughTimePassedSinceLastPlayback)
|
||||
{
|
||||
|
@ -56,6 +56,11 @@ namespace osu.Game
|
||||
|
||||
public const int SAMPLE_CONCURRENCY = 6;
|
||||
|
||||
/// <summary>
|
||||
/// Length of debounce (in milliseconds) for commonly occuring sample playbacks that could stack.
|
||||
/// </summary>
|
||||
public const int SAMPLE_DEBOUNCE_TIME = 20;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum volume at which audio tracks should playback. This can be set lower than 1 to create some head-room for sound effects.
|
||||
/// </summary>
|
||||
|
@ -172,7 +172,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
private void playDebouncedSample(string sampleName)
|
||||
{
|
||||
if (lastSamplePlayback == null || Time.Current - lastSamplePlayback > 50)
|
||||
if (lastSamplePlayback == null || Time.Current - lastSamplePlayback > OsuGameBase.SAMPLE_DEBOUNCE_TIME)
|
||||
{
|
||||
audio.Samples.Get(sampleName)?.Play();
|
||||
lastSamplePlayback = Time.Current;
|
||||
|
Loading…
Reference in New Issue
Block a user