1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

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>
/// 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 @@ namespace osu.Game.Skinning
if (textures.Length > 0)
{
var animation = new SkinnableTextureAnimation
var animation = new SkinnableTextureAnimation(startAtCurrentTime)
{
DefaultFrameLength = getFrameLength(source, applyConfigFrameRate, textures),
Repeat = looping,
@ -60,8 +61,8 @@ namespace osu.Game.Skinning
[Resolved(canBeNull: true)]
private IAnimationTimeReference timeReference { get; set; }
public SkinnableTextureAnimation()
: base(false)
public SkinnableTextureAnimation(bool startAtCurrentTime = true)
: base(startAtCurrentTime)
{
}