mirror of https://github.com/ppy/osu
make legacy skins animatable
This commit is contained in:
parent
05eb8ecd98
commit
f4effd12c3
|
@ -9,6 +9,7 @@
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Animations;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
|
@ -52,22 +53,29 @@ protected override void Dispose(bool isDisposing)
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(string componentName)
|
public override Drawable GetDrawableComponent(string componentName)
|
||||||
{
|
{
|
||||||
|
bool animatable = false;
|
||||||
|
(bool looping, double frametime) animationData = (false, 1000 / 60d);
|
||||||
|
|
||||||
switch (componentName)
|
switch (componentName)
|
||||||
{
|
{
|
||||||
case "Play/Miss":
|
case "Play/Miss":
|
||||||
componentName = "hit0";
|
componentName = "hit0";
|
||||||
|
animatable = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Play/Meh":
|
case "Play/Meh":
|
||||||
componentName = "hit50";
|
componentName = "hit50";
|
||||||
|
animatable = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Play/Good":
|
case "Play/Good":
|
||||||
componentName = "hit100";
|
componentName = "hit100";
|
||||||
|
animatable = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Play/Great":
|
case "Play/Great":
|
||||||
componentName = "hit300";
|
componentName = "hit300";
|
||||||
|
animatable = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Play/osu/number-text":
|
case "Play/osu/number-text":
|
||||||
|
@ -81,15 +89,31 @@ public override Drawable GetDrawableComponent(string componentName)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// temporary allowance is given for skins the fact that stable handles non-animatable items such as hitcircles (incorrectly)
|
var texture = GetTexture($"{componentName}-0");
|
||||||
// by (incorrectly) displaying the first frame of animation rather than the non-animated version.
|
|
||||||
// users have used this to "hide" certain elements like hit300.
|
|
||||||
var texture = GetTexture($"{componentName}-0") ?? GetTexture(componentName);
|
|
||||||
|
|
||||||
if (texture == null)
|
if (texture != null && animatable)
|
||||||
return null;
|
{
|
||||||
|
var animation = new TextureAnimation { DefaultFrameLength = animationData.frametime };
|
||||||
|
|
||||||
return new Sprite { Texture = texture };
|
for (int i = 1; texture != null; i++)
|
||||||
|
{
|
||||||
|
animation.AddFrame(texture);
|
||||||
|
texture = GetTexture($"{componentName}-{i}");
|
||||||
|
}
|
||||||
|
|
||||||
|
animation.Repeat = animationData.looping;
|
||||||
|
|
||||||
|
return animation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
texture = GetTexture(componentName);
|
||||||
|
|
||||||
|
if (texture == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new Sprite { Texture = texture };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Texture GetTexture(string componentName)
|
public override Texture GetTexture(string componentName)
|
||||||
|
|
Loading…
Reference in New Issue