mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 05:22:54 +08:00
Support applying initial values of storyboard commands
This commit is contained in:
parent
2ca36254f4
commit
b450abb687
@ -18,11 +18,23 @@ namespace osu.Game.Storyboards.Commands
|
||||
/// </summary>
|
||||
double EndTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the <see cref="Drawable"/> property affected by this storyboard command.
|
||||
/// Used to apply initial property values based on the list of commands given in <see cref="StoryboardSprite"/>.
|
||||
/// </summary>
|
||||
string PropertyName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the corresponding property in <see cref="Drawable"/> to the start value of this command.
|
||||
/// </summary>
|
||||
/// <param name="d">The target drawable.</param>
|
||||
void ApplyInitialValue(Drawable d);
|
||||
|
||||
/// <summary>
|
||||
/// Applies the transforms described by this storyboard command to the target drawable.
|
||||
/// </summary>
|
||||
/// <param name="d">The target drawable.</param>
|
||||
/// <returns>The sequence of transforms applied to the target drawable.</returns>
|
||||
TransformSequence<Drawable> ApplyTransform(Drawable d);
|
||||
TransformSequence<Drawable> ApplyTransforms(Drawable d);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => d.Alpha = StartValue;
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d) => d.FadeTo(StartValue).Then().FadeTo(EndValue, Duration, Easing);
|
||||
public override string PropertyName => nameof(Drawable.Alpha);
|
||||
|
||||
public override void ApplyInitialValue(Drawable d) => d.Alpha = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.FadeTo(StartValue).Then().FadeTo(EndValue, Duration, Easing);
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,12 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => d.Blending = StartValue;
|
||||
public override string PropertyName => nameof(Drawable.Blending);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
=> d.TransformTo(nameof(d.Blending), StartValue).Delay(Duration).TransformTo(nameof(d.Blending), EndValue);
|
||||
public override void ApplyInitialValue(Drawable d) => d.Blending = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.TransformTo(nameof(d.Blending), StartValue).Delay(Duration)
|
||||
.TransformTo(nameof(d.Blending), EndValue);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => d.Colour = StartValue;
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d) => d.FadeColour(StartValue).Then().FadeColour(EndValue, Duration, Easing);
|
||||
public override string PropertyName => nameof(Drawable.Colour);
|
||||
|
||||
public override void ApplyInitialValue(Drawable d) => d.Colour = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.FadeColour(StartValue).Then().FadeColour(EndValue, Duration, Easing);
|
||||
}
|
||||
}
|
||||
|
@ -32,15 +32,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
public T StartValue;
|
||||
public T EndValue;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the corresponding property in <see cref="Drawable"/> to the start value of this command.
|
||||
/// </summary>
|
||||
public abstract void SetInitialValue(Drawable d);
|
||||
public abstract string PropertyName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a corresponding property in <see cref="Drawable"/> that corresponds to this command group with the specified parameters.
|
||||
/// </summary>
|
||||
public abstract TransformSequence<Drawable> ApplyTransform(Drawable d);
|
||||
public abstract void ApplyInitialValue(Drawable d);
|
||||
|
||||
public abstract TransformSequence<Drawable> ApplyTransforms(Drawable d);
|
||||
|
||||
public int CompareTo(StoryboardCommand<T>? other)
|
||||
{
|
||||
|
@ -14,9 +14,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => ((IDrawableStoryboardElement)d).FlipH = StartValue;
|
||||
public override string PropertyName => nameof(IDrawableStoryboardElement.FlipH);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
public override void ApplyInitialValue(Drawable d) => ((IDrawableStoryboardElement)d).FlipH = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.TransformTo(nameof(IDrawableStoryboardElement.FlipH), StartValue).Delay(Duration)
|
||||
.TransformTo(nameof(IDrawableStoryboardElement.FlipH), EndValue);
|
||||
}
|
||||
|
@ -14,9 +14,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => ((IDrawableStoryboardElement)d).FlipV = StartValue;
|
||||
public override string PropertyName => nameof(IDrawableStoryboardElement.FlipV);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
public override void ApplyInitialValue(Drawable d) => ((IDrawableStoryboardElement)d).FlipV = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.TransformTo(nameof(IDrawableStoryboardElement.FlipV), StartValue).Delay(Duration)
|
||||
.TransformTo(nameof(IDrawableStoryboardElement.FlipV), EndValue);
|
||||
}
|
||||
|
@ -13,9 +13,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => d.Rotation = StartValue;
|
||||
public override string PropertyName => nameof(Drawable.Rotation);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
public override void ApplyInitialValue(Drawable d) => d.Rotation = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.RotateTo(StartValue).Then().RotateTo(EndValue, Duration, Easing);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => d.Scale = new Vector2(StartValue);
|
||||
public override string PropertyName => nameof(Drawable.Scale);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
public override void ApplyInitialValue(Drawable d) => d.Scale = new Vector2(StartValue);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.ScaleTo(StartValue).Then().ScaleTo(EndValue, Duration, Easing);
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => ((IDrawableStoryboardElement)d).VectorScale = StartValue;
|
||||
public override string PropertyName => nameof(IDrawableStoryboardElement.VectorScale);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
public override void ApplyInitialValue(Drawable d) => ((IDrawableStoryboardElement)d).VectorScale = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.TransformTo(nameof(IDrawableStoryboardElement.VectorScale), StartValue).Then()
|
||||
.TransformTo(nameof(IDrawableStoryboardElement.VectorScale), EndValue, Duration, Easing);
|
||||
}
|
||||
|
@ -13,9 +13,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => d.X = StartValue;
|
||||
public override string PropertyName => nameof(Drawable.X);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
public override void ApplyInitialValue(Drawable d) => d.X = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.MoveToX(StartValue).Then().MoveToX(EndValue, Duration, Easing);
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,11 @@ namespace osu.Game.Storyboards.Commands
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetInitialValue(Drawable d) => d.Y = StartValue;
|
||||
public override string PropertyName => nameof(Drawable.Y);
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransform(Drawable d)
|
||||
public override void ApplyInitialValue(Drawable d) => d.Y = StartValue;
|
||||
|
||||
public override TransformSequence<Drawable> ApplyTransforms(Drawable d)
|
||||
=> d.MoveToY(StartValue).Then().MoveToY(EndValue, Duration, Easing);
|
||||
}
|
||||
}
|
||||
|
@ -131,10 +131,18 @@ namespace osu.Game.Storyboards
|
||||
// if (triggeredGroups != null)
|
||||
// commands = commands.Concat(triggeredGroups.SelectMany(tuple => tuple.Item1.GetAllCommands(tuple.Item2)));
|
||||
|
||||
HashSet<string> appliedProperties = new HashSet<string>();
|
||||
|
||||
foreach (var command in commands.OrderBy(c => c.StartTime))
|
||||
{
|
||||
if (!appliedProperties.Contains(command.PropertyName))
|
||||
{
|
||||
command.ApplyInitialValue(drawable);
|
||||
appliedProperties.Add(command.PropertyName);
|
||||
}
|
||||
|
||||
using (drawable.BeginAbsoluteSequence(command.StartTime))
|
||||
command.ApplyTransform(drawable);
|
||||
command.ApplyTransforms(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user