From d4afea0b5e5197d81999ee7edbf774a5946e0319 Mon Sep 17 00:00:00 2001 From: phosphene47 Date: Wed, 27 Nov 2019 23:06:07 +1100 Subject: [PATCH] Use double instead of TimeSpan --- osu.Game/Graphics/UserInterface/HoverClickSounds.cs | 7 ++----- osu.Game/Graphics/UserInterface/HoverSounds.cs | 12 ++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs index fcb8f8d6bd..a8e074d2ef 100644 --- a/osu.Game/Graphics/UserInterface/HoverClickSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverClickSounds.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -44,12 +43,10 @@ namespace osu.Game.Graphics.UserInterface if (buttons.Contains(e.Button) && Contains(e.ScreenSpaceMousePosition)) { - var debounceMs = (int)DebounceTime.TotalMilliseconds; - - if (debounceMs <= 0) + if (DebounceTime <= 0) sampleClick?.Play(); else - playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), debounceMs); + playDelegate = Scheduler.AddDelayed(() => sampleClick?.Play(), DebounceTime); } return base.OnClick(e); diff --git a/osu.Game/Graphics/UserInterface/HoverSounds.cs b/osu.Game/Graphics/UserInterface/HoverSounds.cs index 2223ac21db..c98d50efff 100644 --- a/osu.Game/Graphics/UserInterface/HoverSounds.cs +++ b/osu.Game/Graphics/UserInterface/HoverSounds.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.ComponentModel; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -23,10 +22,9 @@ namespace osu.Game.Graphics.UserInterface private SampleChannel sampleHover; /// - /// Length of debounce for sound playback. - /// Set this to to disable debouncing. + /// Length of debounce for sound playback, in milliseconds. Default is 50ms. /// - public TimeSpan DebounceTime { get; set; } = TimeSpan.FromMilliseconds(50); + public double DebounceTime { get; set; } = 50; protected readonly HoverSampleSet SampleSet; @@ -42,12 +40,10 @@ namespace osu.Game.Graphics.UserInterface { playDelegate?.Cancel(); - var debounceMs = (int)DebounceTime.TotalMilliseconds; - - if (debounceMs <= 0) + if (DebounceTime <= 0) sampleHover?.Play(); else - playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), debounceMs); + playDelegate = Scheduler.AddDelayed(() => sampleHover?.Play(), DebounceTime); return base.OnHover(e); }