1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 16:03:14 +08:00

fix some code quality

This commit is contained in:
jorolf 2019-07-29 11:49:59 +02:00
parent f4effd12c3
commit 0635680db5

View File

@ -54,28 +54,33 @@ namespace osu.Game.Skinning
public override Drawable GetDrawableComponent(string componentName) public override Drawable GetDrawableComponent(string componentName)
{ {
bool animatable = false; bool animatable = false;
(bool looping, double frametime) animationData = (false, 1000 / 60d); bool looping = true;
const double frametime = 1000 / 60d;
switch (componentName) switch (componentName)
{ {
case "Play/Miss": case "Play/Miss":
componentName = "hit0"; componentName = "hit0";
animatable = true; animatable = true;
looping = false;
break; break;
case "Play/Meh": case "Play/Meh":
componentName = "hit50"; componentName = "hit50";
animatable = true; animatable = true;
looping = false;
break; break;
case "Play/Good": case "Play/Good":
componentName = "hit100"; componentName = "hit100";
animatable = true; animatable = true;
looping = false;
break; break;
case "Play/Great": case "Play/Great":
componentName = "hit300"; componentName = "hit300";
animatable = true; animatable = true;
looping = false;
break; break;
case "Play/osu/number-text": case "Play/osu/number-text":
@ -93,7 +98,7 @@ namespace osu.Game.Skinning
if (texture != null && animatable) if (texture != null && animatable)
{ {
var animation = new TextureAnimation { DefaultFrameLength = animationData.frametime }; var animation = new TextureAnimation { DefaultFrameLength = frametime };
for (int i = 1; texture != null; i++) for (int i = 1; texture != null; i++)
{ {
@ -101,7 +106,9 @@ namespace osu.Game.Skinning
texture = GetTexture($"{componentName}-{i}"); texture = GetTexture($"{componentName}-{i}");
} }
animation.Repeat = animationData.looping; // This comment can be removed once we have components which are looping
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
animation.Repeat = looping;
return animation; return animation;
} }
@ -109,10 +116,7 @@ namespace osu.Game.Skinning
{ {
texture = GetTexture(componentName); texture = GetTexture(componentName);
if (texture == null) return texture == null ? null : new Sprite { Texture = texture };
return null;
return new Sprite { Texture = texture };
} }
} }