Apply changes in line with master changes

This commit is contained in:
smoogipoo
2017-12-21 13:59:03 +09:00
parent f6552da406
commit bfa4f1a2c3
2 changed files with 13 additions and 14 deletions

View File

@ -158,8 +158,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
using (var stream = Resource.OpenResource(filename)) using (var stream = Resource.OpenResource(filename))
using (var sr = new StreamReader(stream)) using (var sr = new StreamReader(stream))
{ {
var legacyDecoded = new OsuLegacyDecoder().Decode(sr);
var legacyDecoded = new LegacyBeatmapDecoder().DecodeBeatmap(sr);
using (var ms = new MemoryStream()) using (var ms = new MemoryStream())
using (var sw = new StreamWriter(ms)) using (var sw = new StreamWriter(ms))
using (var sr2 = new StreamReader(ms)) using (var sr2 = new StreamReader(ms))
@ -168,7 +168,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
sw.Flush(); sw.Flush();
ms.Position = 0; ms.Position = 0;
return (legacyDecoded, new OsuJsonDecoder().Decode(sr2)); return (legacyDecoded, new OsuJsonDecoder().DecodeBeatmap(sr2));
} }
} }
} }

View File

@ -3,34 +3,33 @@
using System.IO; using System.IO;
using osu.Game.IO.Serialization; using osu.Game.IO.Serialization;
using osu.Game.Storyboards;
namespace osu.Game.Beatmaps.Formats namespace osu.Game.Beatmaps.Formats
{ {
public class OsuJsonDecoder : BeatmapDecoder public class OsuJsonDecoder : Decoder
{ {
public static void Register() public static void Register()
{ {
AddDecoder<OsuJsonDecoder>("{"); AddDecoder<OsuJsonDecoder>("{");
} }
protected override void ParseFile(StreamReader stream, Beatmap beatmap) public override Decoder GetStoryboardDecoder() => this;
protected override void ParseBeatmap(StreamReader stream, Beatmap beatmap)
{ {
stream.BaseStream.Position = 0; stream.BaseStream.Position = 0;
stream.DiscardBufferedData(); stream.DiscardBufferedData();
try stream.ReadToEnd().DeserializeInto(beatmap);
{
string fullText = stream.ReadToEnd();
fullText.DeserializeInto(beatmap);
}
catch
{
// Temporary because storyboards are deserialized into beatmaps at the moment
// This try-catch shouldn't exist in the future
}
foreach (var hitObject in beatmap.HitObjects) foreach (var hitObject in beatmap.HitObjects)
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty); hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
} }
protected override void ParseStoryboard(StreamReader stream, Storyboard storyboard)
{
// throw new System.NotImplementedException();
}
} }
} }