mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Make storyboard loops work.
This commit is contained in:
@ -3,14 +3,13 @@
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Storyboards
|
||||
{
|
||||
public delegate CommandTimeline<T> CommandTimelineSelector<T>(CommandTimelineGroup commandTimelineGroup);
|
||||
|
||||
public class CommandTimelineGroup
|
||||
{
|
||||
public CommandTimeline<float> X = new CommandTimeline<float>();
|
||||
@ -49,63 +48,20 @@ namespace osu.Game.Storyboards
|
||||
|
||||
public bool HasCommands => Timelines.Any(t => t.HasCommands);
|
||||
|
||||
public virtual void ApplyTransforms(Drawable drawable, double offset = 0)
|
||||
public virtual IEnumerable<CommandTimeline<T>.TypedCommand> GetCommands<T>(CommandTimelineSelector<T> timelineSelector, double offset = 0)
|
||||
{
|
||||
if (X.HasCommands) drawable.X = X.StartValue;
|
||||
foreach (var command in X.Commands)
|
||||
using (drawable.BeginAbsoluteSequence(offset + command.StartTime))
|
||||
PostProcess(command,
|
||||
drawable.MoveToX(command.StartValue)
|
||||
.MoveToX(command.EndValue, command.Duration, command.Easing));
|
||||
if (offset != 0)
|
||||
return timelineSelector(this).Commands.Select(command =>
|
||||
new CommandTimeline<T>.TypedCommand
|
||||
{
|
||||
Easing = command.Easing,
|
||||
StartTime = offset + command.StartTime,
|
||||
EndTime = offset + command.EndTime,
|
||||
StartValue = command.StartValue,
|
||||
EndValue = command.EndValue,
|
||||
});
|
||||
|
||||
if (Y.HasCommands) drawable.Y = Y.StartValue;
|
||||
foreach (var command in Y.Commands)
|
||||
using (drawable.BeginAbsoluteSequence(offset + command.StartTime))
|
||||
PostProcess(command,
|
||||
drawable.MoveToY(command.StartValue)
|
||||
.MoveToY(command.EndValue, command.Duration, command.Easing));
|
||||
|
||||
if (Scale.HasCommands) drawable.Scale = Scale.StartValue;
|
||||
foreach (var command in Scale.Commands)
|
||||
using (drawable.BeginAbsoluteSequence(offset + command.StartTime))
|
||||
PostProcess(command,
|
||||
drawable.ScaleTo(command.StartValue)
|
||||
.ScaleTo(command.EndValue, command.Duration, command.Easing));
|
||||
|
||||
if (Rotation.HasCommands) drawable.Rotation = Rotation.StartValue;
|
||||
foreach (var command in Rotation.Commands)
|
||||
using (drawable.BeginAbsoluteSequence(offset + command.StartTime))
|
||||
PostProcess(command,
|
||||
drawable.RotateTo(command.StartValue)
|
||||
.RotateTo(command.EndValue, command.Duration, command.Easing));
|
||||
|
||||
if (Colour.HasCommands) drawable.Colour = Colour.StartValue;
|
||||
foreach (var command in Colour.Commands)
|
||||
using (drawable.BeginAbsoluteSequence(offset + command.StartTime))
|
||||
PostProcess(command,
|
||||
drawable.FadeColour(command.StartValue)
|
||||
.FadeColour(command.EndValue, command.Duration, command.Easing));
|
||||
|
||||
if (Alpha.HasCommands) drawable.Alpha = Alpha.StartValue;
|
||||
foreach (var command in Alpha.Commands)
|
||||
using (drawable.BeginAbsoluteSequence(offset + command.StartTime))
|
||||
PostProcess(command,
|
||||
drawable.FadeTo(command.StartValue)
|
||||
.FadeTo(command.EndValue, command.Duration, command.Easing));
|
||||
|
||||
if (Additive.HasCommands)
|
||||
drawable.BlendingMode = BlendingMode.Additive;
|
||||
|
||||
var flippable = drawable as IFlippable;
|
||||
if (flippable != null)
|
||||
{
|
||||
flippable.FlipH = FlipH.HasCommands;
|
||||
flippable.FlipV = FlipV.HasCommands;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void PostProcess(ICommand command, TransformSequence<Drawable> sequence)
|
||||
{
|
||||
return timelineSelector(this).Commands;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user