From 6dd638b32793acb6dd0d2db08f92ec00cae3db39 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 20 Aug 2019 17:39:24 +0900 Subject: [PATCH] Further improve legibility of texture lookup --- osu.Game/Skinning/LegacySkin.cs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 94421b1251..6e983fe771 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -151,22 +151,33 @@ namespace osu.Game.Skinning 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 = 1; texture != null; i++) + for (int i = 0;; i++) { + if ((texture = getFrameTexture(i)) == null) + break; + + if (animation == null) + animation = new TextureAnimation + { + DefaultFrameLength = default_frame_time, + Repeat = looping + }; + 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