Show realm migration progress at Loader

This commit is contained in:
Dean Herbert
2022-01-21 14:56:49 +09:00
parent 5be41a189b
commit 5622d2ba4f
2 changed files with 125 additions and 37 deletions

View File

@ -12,6 +12,7 @@ using osu.Game.Screens.Menu;
using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
using IntroSequence = osu.Game.Configuration.IntroSequence;
@ -63,6 +64,11 @@ namespace osu.Game.Screens
protected virtual ShaderPrecompiler CreateShaderPrecompiler() => new ShaderPrecompiler();
[Resolved(canBeNull: true)]
private DatabaseContextFactory efContextFactory { get; set; }
private EFToRealmMigrator realmMigrator;
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
@ -70,6 +76,10 @@ namespace osu.Game.Screens
LoadComponentAsync(precompiler = CreateShaderPrecompiler(), AddInternal);
LoadComponentAsync(loadableScreen = CreateLoadableScreen());
// A non-null context factory means there's still content to migrate.
if (efContextFactory != null)
LoadComponentAsync(realmMigrator = new EFToRealmMigrator(), AddInternal);
LoadComponentAsync(spinner = new LoadingSpinner(true, true)
{
Anchor = Anchor.BottomRight,
@ -86,7 +96,7 @@ namespace osu.Game.Screens
private void checkIfLoaded()
{
if (loadableScreen.LoadState != LoadState.Ready || !precompiler.FinishedCompiling)
if (loadableScreen.LoadState != LoadState.Ready || !precompiler.FinishedCompiling || realmMigrator?.FinishedMigrating == false)
{
Schedule(checkIfLoaded);
return;