1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-04 02:13:22 +08:00

Merge branch 'hover-pitch-randomisation' into update-resources

This commit is contained in:
Dean Herbert 2021-02-11 14:20:22 +09:00
commit 26c9a60b0d

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Framework.Utils;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -47,15 +48,20 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
if (sampleHover == null)
return false;
bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= HoverDebounceTime; bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= HoverDebounceTime;
if (enoughTimePassedSinceLastPlayback) if (enoughTimePassedSinceLastPlayback)
{ {
sampleHover?.Play(); sampleHover.Frequency.Value = 0.96 + RNG.NextDouble(0.08);
sampleHover.Play();
lastPlaybackTime.Value = Time.Current; lastPlaybackTime.Value = Time.Current;
} }
return base.OnHover(e); return false;
} }
} }