1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 20:43:21 +08:00

Use double instead of TimeSpan

This commit is contained in:
phosphene47 2019-11-27 23:06:07 +11:00
parent 037d927e45
commit d4afea0b5e
2 changed files with 6 additions and 13 deletions

View File

@ -1,7 +1,6 @@
// 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;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -44,12 +43,10 @@ namespace osu.Game.Graphics.UserInterface
if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition)) if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition))
{ {
var debounceMs = (int)DebounceTime.TotalMilliseconds; if (DebounceTime <= 0)
if (debounceMs <= 0)
sampleClick?.Play(); sampleClick?.Play();
else else
playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), debounceMs); playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), DebounceTime);
} }
return base.OnClick(e); return base.OnClick(e);

View File

@ -1,7 +1,6 @@
// 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;
using System.ComponentModel; using System.ComponentModel;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -23,10 +22,9 @@ namespace osu.Game.Graphics.UserInterface
private SampleChannel sampleHover; private SampleChannel sampleHover;
/// <summary> /// <summary>
/// Length of debounce for sound playback. /// Length of debounce for sound playback, in milliseconds. Default is 50ms.
/// Set this to <see cref="TimeSpan.Zero"/> to disable debouncing.
/// </summary> /// </summary>
public TimeSpan DebounceTime { get; set; } = TimeSpan.FromMilliseconds(50); public double DebounceTime { get; set; } = 50;
protected readonly HoverSampleSet SampleSet; protected readonly HoverSampleSet SampleSet;
@ -42,12 +40,10 @@ namespace osu.Game.Graphics.UserInterface
{ {
playDelegate?.Cancel(); playDelegate?.Cancel();
var debounceMs = (int)DebounceTime.TotalMilliseconds; if (DebounceTime <= 0)
if (debounceMs <= 0)
sampleHover?.Play(); sampleHover?.Play();
else else
playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), debounceMs); playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), DebounceTime);
return base.OnHover(e); return base.OnHover(e);
} }