// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osuTK; using osuTK.Graphics; using osu.Framework.Graphics; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; namespace osu.Game.Storyboards { public delegate CommandTimeline CommandTimelineSelector(CommandTimelineGroup commandTimelineGroup); public class CommandTimelineGroup { public CommandTimeline X = new CommandTimeline(); public CommandTimeline Y = new CommandTimeline(); public CommandTimeline Scale = new CommandTimeline(); public CommandTimeline Rotation = new CommandTimeline(); public CommandTimeline Colour = new CommandTimeline(); public CommandTimeline Alpha = new CommandTimeline(); public CommandTimeline BlendingMode = new CommandTimeline(); public CommandTimeline FlipH = new CommandTimeline(); public CommandTimeline FlipV = new CommandTimeline(); [JsonIgnore] public IEnumerable Timelines { get { yield return X; yield return Y; yield return Scale; yield return Rotation; yield return Colour; yield return Alpha; yield return BlendingMode; yield return FlipH; yield return FlipV; } } [JsonIgnore] public double CommandsStartTime => Timelines.Where(t => t.HasCommands).Min(t => t.StartTime); [JsonIgnore] public double CommandsEndTime => Timelines.Where(t => t.HasCommands).Max(t => t.EndTime); [JsonIgnore] public double CommandsDuration => CommandsEndTime - CommandsStartTime; [JsonIgnore] public virtual double StartTime => CommandsStartTime; [JsonIgnore] public virtual double EndTime => CommandsEndTime; [JsonIgnore] public double Duration => EndTime - StartTime; [JsonIgnore] public bool HasCommands => Timelines.Any(t => t.HasCommands); public virtual IEnumerable.TypedCommand> GetCommands(CommandTimelineSelector timelineSelector, double offset = 0) { if (offset != 0) return timelineSelector(this).Commands.Select(command => new CommandTimeline.TypedCommand { Easing = command.Easing, StartTime = offset + command.StartTime, EndTime = offset + command.EndTime, StartValue = command.StartValue, EndValue = command.EndValue, }); return timelineSelector(this).Commands; } } }