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 osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Storyboards.Drawables;
|
|
|
|
|
using System.Collections.Generic;
|
2017-09-08 10:11:57 +00:00
|
|
|
|
using System.Linq;
|
2017-09-07 21:55:05 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards
|
|
|
|
|
{
|
2017-09-08 11:04:53 +00:00
|
|
|
|
public class SpriteDefinition : CommandTimelineGroup, IElementDefinition
|
2017-09-07 21:55:05 +00:00
|
|
|
|
{
|
2017-09-08 11:04:53 +00:00
|
|
|
|
public string Path { get; set; }
|
2017-09-07 21:55:05 +00:00
|
|
|
|
public Anchor Origin;
|
|
|
|
|
public Vector2 InitialPosition;
|
|
|
|
|
|
2017-09-08 11:04:53 +00:00
|
|
|
|
private readonly List<CommandLoop> loops = new List<CommandLoop>();
|
|
|
|
|
private readonly List<CommandTrigger> triggers = new List<CommandTrigger>();
|
2017-09-08 10:11:57 +00:00
|
|
|
|
|
2017-09-07 21:55:05 +00:00
|
|
|
|
public SpriteDefinition(string path, Anchor origin, Vector2 initialPosition)
|
|
|
|
|
{
|
|
|
|
|
Path = path;
|
|
|
|
|
Origin = origin;
|
|
|
|
|
InitialPosition = initialPosition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CommandLoop AddLoop(double startTime, int loopCount)
|
|
|
|
|
{
|
|
|
|
|
var loop = new CommandLoop(startTime, loopCount);
|
|
|
|
|
loops.Add(loop);
|
|
|
|
|
return loop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CommandTrigger AddTrigger(string triggerName, double startTime, double endTime, int groupNumber)
|
|
|
|
|
{
|
|
|
|
|
var trigger = new CommandTrigger(triggerName, startTime, endTime, groupNumber);
|
|
|
|
|
triggers.Add(trigger);
|
|
|
|
|
return trigger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual Drawable CreateDrawable()
|
|
|
|
|
=> new StoryboardSprite(this);
|
|
|
|
|
|
2017-09-08 10:11:57 +00:00
|
|
|
|
public override void ApplyTransforms(Drawable target, double offset = 0)
|
2017-09-07 21:55:05 +00:00
|
|
|
|
{
|
2017-09-08 10:11:57 +00:00
|
|
|
|
base.ApplyTransforms(target, offset);
|
|
|
|
|
foreach (var loop in loops.OrderBy(l => l.StartTime))
|
|
|
|
|
loop.ApplyTransforms(target, offset);
|
2017-09-07 21:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
=> $"{Path}, {Origin}, {InitialPosition}";
|
|
|
|
|
}
|
|
|
|
|
}
|