From fbffc8bb89d7d4fd4e419e0d878987d44b64732b Mon Sep 17 00:00:00 2001 From: james58899 Date: Wed, 10 Jan 2018 18:55:04 +0800 Subject: [PATCH] fix load storyboard in osu file --- osu.Game/Beatmaps/BeatmapManager.cs | 11 +++-------- osu.Game/Beatmaps/Formats/Decoder.cs | 7 +++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index d7356cf100..c34ea13eda 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -696,14 +696,9 @@ namespace osu.Game.Beatmaps try { - Decoder decoder; - using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo?.Path)))) - decoder = Decoder.GetDecoder(stream); - - // try for .osb first and fall back to .osu - string storyboardFile = BeatmapSetInfo.StoryboardFile ?? BeatmapInfo.Path; - using (var stream = new StreamReader(store.GetStream(getPathForFile(storyboardFile)))) - return decoder.GetStoryboardDecoder().DecodeStoryboard(stream); + using (var beatmap = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo?.Path)))) + using (var storyboard = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile)))) + return Decoder.GetDecoder(beatmap).GetStoryboardDecoder().DecodeStoryboard(beatmap, storyboard); } catch { diff --git a/osu.Game/Beatmaps/Formats/Decoder.cs b/osu.Game/Beatmaps/Formats/Decoder.cs index 8eeada66e8..87e33429a4 100644 --- a/osu.Game/Beatmaps/Formats/Decoder.cs +++ b/osu.Game/Beatmaps/Formats/Decoder.cs @@ -70,10 +70,13 @@ namespace osu.Game.Beatmaps.Formats protected abstract void ParseBeatmap(StreamReader stream, Beatmap beatmap); - public virtual Storyboard DecodeStoryboard(StreamReader stream) + public virtual Storyboard DecodeStoryboard(params StreamReader[] streams) { var storyboard = new Storyboard(); - ParseStoryboard(stream, storyboard); + foreach (StreamReader stream in streams) + { + ParseStoryboard(stream, storyboard); + } return storyboard; }