2022-04-06 08:42:10 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-04-18 07:07:30 +00:00
|
|
|
using System;
|
2022-05-16 10:21:26 +00:00
|
|
|
using System.Collections.Generic;
|
2022-04-18 07:07:30 +00:00
|
|
|
using System.Diagnostics;
|
2022-04-06 08:42:10 +00:00
|
|
|
using osu.Framework.Allocation;
|
2022-04-19 07:59:25 +00:00
|
|
|
using osu.Framework.Bindables;
|
2022-04-26 07:22:41 +00:00
|
|
|
using osu.Framework.Extensions;
|
2022-04-06 08:42:10 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-05-17 07:33:02 +00:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
2022-04-06 08:42:10 +00:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-04-18 10:36:12 +00:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-04-19 05:46:01 +00:00
|
|
|
using osu.Framework.Input.Events;
|
2022-04-18 07:07:30 +00:00
|
|
|
using osu.Framework.Localisation;
|
2022-04-06 08:42:10 +00:00
|
|
|
using osu.Framework.Screens;
|
2022-05-10 09:04:10 +00:00
|
|
|
using osu.Framework.Threading;
|
2022-04-19 07:59:25 +00:00
|
|
|
using osu.Game.Configuration;
|
2022-05-16 10:21:26 +00:00
|
|
|
using osu.Game.Database;
|
2022-04-06 08:42:10 +00:00
|
|
|
using osu.Game.Graphics;
|
2022-04-18 07:07:30 +00:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-04-19 05:46:01 +00:00
|
|
|
using osu.Game.Input.Bindings;
|
2022-04-19 04:52:55 +00:00
|
|
|
using osu.Game.Localisation;
|
2022-04-06 08:42:10 +00:00
|
|
|
using osu.Game.Overlays.FirstRunSetup;
|
2022-04-20 07:51:26 +00:00
|
|
|
using osu.Game.Overlays.Mods;
|
2022-04-18 10:36:12 +00:00
|
|
|
using osu.Game.Overlays.Notifications;
|
2022-04-18 09:58:14 +00:00
|
|
|
using osu.Game.Screens;
|
2022-04-06 08:42:10 +00:00
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
{
|
|
|
|
[Cached]
|
2022-04-20 07:51:26 +00:00
|
|
|
public partial class FirstRunSetupOverlay : ShearedOverlayContainer
|
2022-04-06 08:42:10 +00:00
|
|
|
{
|
2022-04-18 09:58:14 +00:00
|
|
|
[Resolved]
|
|
|
|
private IPerformFromScreenRunner performer { get; set; } = null!;
|
2022-04-18 07:07:30 +00:00
|
|
|
|
2022-04-18 10:47:47 +00:00
|
|
|
[Resolved]
|
|
|
|
private INotificationOverlay notificationOverlay { get; set; } = null!;
|
2022-04-18 10:36:12 +00:00
|
|
|
|
2022-04-19 07:59:25 +00:00
|
|
|
[Resolved]
|
|
|
|
private OsuConfigManager config { get; set; } = null!;
|
|
|
|
|
2022-04-19 04:48:43 +00:00
|
|
|
private ScreenStack? stack;
|
2022-04-18 07:07:30 +00:00
|
|
|
|
2022-04-29 14:45:17 +00:00
|
|
|
public ShearedButton NextButton = null!;
|
|
|
|
public ShearedButton BackButton = null!;
|
2022-04-06 08:42:10 +00:00
|
|
|
|
2022-04-19 07:59:25 +00:00
|
|
|
private readonly Bindable<bool> showFirstRunSetup = new Bindable<bool>();
|
|
|
|
|
2022-04-18 07:07:30 +00:00
|
|
|
private int? currentStepIndex;
|
|
|
|
|
2022-04-18 07:34:13 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The currently displayed screen, if any.
|
|
|
|
/// </summary>
|
2022-04-19 04:48:43 +00:00
|
|
|
public FirstRunSetupScreen? CurrentScreen => (FirstRunSetupScreen?)stack?.CurrentScreen;
|
2022-04-18 07:34:13 +00:00
|
|
|
|
2022-05-16 10:21:26 +00:00
|
|
|
private readonly List<Type> steps = new List<Type>();
|
2022-04-06 08:42:10 +00:00
|
|
|
|
2022-05-10 08:01:36 +00:00
|
|
|
private Container screenContent = null!;
|
2022-04-18 10:36:12 +00:00
|
|
|
|
2022-04-20 07:51:26 +00:00
|
|
|
private Container content = null!;
|
2022-04-06 08:42:10 +00:00
|
|
|
|
2022-05-10 09:04:10 +00:00
|
|
|
private LoadingSpinner loading = null!;
|
|
|
|
private ScheduledDelegate? loadingShowDelegate;
|
|
|
|
|
2022-05-04 20:17:40 +00:00
|
|
|
public FirstRunSetupOverlay()
|
|
|
|
: base(OverlayColourScheme.Purple)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-05-16 10:21:26 +00:00
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
|
|
|
private void load(OsuColour colours, LegacyImportManager? legacyImportManager)
|
2022-04-06 08:42:10 +00:00
|
|
|
{
|
2022-05-16 10:21:26 +00:00
|
|
|
steps.Add(typeof(ScreenWelcome));
|
2022-05-25 03:17:11 +00:00
|
|
|
steps.Add(typeof(ScreenUIScale));
|
2022-05-16 10:21:26 +00:00
|
|
|
steps.Add(typeof(ScreenBeatmaps));
|
|
|
|
if (legacyImportManager?.SupportsImportFromStable == true)
|
|
|
|
steps.Add(typeof(ScreenImportFromStable));
|
|
|
|
steps.Add(typeof(ScreenBehaviour));
|
|
|
|
|
2022-04-22 22:31:36 +00:00
|
|
|
Header.Title = FirstRunSetupOverlayStrings.FirstRunSetupTitle;
|
|
|
|
Header.Description = FirstRunSetupOverlayStrings.FirstRunSetupDescription;
|
2022-04-18 10:36:12 +00:00
|
|
|
|
2022-04-20 07:51:26 +00:00
|
|
|
MainAreaContent.AddRange(new Drawable[]
|
2022-04-18 10:36:12 +00:00
|
|
|
{
|
2022-05-17 07:33:02 +00:00
|
|
|
content = new PopoverContainer
|
2022-04-18 10:36:12 +00:00
|
|
|
{
|
2022-04-20 07:51:26 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-04-18 10:36:12 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-05-10 08:01:36 +00:00
|
|
|
Padding = new MarginPadding { Bottom = 20, },
|
2022-05-10 10:56:21 +00:00
|
|
|
Child = new GridContainer
|
2022-04-29 14:45:17 +00:00
|
|
|
{
|
2022-05-10 08:01:36 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-04-20 07:51:26 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-05-10 08:01:36 +00:00
|
|
|
ColumnDimensions = new[]
|
2022-04-06 08:42:10 +00:00
|
|
|
{
|
2022-05-10 08:01:36 +00:00
|
|
|
new Dimension(),
|
|
|
|
new Dimension(minSize: 640, maxSize: 800),
|
|
|
|
new Dimension(),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new[]
|
2022-04-18 10:36:12 +00:00
|
|
|
{
|
2022-05-10 08:01:36 +00:00
|
|
|
Empty(),
|
|
|
|
new InputBlockingContainer
|
2022-04-19 07:53:41 +00:00
|
|
|
{
|
2022-05-10 08:01:36 +00:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 14,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourProvider.Background6,
|
|
|
|
},
|
2022-05-10 09:04:10 +00:00
|
|
|
loading = new LoadingSpinner(),
|
2022-05-10 08:01:36 +00:00
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-05-10 08:23:12 +00:00
|
|
|
Padding = new MarginPadding { Vertical = 20 },
|
2022-05-10 08:01:36 +00:00
|
|
|
Child = screenContent = new Container { RelativeSizeAxes = Axes.Both, },
|
|
|
|
},
|
|
|
|
},
|
2022-04-18 10:36:12 +00:00
|
|
|
},
|
2022-05-10 08:01:36 +00:00
|
|
|
Empty(),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2022-04-18 10:36:12 +00:00
|
|
|
},
|
2022-04-20 07:51:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
FooterContent.Add(new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2022-04-29 14:45:17 +00:00
|
|
|
Margin = new MarginPadding { Vertical = PADDING },
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2022-04-20 07:51:26 +00:00
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.Absolute, 10),
|
2022-04-29 14:45:17 +00:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2022-04-20 07:51:26 +00:00
|
|
|
new Dimension(),
|
2022-04-29 14:45:17 +00:00
|
|
|
new Dimension(GridSizeMode.Absolute, 10),
|
2022-04-20 07:51:26 +00:00
|
|
|
},
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new[]
|
|
|
|
{
|
2022-04-29 14:45:17 +00:00
|
|
|
Empty(),
|
|
|
|
BackButton = new ShearedButton(300)
|
2022-04-20 07:51:26 +00:00
|
|
|
{
|
|
|
|
Text = CommonStrings.Back,
|
|
|
|
Action = showPreviousStep,
|
|
|
|
Enabled = { Value = false },
|
2022-04-29 14:45:17 +00:00
|
|
|
DarkerColour = colours.Pink2,
|
|
|
|
LighterColour = colours.Pink1,
|
2022-04-20 07:51:26 +00:00
|
|
|
},
|
2022-04-29 14:45:17 +00:00
|
|
|
NextButton = new ShearedButton(0)
|
2022-04-20 07:51:26 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Width = 1,
|
|
|
|
Text = FirstRunSetupOverlayStrings.GetStarted,
|
2022-04-29 14:45:17 +00:00
|
|
|
DarkerColour = ColourProvider.Colour2,
|
|
|
|
LighterColour = ColourProvider.Colour1,
|
2022-04-20 07:51:26 +00:00
|
|
|
Action = showNextStep
|
2022-04-29 14:45:17 +00:00
|
|
|
},
|
|
|
|
Empty(),
|
2022-04-20 07:51:26 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
2022-04-06 08:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-04-19 07:59:25 +00:00
|
|
|
config.BindWith(OsuSetting.ShowFirstRunSetup, showFirstRunSetup);
|
|
|
|
|
2022-05-10 07:43:38 +00:00
|
|
|
if (showFirstRunSetup.Value) Show();
|
2022-04-06 08:42:10 +00:00
|
|
|
}
|
|
|
|
|
2022-04-19 05:46:01 +00:00
|
|
|
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
2022-04-18 07:07:30 +00:00
|
|
|
{
|
2022-04-19 05:46:01 +00:00
|
|
|
if (!e.Repeat)
|
2022-04-18 10:36:12 +00:00
|
|
|
{
|
2022-04-19 05:46:01 +00:00
|
|
|
switch (e.Action)
|
2022-04-18 10:36:12 +00:00
|
|
|
{
|
2022-04-19 05:46:01 +00:00
|
|
|
case GlobalAction.Select:
|
|
|
|
NextButton.TriggerClick();
|
|
|
|
return true;
|
2022-04-19 04:48:43 +00:00
|
|
|
|
2022-04-19 05:46:01 +00:00
|
|
|
case GlobalAction.Back:
|
|
|
|
if (BackButton.Enabled.Value)
|
|
|
|
{
|
|
|
|
BackButton.TriggerClick();
|
|
|
|
return true;
|
|
|
|
}
|
2022-04-18 07:07:30 +00:00
|
|
|
|
2022-04-19 05:46:01 +00:00
|
|
|
// If back button is disabled, we are at the first step.
|
|
|
|
// The base call will handle dismissal of the overlay.
|
|
|
|
break;
|
|
|
|
}
|
2022-04-18 07:07:30 +00:00
|
|
|
}
|
2022-04-06 08:42:10 +00:00
|
|
|
|
2022-04-19 05:46:01 +00:00
|
|
|
return base.OnPressed(e);
|
2022-04-18 10:18:13 +00:00
|
|
|
}
|
|
|
|
|
2022-04-19 08:40:35 +00:00
|
|
|
public override void Show()
|
|
|
|
{
|
|
|
|
// if we are valid for display, only do so after reaching the main menu.
|
|
|
|
performer.PerformFromScreen(screen =>
|
|
|
|
{
|
2022-05-19 07:42:43 +00:00
|
|
|
// Hides the toolbar for us.
|
|
|
|
if (screen is MainMenu menu)
|
|
|
|
menu.ReturnToOsuLogo();
|
2022-04-19 08:40:35 +00:00
|
|
|
|
|
|
|
base.Show();
|
|
|
|
}, new[] { typeof(MainMenu) });
|
|
|
|
}
|
|
|
|
|
2022-04-18 10:47:47 +00:00
|
|
|
protected override void PopIn()
|
|
|
|
{
|
|
|
|
base.PopIn();
|
|
|
|
|
2022-04-20 07:51:26 +00:00
|
|
|
content.ScaleTo(0.99f)
|
|
|
|
.ScaleTo(1, 400, Easing.OutQuint);
|
2022-04-18 10:47:47 +00:00
|
|
|
|
|
|
|
if (currentStepIndex == null)
|
2022-04-19 05:46:01 +00:00
|
|
|
showFirstStep();
|
2022-04-18 10:47:47 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 08:42:10 +00:00
|
|
|
protected override void PopOut()
|
|
|
|
{
|
2022-04-20 07:51:26 +00:00
|
|
|
base.PopOut();
|
|
|
|
|
|
|
|
content.ScaleTo(0.99f, 400, Easing.OutQuint);
|
|
|
|
|
2022-04-18 10:35:51 +00:00
|
|
|
if (currentStepIndex != null)
|
|
|
|
{
|
2022-04-18 10:47:47 +00:00
|
|
|
notificationOverlay.Post(new SimpleNotification
|
2022-04-18 10:35:51 +00:00
|
|
|
{
|
2022-04-19 04:52:55 +00:00
|
|
|
Text = FirstRunSetupOverlayStrings.ClickToResumeFirstRunSetupAtAnyPoint,
|
2022-04-21 03:18:54 +00:00
|
|
|
Icon = FontAwesome.Solid.Redo,
|
2022-04-18 10:35:51 +00:00
|
|
|
Activated = () =>
|
|
|
|
{
|
|
|
|
Show();
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-04-18 10:47:47 +00:00
|
|
|
else
|
|
|
|
{
|
2022-04-19 04:48:43 +00:00
|
|
|
stack?.FadeOut(100)
|
|
|
|
.Expire();
|
2022-04-18 10:47:47 +00:00
|
|
|
}
|
2022-04-06 08:42:10 +00:00
|
|
|
}
|
2022-04-18 07:07:30 +00:00
|
|
|
|
2022-04-19 05:46:01 +00:00
|
|
|
private void showFirstStep()
|
|
|
|
{
|
|
|
|
Debug.Assert(currentStepIndex == null);
|
|
|
|
|
2022-05-10 08:01:36 +00:00
|
|
|
screenContent.Child = stack = new ScreenStack
|
2022-04-19 05:46:01 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
};
|
|
|
|
|
|
|
|
currentStepIndex = -1;
|
|
|
|
showNextStep();
|
|
|
|
}
|
|
|
|
|
2022-04-20 05:49:17 +00:00
|
|
|
private void showPreviousStep()
|
2022-04-19 05:46:01 +00:00
|
|
|
{
|
|
|
|
if (currentStepIndex == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Debug.Assert(stack != null);
|
|
|
|
|
|
|
|
stack.CurrentScreen.Exit();
|
|
|
|
currentStepIndex--;
|
|
|
|
|
2022-04-20 08:50:31 +00:00
|
|
|
updateButtons();
|
2022-04-19 05:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void showNextStep()
|
|
|
|
{
|
|
|
|
Debug.Assert(currentStepIndex != null);
|
|
|
|
Debug.Assert(stack != null);
|
|
|
|
|
|
|
|
currentStepIndex++;
|
|
|
|
|
2022-05-16 10:21:26 +00:00
|
|
|
if (currentStepIndex < steps.Count)
|
2022-04-19 05:46:01 +00:00
|
|
|
{
|
2022-12-16 09:16:26 +00:00
|
|
|
var nextScreen = (Screen)Activator.CreateInstance(steps[currentStepIndex.Value])!;
|
2022-05-10 09:04:10 +00:00
|
|
|
|
|
|
|
loadingShowDelegate = Scheduler.AddDelayed(() => loading.Show(), 200);
|
|
|
|
nextScreen.OnLoadComplete += _ =>
|
|
|
|
{
|
|
|
|
loadingShowDelegate?.Cancel();
|
|
|
|
loading.Hide();
|
|
|
|
};
|
|
|
|
|
|
|
|
stack.Push(nextScreen);
|
2022-04-19 05:46:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-10 07:43:38 +00:00
|
|
|
showFirstRunSetup.Value = false;
|
2022-04-19 05:46:01 +00:00
|
|
|
currentStepIndex = null;
|
|
|
|
Hide();
|
|
|
|
}
|
2022-04-20 08:50:31 +00:00
|
|
|
|
|
|
|
updateButtons();
|
2022-04-19 05:46:01 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 08:50:31 +00:00
|
|
|
private void updateButtons()
|
2022-04-19 05:46:01 +00:00
|
|
|
{
|
2022-04-20 08:50:31 +00:00
|
|
|
BackButton.Enabled.Value = currentStepIndex > 0;
|
|
|
|
NextButton.Enabled.Value = currentStepIndex != null;
|
2022-04-20 05:50:41 +00:00
|
|
|
|
2022-04-25 14:58:12 +00:00
|
|
|
if (currentStepIndex == null)
|
|
|
|
return;
|
|
|
|
|
2022-04-26 07:03:15 +00:00
|
|
|
bool isFirstStep = currentStepIndex == 0;
|
2022-05-16 10:21:26 +00:00
|
|
|
bool isLastStep = currentStepIndex == steps.Count - 1;
|
2022-04-26 07:03:15 +00:00
|
|
|
|
|
|
|
if (isFirstStep)
|
2022-04-20 08:50:31 +00:00
|
|
|
{
|
2022-04-26 07:03:15 +00:00
|
|
|
BackButton.Text = CommonStrings.Back;
|
2022-04-25 14:58:12 +00:00
|
|
|
NextButton.Text = FirstRunSetupOverlayStrings.GetStarted;
|
2022-04-26 07:03:15 +00:00
|
|
|
}
|
2022-04-25 14:58:12 +00:00
|
|
|
else
|
2022-04-26 07:03:15 +00:00
|
|
|
{
|
2022-04-28 10:00:12 +00:00
|
|
|
BackButton.Text = LocalisableString.Interpolate($@"{CommonStrings.Back} ({steps[currentStepIndex.Value - 1].GetLocalisableDescription()})");
|
2022-04-26 07:03:15 +00:00
|
|
|
|
|
|
|
NextButton.Text = isLastStep
|
|
|
|
? CommonStrings.Finish
|
2022-04-28 10:00:12 +00:00
|
|
|
: LocalisableString.Interpolate($@"{CommonStrings.Next} ({steps[currentStepIndex.Value + 1].GetLocalisableDescription()})");
|
2022-04-20 08:50:31 +00:00
|
|
|
}
|
2022-04-19 05:46:01 +00:00
|
|
|
}
|
2022-04-06 08:42:10 +00:00
|
|
|
}
|
|
|
|
}
|