mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 15:03:10 +08:00
Merge branch 'master' into fix-playback-control
This commit is contained in:
commit
95275cd2ef
@ -8,6 +8,7 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
@ -29,10 +30,10 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
Mods.ValueChanged += mods => applyRateAdjustments();
|
Mods.ValueChanged += mods => applyRateAdjustments();
|
||||||
|
|
||||||
beatmap = new Lazy<Beatmap>(populateBeatmap);
|
beatmap = new AsyncLazy<Beatmap>(populateBeatmap);
|
||||||
background = new Lazy<Texture>(populateBackground);
|
background = new AsyncLazy<Texture>(populateBackground);
|
||||||
track = new Lazy<Track>(populateTrack);
|
track = new AsyncLazy<Track>(populateTrack);
|
||||||
waveform = new Lazy<Waveform>(populateWaveform);
|
waveform = new AsyncLazy<Waveform>(populateWaveform);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Beatmap GetBeatmap();
|
protected abstract Beatmap GetBeatmap();
|
||||||
@ -41,8 +42,10 @@ namespace osu.Game.Beatmaps
|
|||||||
protected virtual Waveform GetWaveform() => new Waveform();
|
protected virtual Waveform GetWaveform() => new Waveform();
|
||||||
|
|
||||||
public bool BeatmapLoaded => beatmap.IsValueCreated;
|
public bool BeatmapLoaded => beatmap.IsValueCreated;
|
||||||
public Beatmap Beatmap => beatmap.Value;
|
public Beatmap Beatmap => beatmap.Value.Result;
|
||||||
private readonly Lazy<Beatmap> beatmap;
|
public async Task<Beatmap> GetBeatmapAsync() => await beatmap.Value;
|
||||||
|
|
||||||
|
private readonly AsyncLazy<Beatmap> beatmap;
|
||||||
|
|
||||||
private Beatmap populateBeatmap()
|
private Beatmap populateBeatmap()
|
||||||
{
|
{
|
||||||
@ -55,14 +58,16 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool BackgroundLoaded => background.IsValueCreated;
|
public bool BackgroundLoaded => background.IsValueCreated;
|
||||||
public Texture Background => background.Value;
|
public Texture Background => background.Value.Result;
|
||||||
private Lazy<Texture> background;
|
public async Task<Texture> GetBackgroundAsync() => await background.Value;
|
||||||
|
private AsyncLazy<Texture> background;
|
||||||
|
|
||||||
private Texture populateBackground() => GetBackground();
|
private Texture populateBackground() => GetBackground();
|
||||||
|
|
||||||
public bool TrackLoaded => track.IsValueCreated;
|
public bool TrackLoaded => track.IsValueCreated;
|
||||||
public Track Track => track.Value;
|
public Track Track => track.Value.Result;
|
||||||
private Lazy<Track> track;
|
public async Task<Track> GetTrackAsync() => await track.Value;
|
||||||
|
private AsyncLazy<Track> track;
|
||||||
|
|
||||||
private Track populateTrack()
|
private Track populateTrack()
|
||||||
{
|
{
|
||||||
@ -73,8 +78,9 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool WaveformLoaded => waveform.IsValueCreated;
|
public bool WaveformLoaded => waveform.IsValueCreated;
|
||||||
public Waveform Waveform => waveform.Value;
|
public Waveform Waveform => waveform.Value.Result;
|
||||||
private readonly Lazy<Waveform> waveform;
|
public async Task<Waveform> GetWaveformAsync() => await waveform.Value;
|
||||||
|
private readonly AsyncLazy<Waveform> waveform;
|
||||||
|
|
||||||
private Waveform populateWaveform() => GetWaveform();
|
private Waveform populateWaveform() => GetWaveform();
|
||||||
|
|
||||||
@ -107,5 +113,13 @@ namespace osu.Game.Beatmaps
|
|||||||
foreach (var mod in Mods.Value.OfType<IApplicableToClock>())
|
foreach (var mod in Mods.Value.OfType<IApplicableToClock>())
|
||||||
mod.ApplyToClock(t);
|
mod.ApplyToClock(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AsyncLazy<T> : Lazy<Task<T>>
|
||||||
|
{
|
||||||
|
public AsyncLazy(Func<T> valueFactory)
|
||||||
|
: base(() => Task.Run(valueFactory))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user