Skip to content

Commit

Permalink
Add loading spinner when loading first run screens
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed May 10, 2022
1 parent 25c6226 commit a93c63b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion osu.Game/Overlays/FirstRunSetupOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
Expand Down Expand Up @@ -68,6 +69,9 @@ public class FirstRunSetupOverlay : ShearedOverlayContainer

private Container content = null!;

private LoadingSpinner loading = null!;
private ScheduledDelegate? loadingShowDelegate;

public FirstRunSetupOverlay()
: base(OverlayColourScheme.Purple)
{
Expand Down Expand Up @@ -115,6 +119,7 @@ private void load(OsuColour colours)
RelativeSizeAxes = Axes.Both,
Colour = ColourProvider.Background6,
},
loading = new LoadingSpinner(),
new Container
{
RelativeSizeAxes = Axes.Both,
Expand Down Expand Up @@ -310,7 +315,16 @@ private void showNextStep()

if (currentStepIndex < steps.Length)
{
stack.Push((Screen)Activator.CreateInstance(steps[currentStepIndex.Value]));
var nextScreen = (Screen)Activator.CreateInstance(steps[currentStepIndex.Value]);

loadingShowDelegate = Scheduler.AddDelayed(() => loading.Show(), 200);
nextScreen.OnLoadComplete += _ =>
{
loadingShowDelegate?.Cancel();
loading.Hide();
};

stack.Push(nextScreen);
}
else
{
Expand Down

0 comments on commit a93c63b

Please sign in to comment.