mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Improve beatmap loading and hydration
This commit is contained in:
@ -17,7 +17,7 @@ namespace osu.Game.Beatmaps
|
||||
[NotNull, Indexed]
|
||||
public int BeatmapMetadataID { get; set; }
|
||||
[Ignore]
|
||||
public List<Beatmap> Beatmaps { get; protected set; }
|
||||
public List<Beatmap> Beatmaps { get; protected set; } = new List<Beatmap>();
|
||||
[Ignore]
|
||||
public BeatmapMetadata Metadata { get; set; }
|
||||
[Ignore]
|
||||
|
@ -20,6 +20,6 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
decoders[magic] = typeof(T);
|
||||
}
|
||||
|
||||
|
||||
public abstract void Decode(TextReader stream, Beatmap beatmap);
|
||||
}
|
@ -202,16 +202,16 @@ namespace osu.Game.Beatmaps.Formats
|
||||
});
|
||||
}
|
||||
|
||||
public override Beatmap Decode(TextReader stream)
|
||||
public override void Decode(TextReader stream, Beatmap beatmap)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
Metadata = new BeatmapMetadata(),
|
||||
BaseDifficulty = new BaseDifficulty(),
|
||||
HitObjects = new List<HitObject>(),
|
||||
ControlPoints = new List<ControlPoint>(),
|
||||
ComboColors = new List<Color4>(),
|
||||
};
|
||||
// We don't overwrite these two because they're DB bound
|
||||
if (beatmap.Metadata == null) beatmap.Metadata = new BeatmapMetadata();
|
||||
if (beatmap.BaseDifficulty == null) beatmap.BaseDifficulty = new BaseDifficulty();
|
||||
// These are fine though
|
||||
beatmap.HitObjects = new List<HitObject>();
|
||||
beatmap.ControlPoints = new List<ControlPoint>();
|
||||
beatmap.ComboColors = new List<Color4>();
|
||||
|
||||
var section = Section.None;
|
||||
string line;
|
||||
while (true)
|
||||
@ -266,7 +266,6 @@ namespace osu.Game.Beatmaps.Formats
|
||||
break;
|
||||
}
|
||||
}
|
||||
return beatmap;
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,8 @@ namespace osu.Game.Beatmaps.IO
|
||||
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
||||
{
|
||||
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||
firstMap = decoder.Decode(stream);
|
||||
firstMap = new Beatmap();
|
||||
decoder.Decode(stream, firstMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user