mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Simplify WorkingBeatmap
in multiple ways
Just a clean-up pass.
This commit is contained in:
@ -32,11 +32,16 @@ namespace osu.Game.Beatmaps
|
|||||||
// TODO: remove once the fallback lookup is not required (and access via `working.BeatmapInfo.Metadata` directly).
|
// TODO: remove once the fallback lookup is not required (and access via `working.BeatmapInfo.Metadata` directly).
|
||||||
public BeatmapMetadata Metadata => BeatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
public BeatmapMetadata Metadata => BeatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
||||||
|
|
||||||
protected AudioManager AudioManager { get; }
|
private AudioManager audioManager { get; }
|
||||||
|
|
||||||
|
private CancellationTokenSource loadCancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
private readonly object beatmapFetchLock = new object();
|
||||||
|
|
||||||
protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager)
|
protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager)
|
||||||
{
|
{
|
||||||
AudioManager = audioManager;
|
this.audioManager = audioManager;
|
||||||
|
|
||||||
BeatmapInfo = beatmapInfo;
|
BeatmapInfo = beatmapInfo;
|
||||||
BeatmapSetInfo = beatmapInfo.BeatmapSet;
|
BeatmapSetInfo = beatmapInfo.BeatmapSet;
|
||||||
|
|
||||||
@ -46,7 +51,7 @@ namespace osu.Game.Beatmaps
|
|||||||
skin = new RecyclableLazy<ISkin>(GetSkin);
|
skin = new RecyclableLazy<ISkin>(GetSkin);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Track GetVirtualTrack(double emptyLength = 0)
|
protected Track GetVirtualTrack(double emptyLength = 0)
|
||||||
{
|
{
|
||||||
const double excess_length = 1000;
|
const double excess_length = 1000;
|
||||||
|
|
||||||
@ -69,7 +74,7 @@ namespace osu.Game.Beatmaps
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AudioManager.Tracks.GetVirtual(length);
|
return audioManager.Tracks.GetVirtual(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -170,24 +175,20 @@ namespace osu.Game.Beatmaps
|
|||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CancellationTokenSource loadCancellation = new CancellationTokenSource();
|
|
||||||
|
|
||||||
public void BeginAsyncLoad() => loadBeatmapAsync();
|
public void BeginAsyncLoad() => loadBeatmapAsync();
|
||||||
|
|
||||||
public void CancelAsyncLoad()
|
public void CancelAsyncLoad()
|
||||||
{
|
{
|
||||||
lock (beatmapFetchLock)
|
lock (beatmapFetchLock)
|
||||||
{
|
{
|
||||||
loadCancellation?.Cancel();
|
loadCancellationSource?.Cancel();
|
||||||
loadCancellation = new CancellationTokenSource();
|
loadCancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
if (beatmapLoadTask?.IsCompleted != true)
|
if (beatmapLoadTask?.IsCompleted != true)
|
||||||
beatmapLoadTask = null;
|
beatmapLoadTask = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly object beatmapFetchLock = new object();
|
|
||||||
|
|
||||||
private Task<IBeatmap> loadBeatmapAsync()
|
private Task<IBeatmap> loadBeatmapAsync()
|
||||||
{
|
{
|
||||||
lock (beatmapFetchLock)
|
lock (beatmapFetchLock)
|
||||||
@ -204,7 +205,7 @@ namespace osu.Game.Beatmaps
|
|||||||
b.BeatmapInfo = BeatmapInfo;
|
b.BeatmapInfo = BeatmapInfo;
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}, loadCancellation.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
}, loadCancellationSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user