2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2017-09-09 21:34:26 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-09-08 05:55:05 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2017-12-06 12:46:49 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-08 05:55:05 +08:00
|
|
|
|
namespace osu.Game.Storyboards
|
|
|
|
|
{
|
2017-09-09 00:00:17 +08:00
|
|
|
|
public delegate CommandTimeline<T> CommandTimelineSelector<T>(CommandTimelineGroup commandTimelineGroup);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-08 05:55:05 +08:00
|
|
|
|
public class CommandTimelineGroup
|
|
|
|
|
{
|
|
|
|
|
public CommandTimeline<float> X = new CommandTimeline<float>();
|
|
|
|
|
public CommandTimeline<float> Y = new CommandTimeline<float>();
|
2019-12-18 16:21:38 +08:00
|
|
|
|
public CommandTimeline<float> Scale = new CommandTimeline<float>();
|
|
|
|
|
public CommandTimeline<Vector2> VectorScale = new CommandTimeline<Vector2>();
|
2017-09-08 05:55:05 +08:00
|
|
|
|
public CommandTimeline<float> Rotation = new CommandTimeline<float>();
|
|
|
|
|
public CommandTimeline<Color4> Colour = new CommandTimeline<Color4>();
|
|
|
|
|
public CommandTimeline<float> Alpha = new CommandTimeline<float>();
|
2019-08-21 12:29:50 +08:00
|
|
|
|
public CommandTimeline<BlendingParameters> BlendingParameters = new CommandTimeline<BlendingParameters>();
|
2017-09-08 05:55:05 +08:00
|
|
|
|
public CommandTimeline<bool> FlipH = new CommandTimeline<bool>();
|
|
|
|
|
public CommandTimeline<bool> FlipV = new CommandTimeline<bool>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-12-18 22:59:48 +08:00
|
|
|
|
private readonly ICommandTimeline[] timelines;
|
|
|
|
|
|
|
|
|
|
public CommandTimelineGroup()
|
|
|
|
|
{
|
|
|
|
|
timelines = new ICommandTimeline[]
|
|
|
|
|
{
|
|
|
|
|
X,
|
|
|
|
|
Y,
|
|
|
|
|
Scale,
|
|
|
|
|
VectorScale,
|
|
|
|
|
Rotation,
|
|
|
|
|
Colour,
|
|
|
|
|
Alpha,
|
|
|
|
|
BlendingParameters,
|
|
|
|
|
FlipH,
|
|
|
|
|
FlipV
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-06 12:46:49 +08:00
|
|
|
|
[JsonIgnore]
|
2024-03-01 04:23:57 +08:00
|
|
|
|
public double CommandsStartTime => timelines.Min(static t => t.StartTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-06 12:46:49 +08:00
|
|
|
|
[JsonIgnore]
|
2024-03-01 04:23:57 +08:00
|
|
|
|
public double CommandsEndTime => timelines.Max(static t => t.EndTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-06 12:46:49 +08:00
|
|
|
|
[JsonIgnore]
|
2017-09-09 00:03:04 +08:00
|
|
|
|
public double CommandsDuration => CommandsEndTime - CommandsStartTime;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-06 12:46:49 +08:00
|
|
|
|
[JsonIgnore]
|
2017-09-09 00:03:04 +08:00
|
|
|
|
public virtual double StartTime => CommandsStartTime;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-06 12:46:49 +08:00
|
|
|
|
[JsonIgnore]
|
2017-09-09 00:03:04 +08:00
|
|
|
|
public virtual double EndTime => CommandsEndTime;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-06 12:46:49 +08:00
|
|
|
|
[JsonIgnore]
|
2024-03-01 04:23:57 +08:00
|
|
|
|
public bool HasCommands => timelines.Any(static t => t.HasCommands);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-09 00:00:17 +08:00
|
|
|
|
public virtual IEnumerable<CommandTimeline<T>.TypedCommand> GetCommands<T>(CommandTimelineSelector<T> timelineSelector, double offset = 0)
|
2017-09-08 05:55:05 +08:00
|
|
|
|
{
|
2017-09-09 00:00:17 +08:00
|
|
|
|
if (offset != 0)
|
2019-11-11 19:53:22 +08:00
|
|
|
|
{
|
2017-09-09 00:00:17 +08:00
|
|
|
|
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,
|
|
|
|
|
});
|
2019-11-11 19:53:22 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-09-09 00:00:17 +08:00
|
|
|
|
return timelineSelector(this).Commands;
|
2017-09-08 18:11:57 +08:00
|
|
|
|
}
|
2017-09-08 05:55:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|