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:
commit
d210383d8f
@ -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)
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user