mirror of
https://github.com/ppy/osu.git
synced 2025-03-01 00:12:56 +08:00
Return existing download if it exists.
This commit is contained in:
parent
5f5dd54f9d
commit
e67606e203
@ -191,11 +191,14 @@ namespace osu.Game.Beatmaps
|
|||||||
/// Downloads a beatmap.
|
/// Downloads a beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to be downloaded.</param>
|
/// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to be downloaded.</param>
|
||||||
/// <returns>The new <see cref="DownloadBeatmapSetRequest"/>, or null if a download already exists for the same beatmap.</returns>
|
/// <returns>A new <see cref="DownloadBeatmapSetRequest"/>, or an existing one if a download is already in progress.</returns>
|
||||||
public DownloadBeatmapSetRequest Download(BeatmapSetInfo beatmapSetInfo)
|
public DownloadBeatmapSetRequest Download(BeatmapSetInfo beatmapSetInfo)
|
||||||
{
|
{
|
||||||
if (api == null || downloadsList.Find(d => d.BeatmapSet.OnlineBeatmapSetID == beatmapSetInfo.OnlineBeatmapSetID) != null)
|
var existing = downloadsList.Find(d => d.BeatmapSet.OnlineBeatmapSetID == beatmapSetInfo.OnlineBeatmapSetID);
|
||||||
return null;
|
|
||||||
|
if (existing != null) return existing;
|
||||||
|
|
||||||
|
if (api == null) return null;
|
||||||
|
|
||||||
ProgressNotification downloadNotification = new ProgressNotification
|
ProgressNotification downloadNotification = new ProgressNotification
|
||||||
{
|
{
|
||||||
|
@ -160,13 +160,17 @@ namespace osu.Game.Overlays.Direct
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we already have an active download running.
|
// we already have an active download running.
|
||||||
if ((DownloadRequest = beatmaps.Download(SetInfo)) == null)
|
if (beatmaps.GetExistingDownload(SetInfo) != null)
|
||||||
{
|
{
|
||||||
content.MoveToX(-5, 50, Easing.OutSine).Then()
|
content.MoveToX(-5, 50, Easing.OutSine).Then()
|
||||||
.MoveToX(5, 100, Easing.InOutSine).Then()
|
.MoveToX(5, 100, Easing.InOutSine).Then()
|
||||||
.MoveToX(-5, 100, Easing.InOutSine).Then()
|
.MoveToX(-5, 100, Easing.InOutSine).Then()
|
||||||
.MoveToX(0, 50, Easing.InSine).Then();
|
.MoveToX(0, 50, Easing.InSine).Then();
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DownloadRequest = beatmaps.Download(SetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -176,7 +176,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
// if a new map was imported, we should remove it from search results (download completed etc.)
|
// if a new map was imported, we should remove it from search results (download completed etc.)
|
||||||
panels?.FirstOrDefault(p => p.SetInfo.OnlineBeatmapSetID == set.OnlineBeatmapSetID)?.FadeOut(400).Expire();
|
panels?.FirstOrDefault(p => p.SetInfo.OnlineBeatmapSetID == set.OnlineBeatmapSetID)?.FadeOut(400).Expire();
|
||||||
BeatmapSets = BeatmapSets.Where(b => b.OnlineBeatmapSetID != set.OnlineBeatmapSetID);
|
BeatmapSets = BeatmapSets?.Where(b => b.OnlineBeatmapSetID != set.OnlineBeatmapSetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateResultCounts()
|
private void updateResultCounts()
|
||||||
|
Loading…
Reference in New Issue
Block a user