1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:57:24 +08:00

remove Storyboard from Beatmap, add it to WorkingBeatmap

This commit is contained in:
Aergwyn 2017-11-29 21:54:04 +01:00
parent cd653c1cbc
commit 96f5bd3323
3 changed files with 35 additions and 7 deletions

View File

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

View File

@ -35,6 +35,7 @@ namespace osu.Game.Beatmaps
background = new AsyncLazy<Texture>(populateBackground);
track = new AsyncLazy<Track>(populateTrack);
waveform = new AsyncLazy<Waveform>(populateWaveform);
storyboard = new AsyncLazy<Storyboard>(populateStoryboard);
}
protected abstract Beatmap GetBeatmap();
@ -86,6 +87,13 @@ namespace osu.Game.Beatmaps
private Waveform populateWaveform() => GetWaveform();
public bool StoryboardLoaded => storyboard.IsValueCreated;
public Storyboard Storyboard => storyboard.Value.Result;
public async Task<Storyboard> GetStoryboardAsync() => await storyboard.Value;
private readonly AsyncLazy<Storyboard> storyboard;
private Storyboard populateStoryboard() => GetStoryboard();
public void TransferTo(WorkingBeatmap other)
{
if (track.IsValueCreated && Track != null && BeatmapInfo.AudioEquals(other.BeatmapInfo))
@ -99,6 +107,7 @@ namespace osu.Game.Beatmaps
{
if (BackgroundLoaded) Background?.Dispose();
if (WaveformLoaded) Waveform?.Dispose();
if (StoryboardLoaded) Storyboard?.Dispose();
}
public void DisposeTrack()

View File

@ -5,10 +5,11 @@ using osu.Game.Beatmaps;
using osu.Game.Storyboards.Drawables;
using System.Collections.Generic;
using System.Linq;
using System;
namespace osu.Game.Storyboards
{
public class Storyboard
public class Storyboard : IDisposable
{
private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>();
public IEnumerable<StoryboardLayer> Layers => layers.Values;
@ -59,5 +60,29 @@ namespace osu.Game.Storyboards
}
return drawable;
}
#region Disposal
~Storyboard()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private bool isDisposed;
protected virtual void Dispose(bool isDisposing)
{
if (isDisposed)
return;
isDisposed = true;
}
#endregion
}
}