1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 07:42:58 +08:00

Update SliderOption implementation

Per @Tom94's suggestion, the bars track the nub in Update instead of
animating seperately. Also only animates when the event source is the
keyboard.
This commit is contained in:
Drew DeVault 2016-12-14 14:57:41 -05:00
parent 10cc6f7885
commit a751cfcba3

View File

@ -140,15 +140,21 @@ namespace osu.Game.Overlays.Options
return base.OnDrag(state);
}
protected override void UpdateValue(float value)
protected override void Update()
{
leftBox.Scale = new Vector2(MathHelper.Clamp(
nub.DrawPosition.X - nub.DrawSize.X / 2 + 2, 0, DrawWidth), 1);
rightBox.Scale = new Vector2(MathHelper.Clamp(
DrawWidth - nub.DrawPosition.X - nub.DrawSize.X / 2 + 2, 0, DrawWidth), 1);
base.Update();
}
protected override void UpdateValue(float value, SliderBarEventSource eventSource)
{
if (eventSource == SliderBarEventSource.Keyboard)
nub.MoveToX(DrawWidth * value, 300, EasingTypes.OutQuint);
leftBox.ScaleTo(new Vector2(
MathHelper.Clamp(DrawWidth * value - nub.Width / 2 + 2, 0, DrawWidth),
1), 300, EasingTypes.OutQuint);
rightBox.ScaleTo(new Vector2(
MathHelper.Clamp(DrawWidth * (1 - value) - nub.Width / 2 + 2, 0, DrawWidth),
1), 300, EasingTypes.OutQuint);
else
nub.Position = new Vector2(DrawWidth * value, nub.Position.Y);
}
}
}