Fix tutorial download state not matching correctly when already available locally

Closes https://github.com/ppy/osu/issues/18468.

This doesn't stop the tutorial from downloading a second time, but at
least displays the correct status afterwards. Avoiding the download is a
bit more involved and requires a change to the flow. Probably not worth
it just yet.

To test, recommend switching to production environment, as dev server
doesn't have correct metadata for tutorial resulting in weirdness.
This commit is contained in:
Dean Herbert 2022-06-02 16:34:23 +09:00
parent 5adbf85654
commit 5bd9d88219
2 changed files with 8 additions and 3 deletions

View File

@ -85,6 +85,8 @@ private void load()
downloadTrackers.Add(beatmapDownloadTracker);
AddInternal(beatmapDownloadTracker);
// Note that this is downloading the beatmaps even if they are already downloaded.
// We could rely more on `BeatmapDownloadTracker`'s exposed state to avoid this.
beatmapDownloader.Download(beatmapSet);
}
}

View File

@ -154,12 +154,15 @@ private void downloadTutorial()
var downloadTracker = tutorialDownloader.DownloadTrackers.First();
downloadTracker.State.BindValueChanged(state =>
{
if (state.NewValue == DownloadState.LocallyAvailable)
downloadTutorialButton.Complete();
}, true);
downloadTracker.Progress.BindValueChanged(progress =>
{
downloadTutorialButton.SetProgress(progress.NewValue, false);
if (progress.NewValue == 1)
downloadTutorialButton.Complete();
}, true);
}