1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 18:32:55 +08:00

Coerce undefined animation loop types to Forever

This commit is contained in:
Bartłomiej Dach 2021-01-31 15:33:07 +01:00
parent d7e5a21213
commit b9a49d5589

View File

@ -139,7 +139,7 @@ namespace osu.Game.Beatmaps.Formats
// this is random as hell but taken straight from osu-stable. // this is random as hell but taken straight from osu-stable.
frameDelay = Math.Round(0.015 * frameDelay) * 1.186 * (1000 / 60f); frameDelay = Math.Round(0.015 * frameDelay) * 1.186 * (1000 / 60f);
var loopType = split.Length > 8 ? (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), split[8]) : AnimationLoopType.LoopForever; var loopType = split.Length > 8 ? parseAnimationLoopType(split[8]) : AnimationLoopType.LoopForever;
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType); storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
storyboard.GetLayer(layer).Add(storyboardSprite); storyboard.GetLayer(layer).Add(storyboardSprite);
break; break;
@ -341,6 +341,12 @@ namespace osu.Game.Beatmaps.Formats
} }
} }
private AnimationLoopType parseAnimationLoopType(string value)
{
var parsed = (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), value);
return Enum.IsDefined(typeof(AnimationLoopType), parsed) ? parsed : AnimationLoopType.LoopForever;
}
private void handleVariables(string line) private void handleVariables(string line)
{ {
var pair = SplitKeyVal(line, '='); var pair = SplitKeyVal(line, '=');