Add tween to time span changing.

This commit is contained in:
smoogipooo 2017-05-16 19:14:27 +09:00
parent 3c8d75effb
commit 9b0aed7c48
1 changed files with 31 additions and 2 deletions

View File

@ -20,6 +20,8 @@
using osu.Game.Rulesets.Mania.Timing;
using osu.Framework.Input;
using osu.Game.Beatmaps.Timing;
using osu.Framework.Graphics.Transforms;
using osu.Framework.MathUtils;
namespace osu.Game.Rulesets.Mania.UI
{
@ -196,10 +198,10 @@ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
switch (args.Key)
{
case Key.Minus:
TimeSpan += time_span_step;
transformTimeSpanTo(TimeSpan + time_span_step, 200, EasingTypes.OutQuint);
break;
case Key.Plus:
TimeSpan -= time_span_step;
transformTimeSpanTo(TimeSpan - time_span_step, 200, EasingTypes.OutQuint);
break;
}
}
@ -227,5 +229,32 @@ public double TimeSpan
}
}
private void transformTimeSpanTo(double newTimeSpan, double duration = 0, EasingTypes easing = EasingTypes.None)
{
TransformTo(() => TimeSpan, newTimeSpan, duration, easing, new TransformTimeSpan());
}
private class TransformTimeSpan : Transform<double>
{
public override double CurrentValue
{
get
{
double time = Time?.Current ?? 0;
if (time < StartTime) return StartValue;
if (time >= EndTime) return EndValue;
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
}
}
public override void Apply(Drawable d)
{
base.Apply(d);
var p = (ManiaPlayfield)d;
p.TimeSpan = CurrentValue;
}
}
}
}