mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 17:32:54 +08:00
Minor cleanups for Legacy Storyboard/Beatmap decoder
This commit is contained in:
parent
f3bb47ffce
commit
316a764f6f
@ -239,11 +239,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case @"Source":
|
case @"Source":
|
||||||
beatmap.BeatmapInfo.Metadata.Source = pair.Value;
|
metadata.Source = pair.Value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case @"Tags":
|
case @"Tags":
|
||||||
beatmap.BeatmapInfo.Metadata.Tags = pair.Value;
|
metadata.Tags = pair.Value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case @"BeatmapID":
|
case @"BeatmapID":
|
||||||
@ -300,13 +300,13 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case LegacyEventType.Background:
|
case LegacyEventType.Background:
|
||||||
string bgFilename = split[2].Trim('"');
|
string bgFilename = split[2];
|
||||||
beatmap.BeatmapInfo.Metadata.BackgroundFile = bgFilename.ToStandardisedPath();
|
beatmap.BeatmapInfo.Metadata.BackgroundFile = CleanFilename(bgFilename); ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LegacyEventType.Video:
|
case LegacyEventType.Video:
|
||||||
string videoFilename = split[2].Trim('"');
|
string videoFilename = split[2];
|
||||||
beatmap.BeatmapInfo.Metadata.VideoFile = videoFilename.ToStandardisedPath();
|
beatmap.BeatmapInfo.Metadata.VideoFile = CleanFilename(videoFilename);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LegacyEventType.Break:
|
case LegacyEventType.Break:
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
@ -115,7 +116,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
protected KeyValuePair<string, string> SplitKeyVal(string line, char separator = ':')
|
protected KeyValuePair<string, string> SplitKeyVal(string line, char separator = ':')
|
||||||
{
|
{
|
||||||
var split = line.Trim().Split(new[] { separator }, 2);
|
var split = line.Split(separator, 2);
|
||||||
|
|
||||||
return new KeyValuePair<string, string>
|
return new KeyValuePair<string, string>
|
||||||
(
|
(
|
||||||
@ -124,6 +125,8 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected string CleanFilename(string path) => path.Trim('"').ToStandardisedPath();
|
||||||
|
|
||||||
protected enum Section
|
protected enum Section
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
@ -7,7 +7,6 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
@ -65,12 +64,14 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
private void handleEvents(string line)
|
private void handleEvents(string line)
|
||||||
{
|
{
|
||||||
var depth = 0;
|
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;
|
++depth;
|
||||||
line = line.Substring(1);
|
|
||||||
}
|
}
|
||||||
|
line = line.Substring(depth);
|
||||||
|
|
||||||
decodeVariables(ref line);
|
decodeVariables(ref line);
|
||||||
|
|
||||||
@ -89,7 +90,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
var layer = parseLayer(split[1]);
|
var layer = parseLayer(split[1]);
|
||||||
var origin = parseOrigin(split[2]);
|
var origin = parseOrigin(split[2]);
|
||||||
var path = cleanFilename(split[3]);
|
var path = CleanFilename(split[3]);
|
||||||
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
||||||
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
||||||
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
|
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
|
||||||
@ -101,7 +102,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
var layer = parseLayer(split[1]);
|
var layer = parseLayer(split[1]);
|
||||||
var origin = parseOrigin(split[2]);
|
var origin = parseOrigin(split[2]);
|
||||||
var path = cleanFilename(split[3]);
|
var path = CleanFilename(split[3]);
|
||||||
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
||||||
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
||||||
var frameCount = int.Parse(split[6]);
|
var frameCount = int.Parse(split[6]);
|
||||||
@ -116,7 +117,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
var time = double.Parse(split[1], CultureInfo.InvariantCulture);
|
var time = double.Parse(split[1], CultureInfo.InvariantCulture);
|
||||||
var layer = parseLayer(split[2]);
|
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;
|
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
|
||||||
storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
|
storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
|
||||||
break;
|
break;
|
||||||
@ -332,6 +333,5 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string cleanFilename(string path) => path.Trim('"').ToStandardisedPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user