Merge pull request #8555 from smoogipoo/legacy-skin-start-at-current-time

Add startAtCurrentTime parameter to GetAnimation()
This commit is contained in:
Dean Herbert 2020-04-02 14:57:41 +09:00 committed by GitHub
commit 366dc7085d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -9,6 +9,10 @@ namespace osu.Game.Skinning
/// <summary>
/// Denotes an object which provides a reference time to start animations from.
/// </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]
public interface IAnimationTimeReference
{

View File

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