1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 10:33:07 +08:00

Merge pull request #3615 from plankp/check-before-btn-change

Change DownloadState only when Download is possible
This commit is contained in:
Dean Herbert 2018-10-22 21:52:29 +09:00 committed by GitHub
commit d210383d8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -148,11 +148,12 @@ namespace osu.Game.Beatmaps
/// </summary> /// </summary>
/// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to be downloaded.</param> /// <param name="beatmapSetInfo">The <see cref="BeatmapSetInfo"/> to be downloaded.</param>
/// <param name="noVideo">Whether the beatmap should be downloaded without video. Defaults to false.</param> /// <param name="noVideo">Whether the beatmap should be downloaded without video. Defaults to false.</param>
public void Download(BeatmapSetInfo beatmapSetInfo, bool noVideo = false) /// <returns>Downloading can happen</returns>
public bool Download(BeatmapSetInfo beatmapSetInfo, bool noVideo = false)
{ {
var existing = GetExistingDownload(beatmapSetInfo); var existing = GetExistingDownload(beatmapSetInfo);
if (existing != null || api == null) return; if (existing != null || api == null) return false;
if (!api.LocalUser.Value.IsSupporter) if (!api.LocalUser.Value.IsSupporter)
{ {
@ -161,7 +162,7 @@ namespace osu.Game.Beatmaps
Icon = FontAwesome.fa_superpowers, Icon = FontAwesome.fa_superpowers,
Text = "You gotta be an osu!supporter to download for now 'yo" Text = "You gotta be an osu!supporter to download for now 'yo"
}); });
return; return false;
} }
var downloadNotification = new DownloadNotification var downloadNotification = new DownloadNotification
@ -227,6 +228,7 @@ namespace osu.Game.Beatmaps
// don't run in the main api queue as this is a long-running task. // don't run in the main api queue as this is a long-running task.
Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning); Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning);
BeatmapDownloadBegan?.Invoke(request); BeatmapDownloadBegan?.Invoke(request);
return true;
} }
protected override void PresentCompletedImport(IEnumerable<BeatmapSetInfo> imported) protected override void PresentCompletedImport(IEnumerable<BeatmapSetInfo> imported)

View File

@ -71,9 +71,11 @@ namespace osu.Game.Beatmaps.Drawables
if (DownloadState.Value > DownloadStatus.NotDownloaded) if (DownloadState.Value > DownloadStatus.NotDownloaded)
return; return;
beatmaps.Download(set, noVideo); if (beatmaps.Download(set, noVideo))
{
DownloadState.Value = DownloadStatus.Downloading; // Only change state if download can happen
DownloadState.Value = DownloadStatus.Downloading;
}
} }
private void setAdded(BeatmapSetInfo s) private void setAdded(BeatmapSetInfo s)