mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Rewrite waveform invalidation
This commit is contained in:
parent
f2e8776529
commit
d0645ce151
@ -34,8 +34,6 @@ namespace osu.Game.Beatmaps
|
||||
// TODO: remove once the fallback lookup is not required (and access via `working.BeatmapInfo.Metadata` directly).
|
||||
public BeatmapMetadata Metadata => BeatmapInfo.Metadata;
|
||||
|
||||
public Waveform Waveform => waveform.Value;
|
||||
|
||||
public Storyboard Storyboard => storyboard.Value;
|
||||
|
||||
public Texture Background => GetBackground(); // Texture uses ref counting, so we want to return a new instance every usage.
|
||||
@ -48,7 +46,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
private readonly object beatmapFetchLock = new object();
|
||||
|
||||
private Lazy<Waveform> waveform;
|
||||
private Waveform waveform;
|
||||
private readonly Lazy<Storyboard> storyboard;
|
||||
private readonly Lazy<ISkin> skin;
|
||||
private Track track; // track is not Lazy as we allow transferring and loading multiple times.
|
||||
@ -60,7 +58,6 @@ namespace osu.Game.Beatmaps
|
||||
BeatmapInfo = beatmapInfo;
|
||||
BeatmapSetInfo = beatmapInfo.BeatmapSet ?? new BeatmapSetInfo();
|
||||
|
||||
waveform = new Lazy<Waveform>(GetWaveform);
|
||||
storyboard = new Lazy<Storyboard>(GetStoryboard);
|
||||
skin = new Lazy<ISkin>(GetSkin);
|
||||
}
|
||||
@ -171,6 +168,18 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
#endregion
|
||||
|
||||
#region Waveform
|
||||
|
||||
public Waveform Waveform => waveform ??= GetWaveform();
|
||||
|
||||
/// <summary>
|
||||
/// Reloads waveform of beatmap's track even if one is already cached.
|
||||
/// </summary>
|
||||
/// <returns>Newly loaded waveform.</returns>
|
||||
public Waveform LoadWaveform() => waveform = GetWaveform();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Beatmap
|
||||
|
||||
public virtual bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false;
|
||||
@ -329,12 +338,6 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
#endregion
|
||||
|
||||
public void InvalidateWaveform()
|
||||
{
|
||||
if (waveform.IsValueCreated)
|
||||
waveform = new Lazy<Waveform>(GetWaveform);
|
||||
}
|
||||
|
||||
public override string ToString() => BeatmapInfo.ToString();
|
||||
|
||||
public abstract Stream GetStream(string storagePath);
|
||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
}
|
||||
|
||||
working.Value.Metadata.AudioFile = destination.Name;
|
||||
working.Value.InvalidateWaveform();
|
||||
working.Value.LoadWaveform();
|
||||
editorBeatmap.SaveState();
|
||||
music.ReloadCurrentTrack();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user