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

View File

@ -12,10 +12,11 @@ using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface 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 SampleChannel sample;
private double lastSampleTime; private double lastSampleTime;
private T lastSampleValue;
private readonly Nub nub; private readonly Nub nub;
private readonly Box leftBox; private readonly Box leftBox;
@ -84,6 +85,12 @@ namespace osu.Game.Graphics.UserInterface
{ {
if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50) if (Clock == null || Clock.CurrentTime - lastSampleTime <= 50)
return; return;
if (Current.Value.Equals(lastSampleValue))
return;
lastSampleValue = Current.Value;
lastSampleTime = Clock.CurrentTime; lastSampleTime = Clock.CurrentTime;
sample.Frequency.Value = 1 + NormalizedValue * 0.2f; sample.Frequency.Value = 1 + NormalizedValue * 0.2f;