Don't play sliderbar samples more than once when value has not changed.

This commit is contained in:
Dean Herbert 2017-04-20 16:35:55 +09:00
parent 7dc8404cf6
commit 9c8cd08927
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
1 changed files with 8 additions and 1 deletions

View File

@ -12,10 +12,11 @@
namespace osu.Game.Graphics.UserInterface
{
public class OsuSliderBar<U> : SliderBar<U> where U : struct
public class OsuSliderBar<T> : SliderBar<T> where T : struct
{
private SampleChannel sample;
private double lastSampleTime;
private T lastSampleValue;
private readonly Nub nub;
private readonly Box leftBox;
@ -84,6 +85,12 @@ private void playSample()
{
if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50)
return;
if (Current.Value.Equals(lastSampleValue))
return;
lastSampleValue = Current.Value;
lastSampleTime = Clock.CurrentTime;
sample.Frequency.Value = 1 + NormalizedValue * 0.2f;