1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 07:22:55 +08:00

Further improve legibility of texture lookup

This commit is contained in:
Dean Herbert 2019-08-20 17:39:24 +09:00
parent 9fbc8440fc
commit 6dd638b327

View File

@ -151,22 +151,33 @@ namespace osu.Game.Skinning
Texture getFrameTexture(int frame) => GetTexture($"{componentName}{animationSeparator}{frame}"); Texture getFrameTexture(int frame) => GetTexture($"{componentName}{animationSeparator}{frame}");
if (animatable && (texture = getFrameTexture(0)) != null) TextureAnimation animation = null;
if (animatable)
{ {
var animation = new TextureAnimation { DefaultFrameLength = default_frame_time }; for (int i = 0;; i++)
for (int i = 1; texture != null; i++)
{ {
if ((texture = getFrameTexture(i)) == null)
break;
if (animation == null)
animation = new TextureAnimation
{
DefaultFrameLength = default_frame_time,
Repeat = looping
};
animation.AddFrame(texture); animation.AddFrame(texture);
texture = getFrameTexture(i);
} }
animation.Repeat = looping;
return animation;
} }
return (texture = GetTexture(componentName)) == null ? null : new Sprite { Texture = texture }; if (animation != null)
return animation;
if ((texture = GetTexture(componentName)) != null)
return new Sprite { Texture = texture };
return null;
} }
public class LegacySliderBall : Sprite public class LegacySliderBall : Sprite