Minor cleanups for Legacy Storyboard/Beatmap decoder

This commit is contained in:
Berkan Diler
2020-01-23 16:23:53 +01:00
parent f3bb47ffce
commit 316a764f6f
3 changed files with 17 additions and 14 deletions

View File

@ -7,7 +7,6 @@ using System.Globalization;
using System.IO;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Game.IO;
using osu.Game.Storyboards;
@ -65,12 +64,14 @@ namespace osu.Game.Beatmaps.Formats
private void handleEvents(string line)
{
var depth = 0;
var lineSpan = line.AsSpan();
while (line.StartsWith(" ", StringComparison.Ordinal) || line.StartsWith("_", StringComparison.Ordinal))
while (lineSpan.StartsWith(" ", StringComparison.Ordinal) || lineSpan.StartsWith("_", StringComparison.Ordinal))
{
lineSpan = lineSpan.Slice(1);
++depth;
line = line.Substring(1);
}
line = line.Substring(depth);
decodeVariables(ref line);
@ -89,7 +90,7 @@ namespace osu.Game.Beatmaps.Formats
{
var layer = parseLayer(split[1]);
var origin = parseOrigin(split[2]);
var path = cleanFilename(split[3]);
var path = CleanFilename(split[3]);
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
@ -101,7 +102,7 @@ namespace osu.Game.Beatmaps.Formats
{
var layer = parseLayer(split[1]);
var origin = parseOrigin(split[2]);
var path = cleanFilename(split[3]);
var path = CleanFilename(split[3]);
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
var frameCount = int.Parse(split[6]);
@ -116,7 +117,7 @@ namespace osu.Game.Beatmaps.Formats
{
var time = double.Parse(split[1], CultureInfo.InvariantCulture);
var layer = parseLayer(split[2]);
var path = cleanFilename(split[3]);
var path = CleanFilename(split[3]);
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
break;
@ -332,6 +333,5 @@ namespace osu.Game.Beatmaps.Formats
}
}
private string cleanFilename(string path) => path.Trim('"').ToStandardisedPath();
}
}