2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2017-09-09 13:34:26 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-07 21:55:05 +00:00
|
|
|
|
namespace osu.Game.Storyboards.Drawables
|
|
|
|
|
{
|
2019-12-18 08:21:38 +00:00
|
|
|
|
internal interface IFlippable : ITransformable
|
2017-09-07 21:55:05 +00:00
|
|
|
|
{
|
|
|
|
|
bool FlipH { get; set; }
|
|
|
|
|
bool FlipV { get; set; }
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-12-18 08:21:38 +00:00
|
|
|
|
internal class TransformFlipH : Transform<bool, IFlippable>
|
2017-09-09 13:34:26 +00:00
|
|
|
|
{
|
|
|
|
|
private bool valueAt(double time)
|
|
|
|
|
=> time < EndTime ? StartValue : EndValue;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-09 13:34:26 +00:00
|
|
|
|
public override string TargetMember => nameof(IFlippable.FlipH);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-09 13:34:26 +00:00
|
|
|
|
protected override void Apply(IFlippable d, double time) => d.FlipH = valueAt(time);
|
|
|
|
|
protected override void ReadIntoStartValue(IFlippable d) => StartValue = d.FlipH;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-12-18 08:21:38 +00:00
|
|
|
|
internal class TransformFlipV : Transform<bool, IFlippable>
|
2017-09-09 13:34:26 +00:00
|
|
|
|
{
|
|
|
|
|
private bool valueAt(double time)
|
|
|
|
|
=> time < EndTime ? StartValue : EndValue;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-09 13:34:26 +00:00
|
|
|
|
public override string TargetMember => nameof(IFlippable.FlipV);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-09 13:34:26 +00:00
|
|
|
|
protected override void Apply(IFlippable d, double time) => d.FlipV = valueAt(time);
|
|
|
|
|
protected override void ReadIntoStartValue(IFlippable d) => StartValue = d.FlipV;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-12-18 08:21:38 +00:00
|
|
|
|
internal static class FlippableExtensions
|
2017-09-09 13:34:26 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adjusts <see cref="IFlippable.FlipH"/> after a delay.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
|
|
|
|
public static TransformSequence<T> TransformFlipH<T>(this T flippable, bool newValue, double delay = 0)
|
2019-12-07 11:49:52 +00:00
|
|
|
|
where T : class, IFlippable
|
2017-09-09 13:34:26 +00:00
|
|
|
|
=> flippable.TransformTo(flippable.PopulateTransform(new TransformFlipH(), newValue, delay));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-09 13:34:26 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adjusts <see cref="IFlippable.FlipV"/> after a delay.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
|
|
|
|
public static TransformSequence<T> TransformFlipV<T>(this T flippable, bool newValue, double delay = 0)
|
2019-12-07 11:49:52 +00:00
|
|
|
|
where T : class, IFlippable
|
2017-09-09 13:34:26 +00:00
|
|
|
|
=> flippable.TransformTo(flippable.PopulateTransform(new TransformFlipV(), newValue, delay));
|
|
|
|
|
}
|
2017-09-07 21:55:05 +00:00
|
|
|
|
}
|