Merge branch 'i-beatmap' into beatmap-conversion-rework

This commit is contained in:
smoogipoo
2018-05-07 10:00:24 +09:00
96 changed files with 1002 additions and 428 deletions

View File

@ -21,7 +21,7 @@ namespace osu.Game.Beatmaps.Formats
return output;
}
protected abstract void ParseStreamInto(StreamReader stream, TOutput beatmap);
protected abstract void ParseStreamInto(StreamReader stream, TOutput output);
}
public abstract class Decoder

View File

@ -13,15 +13,15 @@ namespace osu.Game.Beatmaps.Formats
AddDecoder<Beatmap>("{", m => new JsonBeatmapDecoder());
}
protected override void ParseStreamInto(StreamReader stream, Beatmap beatmap)
protected override void ParseStreamInto(StreamReader stream, Beatmap output)
{
stream.BaseStream.Position = 0;
stream.DiscardBufferedData();
stream.ReadToEnd().DeserializeInto(beatmap);
stream.ReadToEnd().DeserializeInto(output);
foreach (var hitObject in beatmap.HitObjects)
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
foreach (var hitObject in output.HitObjects)
hitObject.ApplyDefaults(output.ControlPointInfo, output.BeatmapInfo.BaseDifficulty);
}
}
}

View File

@ -373,17 +373,18 @@ namespace osu.Game.Beatmaps.Formats
if (parser == null)
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
var obj = parser.Parse(line);
var obj = parser.Parse(line, getOffsetTime());
if (obj != null)
{
obj.StartTime = getOffsetTime(obj.StartTime);
beatmap.HitObjects.Add(obj);
}
}
private int getOffsetTime(int time) => time + (ApplyOffsets ? offset : 0);
private double getOffsetTime() => ApplyOffsets ? offset : 0;
private double getOffsetTime(double time) => time + (ApplyOffsets ? offset : 0);
}
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps.Formats
FormatVersion = version;
}
protected override void ParseStreamInto(StreamReader stream, T beatmap)
protected override void ParseStreamInto(StreamReader stream, T output)
{
Section section = Section.None;
@ -33,14 +33,21 @@ namespace osu.Game.Beatmaps.Formats
{
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
{
Logger.Log($"Unknown section \"{line}\" in {beatmap}");
Logger.Log($"Unknown section \"{line}\" in {output}");
section = Section.None;
}
continue;
}
ParseLine(beatmap, section, line);
try
{
ParseLine(output, section, line);
}
catch (Exception e)
{
Logger.Error(e, $"Failed to process line \"{line}\" into {output}");
}
}
}