Add startAtCurrentTime parameter to GetAnimation()

This commit is contained in:
smoogipoo 2020-04-02 14:30:22 +09:00
parent e862ca23ad
commit beb1f037e9
2 changed files with 9 additions and 4 deletions

View File

@ -9,6 +9,10 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// Denotes an object which provides a reference time to start animations from. /// Denotes an object which provides a reference time to start animations from.
/// </summary> /// </summary>
/// <remarks>
/// This should not be used to start an animation immediately at the current time.
/// To do so, use <see cref="LegacySkinExtensions.GetAnimation"/> with <code>startAtCurrentTime = true</code> instead.
/// </remarks>
[Cached] [Cached]
public interface IAnimationTimeReference public interface IAnimationTimeReference
{ {

View File

@ -14,7 +14,8 @@ namespace osu.Game.Skinning
{ {
public static class LegacySkinExtensions public static class LegacySkinExtensions
{ {
public static Drawable GetAnimation(this ISkin source, string componentName, bool animatable, bool looping, bool applyConfigFrameRate = false, string animationSeparator = "-") public static Drawable GetAnimation(this ISkin source, string componentName, bool animatable, bool looping, bool applyConfigFrameRate = false, string animationSeparator = "-",
bool startAtCurrentTime = false)
{ {
Texture texture; Texture texture;
@ -24,7 +25,7 @@ public static Drawable GetAnimation(this ISkin source, string componentName, boo
if (textures.Length > 0) if (textures.Length > 0)
{ {
var animation = new SkinnableTextureAnimation var animation = new SkinnableTextureAnimation(startAtCurrentTime)
{ {
DefaultFrameLength = getFrameLength(source, applyConfigFrameRate, textures), DefaultFrameLength = getFrameLength(source, applyConfigFrameRate, textures),
Repeat = looping, Repeat = looping,
@ -60,8 +61,8 @@ public class SkinnableTextureAnimation : TextureAnimation
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private IAnimationTimeReference timeReference { get; set; } private IAnimationTimeReference timeReference { get; set; }
public SkinnableTextureAnimation() public SkinnableTextureAnimation(bool startAtCurrentTime = true)
: base(false) : base(startAtCurrentTime)
{ {
} }