1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:42:54 +08:00

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 sr = new StreamReader(stream))
{
var legacyDecoded = new OsuLegacyDecoder().Decode(sr);
var legacyDecoded = new LegacyBeatmapDecoder().DecodeBeatmap(sr);
using (var ms = new MemoryStream())
using (var sw = new StreamWriter(ms))
using (var sr2 = new StreamReader(ms))
@ -168,7 +168,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
sw.Flush();
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 osu.Game.IO.Serialization;
using osu.Game.Storyboards;
namespace osu.Game.Beatmaps.Formats
{
public class OsuJsonDecoder : BeatmapDecoder
public class OsuJsonDecoder : Decoder
{
public static void Register()
{
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.DiscardBufferedData();
try
{
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
}
stream.ReadToEnd().DeserializeInto(beatmap);
foreach (var hitObject in beatmap.HitObjects)
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
}
protected override void ParseStoryboard(StreamReader stream, Storyboard storyboard)
{
// throw new System.NotImplementedException();
}
}
}