mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 03:53:21 +08:00
Add tween to time span changing.
This commit is contained in:
parent
3c8d75effb
commit
9b0aed7c48
@ -20,6 +20,8 @@ using osu.Game.Rulesets.Objects.Drawables;
|
|||||||
using osu.Game.Rulesets.Mania.Timing;
|
using osu.Game.Rulesets.Mania.Timing;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
using osu.Framework.Graphics.Transforms;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
@ -196,10 +198,10 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
switch (args.Key)
|
switch (args.Key)
|
||||||
{
|
{
|
||||||
case Key.Minus:
|
case Key.Minus:
|
||||||
TimeSpan += time_span_step;
|
transformTimeSpanTo(TimeSpan + time_span_step, 200, EasingTypes.OutQuint);
|
||||||
break;
|
break;
|
||||||
case Key.Plus:
|
case Key.Plus:
|
||||||
TimeSpan -= time_span_step;
|
transformTimeSpanTo(TimeSpan - time_span_step, 200, EasingTypes.OutQuint);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,5 +229,32 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user