mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 03:23:05 +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:
parent
10cc6f7885
commit
a751cfcba3
@ -139,16 +139,22 @@ namespace osu.Game.Overlays.Options
|
||||
playSample();
|
||||
return base.OnDrag(state);
|
||||
}
|
||||
|
||||
protected override void UpdateValue(float value)
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
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);
|
||||
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);
|
||||
else
|
||||
nub.Position = new Vector2(DrawWidth * value, nub.Position.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user