readd storyboard to beatmap + minor cleanup

This commit is contained in:
Aergwyn 2017-11-30 16:49:53 +01:00
parent 96f5bd3323
commit 016057ab01
3 changed files with 13 additions and 14 deletions

View File

@ -41,6 +41,11 @@ namespace osu.Game.Beatmaps
/// </summary> /// </summary>
public double TotalBreakTime => Breaks.Sum(b => b.Duration); public double TotalBreakTime => Breaks.Sum(b => b.Duration);
/// <summary>
/// The Beatmap's Storyboard.
/// </summary>
public Storyboard Storyboard = new Storyboard();
/// <summary> /// <summary>
/// Constructs a new beatmap. /// Constructs a new beatmap.
/// </summary> /// </summary>
@ -52,6 +57,7 @@ namespace osu.Game.Beatmaps
Breaks = original?.Breaks ?? Breaks; Breaks = original?.Breaks ?? Breaks;
ComboColors = original?.ComboColors ?? ComboColors; ComboColors = original?.ComboColors ?? ComboColors;
HitObjects = original?.HitObjects ?? HitObjects; HitObjects = original?.HitObjects ?? HitObjects;
Storyboard = original?.Storyboard ?? Storyboard;
if (original == null && Metadata == null) if (original == null && Metadata == null)
{ {

View File

@ -569,16 +569,11 @@ namespace osu.Game.Beatmaps
{ {
try try
{ {
Beatmap beatmap;
BeatmapDecoder decoder;
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path)))) using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
{ {
decoder = BeatmapDecoder.GetDecoder(stream); BeatmapDecoder decoder = BeatmapDecoder.GetDecoder(stream);
beatmap = decoder.Decode(stream); return decoder.Decode(stream);
} }
return beatmap;
} }
catch catch
{ {
@ -622,9 +617,7 @@ namespace osu.Game.Beatmaps
{ {
try try
{ {
Beatmap beatmap = Beatmap; if (Beatmap == null || BeatmapSetInfo.StoryboardFile == null)
if (beatmap == null || BeatmapSetInfo.StoryboardFile == null)
return new Storyboard(); return new Storyboard();
BeatmapDecoder decoder; BeatmapDecoder decoder;
@ -632,9 +625,9 @@ namespace osu.Game.Beatmaps
decoder = BeatmapDecoder.GetDecoder(stream); decoder = BeatmapDecoder.GetDecoder(stream);
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile)))) using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
decoder.Decode(stream, beatmap); decoder.Decode(stream, Beatmap);
return beatmap.Storyboard; return Beatmap.Storyboard;
} }
catch catch
{ {

View File

@ -245,7 +245,7 @@ namespace osu.Game.Screens.Play
private void initializeStoryboard(bool asyncLoad) private void initializeStoryboard(bool asyncLoad)
{ {
var beatmap = Beatmap.Value.Beatmap; var beatmap = Beatmap.Value;
storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value);
storyboard.Masking = true; storyboard.Masking = true;
@ -388,7 +388,7 @@ namespace osu.Game.Screens.Play
initializeStoryboard(true); initializeStoryboard(true);
var beatmap = Beatmap.Value; var beatmap = Beatmap.Value;
var storyboardVisible = showStoryboard && beatmap.Beatmap.Storyboard.HasDrawable; var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable;
storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800); storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800);
storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0); storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0);