1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 19:05:37 +08:00

split storyboard loading into GetStoryboard()

This commit is contained in:
Aergwyn 2017-11-29 21:28:02 +01:00
parent dddd432dc8
commit cd653c1cbc
2 changed files with 27 additions and 7 deletions

View File

@ -25,6 +25,7 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Storyboards;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
@ -577,13 +578,6 @@ namespace osu.Game.Beatmaps
beatmap = decoder.Decode(stream); beatmap = decoder.Decode(stream);
} }
if (beatmap == null || BeatmapSetInfo.StoryboardFile == null)
return beatmap;
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
decoder.Decode(stream, beatmap);
return beatmap; return beatmap;
} }
catch catch
@ -623,6 +617,30 @@ namespace osu.Game.Beatmaps
} }
protected override Waveform GetWaveform() => new Waveform(store.GetStream(getPathForFile(Metadata.AudioFile))); protected override Waveform GetWaveform() => new Waveform(store.GetStream(getPathForFile(Metadata.AudioFile)));
protected override Storyboard GetStoryboard()
{
try
{
Beatmap beatmap = Beatmap;
if (beatmap == null || BeatmapSetInfo.StoryboardFile == null)
return new Storyboard();
BeatmapDecoder decoder;
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
decoder = BeatmapDecoder.GetDecoder(stream);
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
decoder.Decode(stream, beatmap);
return beatmap.Storyboard;
}
catch
{
return new Storyboard();
}
}
} }
/// <summary> /// <summary>

View File

@ -9,6 +9,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Game.Storyboards;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
@ -40,6 +41,7 @@ namespace osu.Game.Beatmaps
protected abstract Texture GetBackground(); protected abstract Texture GetBackground();
protected abstract Track GetTrack(); protected abstract Track GetTrack();
protected virtual Waveform GetWaveform() => new Waveform(); protected virtual Waveform GetWaveform() => new Waveform();
protected virtual Storyboard GetStoryboard() => new Storyboard();
public bool BeatmapLoaded => beatmap.IsValueCreated; public bool BeatmapLoaded => beatmap.IsValueCreated;
public Beatmap Beatmap => beatmap.Value.Result; public Beatmap Beatmap => beatmap.Value.Result;