mirror of https://github.com/ppy/osu
Strip comments from everything except metadata
This commit is contained in:
parent
a9f8c2acb8
commit
6c861a1638
|
@ -62,32 +62,34 @@ protected override void ParseStreamInto(StreamReader stream, Beatmap beatmap)
|
|||
|
||||
protected override void ParseLine(Beatmap beatmap, Section section, string line)
|
||||
{
|
||||
var stripped_line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.General:
|
||||
handleGeneral(line);
|
||||
handleGeneral(stripped_line);
|
||||
return;
|
||||
case Section.Editor:
|
||||
handleEditor(line);
|
||||
handleEditor(stripped_line);
|
||||
return;
|
||||
case Section.Metadata:
|
||||
handleMetadata(line);
|
||||
return;
|
||||
case Section.Difficulty:
|
||||
handleDifficulty(line);
|
||||
handleDifficulty(stripped_line);
|
||||
return;
|
||||
case Section.Events:
|
||||
handleEvent(line);
|
||||
handleEvent(stripped_line);
|
||||
return;
|
||||
case Section.TimingPoints:
|
||||
handleTimingPoint(line);
|
||||
handleTimingPoint(stripped_line);
|
||||
return;
|
||||
case Section.HitObjects:
|
||||
handleHitObject(line);
|
||||
handleHitObject(stripped_line);
|
||||
return;
|
||||
}
|
||||
|
||||
base.ParseLine(beatmap, section, line);
|
||||
base.ParseLine(beatmap, section, stripped_line);
|
||||
}
|
||||
|
||||
private void handleGeneral(string line)
|
||||
|
|
|
@ -58,6 +58,8 @@ protected override void ParseStreamInto(StreamReader stream, T output)
|
|||
|
||||
protected virtual void ParseLine(T output, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.Colours:
|
||||
|
@ -65,6 +67,13 @@ protected virtual void ParseLine(T output, Section section, string line)
|
|||
return;
|
||||
}
|
||||
}
|
||||
internal string StripComments(string line)
|
||||
{
|
||||
var index = line.IndexOf("//");
|
||||
if (index > 0)
|
||||
return line.Substring(0, index);
|
||||
return line;
|
||||
}
|
||||
|
||||
private bool hasComboColours;
|
||||
|
||||
|
@ -74,12 +83,10 @@ private void handleColours(T output, string line)
|
|||
|
||||
bool isCombo = pair.Key.StartsWith(@"Combo");
|
||||
|
||||
line = Regex.Replace(pair.Value, "[^0-9,]", "");
|
||||
|
||||
string[] split = line.Split(',');
|
||||
string[] split = pair.Value.Split(',');
|
||||
|
||||
if (split.Length != 3)
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {line}");
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {pair.Value}");
|
||||
|
||||
if (!byte.TryParse(split[0], out var r) || !byte.TryParse(split[1], out var g) || !byte.TryParse(split[2], out var b))
|
||||
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
|
||||
|
|
|
@ -42,6 +42,8 @@ protected override void ParseStreamInto(StreamReader stream, Storyboard storyboa
|
|||
|
||||
protected override void ParseLine(Storyboard storyboard, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.Events:
|
||||
|
|
|
@ -14,6 +14,8 @@ public LegacySkinDecoder()
|
|||
|
||||
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
|
||||
{
|
||||
line = StripComments(line);
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.General:
|
||||
|
|
Loading…
Reference in New Issue