2017-09-07 21:55:05 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-09-09 13:34:26 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-09-07 21:55:05 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards
|
|
|
|
|
{
|
2017-09-08 16:00:17 +00:00
|
|
|
|
public delegate CommandTimeline<T> CommandTimelineSelector<T>(CommandTimelineGroup commandTimelineGroup);
|
|
|
|
|
|
2017-09-07 21:55:05 +00:00
|
|
|
|
public class CommandTimelineGroup
|
|
|
|
|
{
|
|
|
|
|
public CommandTimeline<float> X = new CommandTimeline<float>();
|
|
|
|
|
public CommandTimeline<float> Y = new CommandTimeline<float>();
|
|
|
|
|
public CommandTimeline<Vector2> Scale = new CommandTimeline<Vector2>();
|
|
|
|
|
public CommandTimeline<float> Rotation = new CommandTimeline<float>();
|
|
|
|
|
public CommandTimeline<Color4> Colour = new CommandTimeline<Color4>();
|
|
|
|
|
public CommandTimeline<float> Alpha = new CommandTimeline<float>();
|
2017-09-09 13:34:26 +00:00
|
|
|
|
public CommandTimeline<BlendingMode> BlendingMode = new CommandTimeline<BlendingMode>();
|
2017-09-07 21:55:05 +00:00
|
|
|
|
public CommandTimeline<bool> FlipH = new CommandTimeline<bool>();
|
|
|
|
|
public CommandTimeline<bool> FlipV = new CommandTimeline<bool>();
|
|
|
|
|
|
2017-09-08 11:04:53 +00:00
|
|
|
|
public IEnumerable<ICommandTimeline> Timelines
|
2017-09-07 21:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
yield return X;
|
|
|
|
|
yield return Y;
|
|
|
|
|
yield return Scale;
|
|
|
|
|
yield return Rotation;
|
|
|
|
|
yield return Colour;
|
|
|
|
|
yield return Alpha;
|
2017-09-09 13:34:26 +00:00
|
|
|
|
yield return BlendingMode;
|
2017-09-07 21:55:05 +00:00
|
|
|
|
yield return FlipH;
|
|
|
|
|
yield return FlipV;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 16:03:04 +00:00
|
|
|
|
public double CommandsStartTime => Timelines.Where(t => t.HasCommands).Min(t => t.StartTime);
|
|
|
|
|
public double CommandsEndTime => Timelines.Where(t => t.HasCommands).Max(t => t.EndTime);
|
|
|
|
|
public double CommandsDuration => CommandsEndTime - CommandsStartTime;
|
|
|
|
|
|
|
|
|
|
public virtual double StartTime => CommandsStartTime;
|
|
|
|
|
public virtual double EndTime => CommandsEndTime;
|
2017-09-08 10:11:57 +00:00
|
|
|
|
public double Duration => EndTime - StartTime;
|
2017-09-08 16:03:04 +00:00
|
|
|
|
|
2017-09-07 21:55:05 +00:00
|
|
|
|
public bool HasCommands => Timelines.Any(t => t.HasCommands);
|
|
|
|
|
|
2017-09-08 16:00:17 +00:00
|
|
|
|
public virtual IEnumerable<CommandTimeline<T>.TypedCommand> GetCommands<T>(CommandTimelineSelector<T> timelineSelector, double offset = 0)
|
2017-09-07 21:55:05 +00:00
|
|
|
|
{
|
2017-09-08 16:00:17 +00:00
|
|
|
|
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,
|
|
|
|
|
});
|
2017-09-07 21:55:05 +00:00
|
|
|
|
|
2017-09-08 16:00:17 +00:00
|
|
|
|
return timelineSelector(this).Commands;
|
2017-09-08 10:11:57 +00:00
|
|
|
|
}
|
2017-09-07 21:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|