2022-04-06 16:42:10 +08: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 15:07:30 +08:00
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
2022-04-06 16:42:10 +08:00
|
|
|
using osu.Framework.Allocation;
|
2022-04-19 15:59:25 +08:00
|
|
|
using osu.Framework.Bindables;
|
2022-04-06 16:42:10 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Effects;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-04-18 18:36:12 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-04-19 13:46:01 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2022-04-18 15:07:30 +08:00
|
|
|
using osu.Framework.Localisation;
|
2022-04-06 16:42:10 +08:00
|
|
|
using osu.Framework.Screens;
|
2022-04-19 15:59:25 +08:00
|
|
|
using osu.Game.Configuration;
|
2022-04-06 16:42:10 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
2022-04-18 14:20:54 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-04-18 15:07:30 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-04-19 13:46:01 +08:00
|
|
|
using osu.Game.Input.Bindings;
|
2022-04-19 12:52:55 +08:00
|
|
|
using osu.Game.Localisation;
|
2022-04-06 16:42:10 +08:00
|
|
|
using osu.Game.Overlays.FirstRunSetup;
|
2022-04-18 18:36:12 +08:00
|
|
|
using osu.Game.Overlays.Notifications;
|
2022-04-18 17:58:14 +08:00
|
|
|
using osu.Game.Screens;
|
2022-04-06 16:42:10 +08:00
|
|
|
using osu.Game.Screens.Menu;
|
2022-04-18 15:07:30 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
2022-04-06 16:42:10 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
public class FirstRunSetupOverlay : OsuFocusedOverlayContainer
|
|
|
|
{
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
2022-04-18 17:58:14 +08:00
|
|
|
[Resolved]
|
|
|
|
private IPerformFromScreenRunner performer { get; set; } = null!;
|
2022-04-18 15:07:30 +08:00
|
|
|
|
2022-04-18 18:47:47 +08:00
|
|
|
[Resolved]
|
|
|
|
private INotificationOverlay notificationOverlay { get; set; } = null!;
|
2022-04-18 18:36:12 +08:00
|
|
|
|
2022-04-19 15:59:25 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuConfigManager config { get; set; } = null!;
|
|
|
|
|
2022-04-19 12:48:43 +08:00
|
|
|
private ScreenStack? stack;
|
2022-04-18 15:07:30 +08:00
|
|
|
|
2022-04-18 15:34:13 +08:00
|
|
|
public PurpleTriangleButton NextButton = null!;
|
|
|
|
public DangerousTriangleButton BackButton = null!;
|
2022-04-06 16:42:10 +08:00
|
|
|
|
2022-04-18 14:20:54 +08:00
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
2022-04-06 16:42:10 +08:00
|
|
|
|
2022-04-19 15:59:25 +08:00
|
|
|
private readonly Bindable<bool> showFirstRunSetup = new Bindable<bool>();
|
|
|
|
|
2022-04-18 15:07:30 +08:00
|
|
|
private int? currentStepIndex;
|
|
|
|
|
2022-04-18 18:47:47 +08:00
|
|
|
private const float scale_when_hidden = 0.9f;
|
|
|
|
|
2022-04-18 15:34:13 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The currently displayed screen, if any.
|
|
|
|
/// </summary>
|
2022-04-19 12:48:43 +08:00
|
|
|
public FirstRunSetupScreen? CurrentScreen => (FirstRunSetupScreen?)stack?.CurrentScreen;
|
2022-04-18 15:34:13 +08:00
|
|
|
|
2022-04-18 15:07:30 +08:00
|
|
|
private readonly FirstRunStep[] steps =
|
|
|
|
{
|
2022-04-19 12:52:55 +08:00
|
|
|
new FirstRunStep(typeof(ScreenWelcome), FirstRunSetupOverlayStrings.Welcome),
|
|
|
|
new FirstRunStep(typeof(ScreenUIScale), GraphicsSettingsStrings.UIScaling),
|
2022-04-18 15:07:30 +08:00
|
|
|
};
|
2022-04-06 16:42:10 +08:00
|
|
|
|
2022-04-18 18:36:12 +08:00
|
|
|
private Container stackContainer = null!;
|
|
|
|
|
2022-04-19 16:40:35 +08:00
|
|
|
private Bindable<OverlayActivation>? overlayActivationMode;
|
|
|
|
|
2022-04-06 16:42:10 +08:00
|
|
|
public FirstRunSetupOverlay()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-04-18 18:06:13 +08:00
|
|
|
private void load()
|
2022-04-06 16:42:10 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Size = new Vector2(0.95f);
|
|
|
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Radius = 5,
|
|
|
|
Colour = Color4.Black.Opacity(0.2f),
|
|
|
|
};
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 10;
|
|
|
|
|
2022-04-06 16:42:10 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new Box
|
2022-04-06 16:42:10 +08:00
|
|
|
{
|
2022-04-06 17:11:32 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-04-18 18:36:12 +08:00
|
|
|
Colour = colourProvider.Background6,
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[]
|
2022-04-06 16:42:10 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2022-04-06 16:42:10 +08:00
|
|
|
},
|
2022-04-18 18:36:12 +08:00
|
|
|
Content = new[]
|
2022-04-06 16:42:10 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new Drawable[]
|
2022-04-06 16:42:10 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new Container
|
2022-04-18 14:20:54 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
2022-04-18 14:20:54 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = colourProvider.Background5,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
2022-04-18 14:20:54 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2022-04-18 18:36:12 +08:00
|
|
|
Margin = new MarginPadding(10),
|
2022-04-18 14:20:54 +08:00
|
|
|
AutoSizeAxes = Axes.Y,
|
2022-04-18 18:36:12 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
2022-04-18 14:20:54 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new OsuSpriteText
|
2022-04-18 14:20:54 +08:00
|
|
|
{
|
2022-04-19 12:52:55 +08:00
|
|
|
Text = FirstRunSetupOverlayStrings.FirstRunSetup,
|
2022-04-18 18:36:12 +08:00
|
|
|
Font = OsuFont.Default.With(size: 32),
|
2022-04-20 13:48:51 +08:00
|
|
|
Colour = colourProvider.Content1,
|
2022-04-18 18:36:12 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2022-04-18 14:20:54 +08:00
|
|
|
},
|
2022-04-18 18:36:12 +08:00
|
|
|
new OsuTextFlowContainer
|
2022-04-18 14:20:54 +08:00
|
|
|
{
|
2022-04-19 12:52:55 +08:00
|
|
|
Text = FirstRunSetupOverlayStrings.SetupOsuToSuitYou,
|
2022-04-20 13:48:51 +08:00
|
|
|
Colour = colourProvider.Content2,
|
2022-04-18 18:36:12 +08:00
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2022-04-18 14:20:54 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2022-04-18 18:36:12 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
stackContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding(20),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2022-04-19 15:53:41 +08:00
|
|
|
Padding = new MarginPadding(20)
|
|
|
|
{
|
|
|
|
Top = 0 // provided by the stack container above.
|
|
|
|
},
|
2022-04-18 18:36:12 +08:00
|
|
|
Child = new GridContainer
|
2022-04-18 14:20:54 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
ColumnDimensions = new[]
|
2022-04-18 14:20:54 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(GridSizeMode.Absolute, 10),
|
|
|
|
new Dimension(),
|
2022-04-18 14:20:54 +08:00
|
|
|
},
|
2022-04-18 18:36:12 +08:00
|
|
|
RowDimensions = new[]
|
2022-04-18 15:07:30 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new[]
|
2022-04-18 15:07:30 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
BackButton = new DangerousTriangleButton
|
2022-04-18 15:07:30 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
Width = 200,
|
2022-04-19 12:52:55 +08:00
|
|
|
Text = CommonStrings.Back,
|
2022-04-20 13:49:17 +08:00
|
|
|
Action = showPreviousStep,
|
2022-04-18 18:36:12 +08:00
|
|
|
Enabled = { Value = false },
|
2022-04-18 15:07:30 +08:00
|
|
|
},
|
2022-04-18 18:36:12 +08:00
|
|
|
Empty(),
|
|
|
|
NextButton = new PurpleTriangleButton
|
2022-04-18 15:07:30 +08:00
|
|
|
{
|
2022-04-18 18:36:12 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Width = 1,
|
2022-04-19 12:52:55 +08:00
|
|
|
Text = FirstRunSetupOverlayStrings.GetStarted,
|
2022-04-18 18:36:12 +08:00
|
|
|
Action = showNextStep
|
2022-04-18 15:07:30 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2022-04-18 18:36:12 +08:00
|
|
|
},
|
2022-04-18 14:20:54 +08:00
|
|
|
}
|
2022-04-18 18:36:12 +08:00
|
|
|
}
|
2022-04-06 16:42:10 +08:00
|
|
|
}
|
2022-04-18 18:36:12 +08:00
|
|
|
},
|
2022-04-06 16:42:10 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-04-19 15:59:25 +08:00
|
|
|
config.BindWith(OsuSetting.ShowFirstRunSetup, showFirstRunSetup);
|
|
|
|
|
2022-04-19 16:40:35 +08:00
|
|
|
if (showFirstRunSetup.Value) Show();
|
2022-04-06 16:42:10 +08:00
|
|
|
}
|
|
|
|
|
2022-04-19 13:46:01 +08:00
|
|
|
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
2022-04-18 15:07:30 +08:00
|
|
|
{
|
2022-04-19 13:46:01 +08:00
|
|
|
if (!e.Repeat)
|
2022-04-18 18:36:12 +08:00
|
|
|
{
|
2022-04-19 13:46:01 +08:00
|
|
|
switch (e.Action)
|
2022-04-18 18:36:12 +08:00
|
|
|
{
|
2022-04-19 13:46:01 +08:00
|
|
|
case GlobalAction.Select:
|
|
|
|
NextButton.TriggerClick();
|
|
|
|
return true;
|
2022-04-19 12:48:43 +08:00
|
|
|
|
2022-04-19 13:46:01 +08:00
|
|
|
case GlobalAction.Back:
|
|
|
|
if (BackButton.Enabled.Value)
|
|
|
|
{
|
|
|
|
BackButton.TriggerClick();
|
|
|
|
return true;
|
|
|
|
}
|
2022-04-18 15:07:30 +08:00
|
|
|
|
2022-04-19 13:46:01 +08: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 15:07:30 +08:00
|
|
|
}
|
2022-04-06 16:42:10 +08:00
|
|
|
|
2022-04-19 13:46:01 +08:00
|
|
|
return base.OnPressed(e);
|
2022-04-18 18:18:13 +08:00
|
|
|
}
|
|
|
|
|
2022-04-19 16:40:35 +08:00
|
|
|
public override void Show()
|
|
|
|
{
|
|
|
|
// if we are valid for display, only do so after reaching the main menu.
|
|
|
|
performer.PerformFromScreen(screen =>
|
|
|
|
{
|
|
|
|
MainMenu menu = (MainMenu)screen;
|
|
|
|
|
|
|
|
// Eventually I'd like to replace this with a better method that doesn't access the screen.
|
|
|
|
// Either this dialog would be converted to its own screen, or at very least be "hosted" by a screen pushed to the main menu.
|
|
|
|
// Alternatively, another method of disabling notifications could be added to `INotificationOverlay`.
|
|
|
|
if (menu != null)
|
|
|
|
{
|
|
|
|
overlayActivationMode = menu.OverlayActivationMode.GetBoundCopy();
|
|
|
|
overlayActivationMode.Value = OverlayActivation.UserTriggered;
|
|
|
|
}
|
|
|
|
|
|
|
|
base.Show();
|
|
|
|
}, new[] { typeof(MainMenu) });
|
|
|
|
}
|
|
|
|
|
2022-04-18 18:47:47 +08:00
|
|
|
protected override void PopIn()
|
|
|
|
{
|
|
|
|
base.PopIn();
|
|
|
|
|
|
|
|
this.ScaleTo(scale_when_hidden)
|
|
|
|
.ScaleTo(1, 400, Easing.OutElasticHalf);
|
|
|
|
|
|
|
|
this.FadeIn(400, Easing.OutQuint);
|
|
|
|
|
|
|
|
if (currentStepIndex == null)
|
2022-04-19 13:46:01 +08:00
|
|
|
showFirstStep();
|
2022-04-18 18:47:47 +08:00
|
|
|
}
|
|
|
|
|
2022-04-06 16:42:10 +08:00
|
|
|
protected override void PopOut()
|
|
|
|
{
|
2022-04-19 16:40:35 +08:00
|
|
|
if (overlayActivationMode != null)
|
|
|
|
{
|
|
|
|
// If this is non-null we are guaranteed to have come from the main menu.
|
|
|
|
overlayActivationMode.Value = OverlayActivation.All;
|
|
|
|
overlayActivationMode = null;
|
|
|
|
}
|
|
|
|
|
2022-04-18 18:35:51 +08:00
|
|
|
if (currentStepIndex != null)
|
|
|
|
{
|
2022-04-18 18:47:47 +08:00
|
|
|
notificationOverlay.Post(new SimpleNotification
|
2022-04-18 18:35:51 +08:00
|
|
|
{
|
2022-04-19 12:52:55 +08:00
|
|
|
Text = FirstRunSetupOverlayStrings.ClickToResumeFirstRunSetupAtAnyPoint,
|
2022-04-18 18:35:51 +08:00
|
|
|
Icon = FontAwesome.Solid.Horse,
|
|
|
|
Activated = () =>
|
|
|
|
{
|
|
|
|
Show();
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2022-04-18 18:47:47 +08:00
|
|
|
else
|
|
|
|
{
|
2022-04-19 12:48:43 +08:00
|
|
|
stack?.FadeOut(100)
|
|
|
|
.Expire();
|
2022-04-18 18:47:47 +08:00
|
|
|
}
|
2022-04-18 18:35:51 +08:00
|
|
|
|
2022-04-06 16:42:10 +08:00
|
|
|
base.PopOut();
|
2022-04-18 18:47:47 +08:00
|
|
|
|
|
|
|
this.ScaleTo(0.96f, 400, Easing.OutQuint);
|
|
|
|
this.FadeOut(200, Easing.OutQuint);
|
2022-04-06 16:42:10 +08:00
|
|
|
}
|
2022-04-18 15:07:30 +08:00
|
|
|
|
2022-04-19 13:46:01 +08:00
|
|
|
private void showFirstStep()
|
|
|
|
{
|
|
|
|
Debug.Assert(currentStepIndex == null);
|
|
|
|
|
|
|
|
stackContainer.Child = stack = new ScreenStack
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
};
|
|
|
|
|
|
|
|
currentStepIndex = -1;
|
|
|
|
showNextStep();
|
|
|
|
}
|
|
|
|
|
2022-04-20 13:49:17 +08:00
|
|
|
private void showPreviousStep()
|
2022-04-19 13:46:01 +08:00
|
|
|
{
|
|
|
|
if (currentStepIndex == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Debug.Assert(stack != null);
|
|
|
|
|
|
|
|
stack.CurrentScreen.Exit();
|
|
|
|
currentStepIndex--;
|
|
|
|
|
|
|
|
BackButton.Enabled.Value = currentStepIndex != 0;
|
|
|
|
|
|
|
|
updateButtonText();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showNextStep()
|
|
|
|
{
|
|
|
|
Debug.Assert(currentStepIndex != null);
|
|
|
|
Debug.Assert(stack != null);
|
|
|
|
|
|
|
|
currentStepIndex++;
|
|
|
|
|
|
|
|
BackButton.Enabled.Value = currentStepIndex > 0;
|
|
|
|
|
|
|
|
if (currentStepIndex < steps.Length)
|
|
|
|
{
|
|
|
|
stack.Push((Screen)Activator.CreateInstance(steps[currentStepIndex.Value].ScreenType));
|
|
|
|
updateButtonText();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-19 15:59:25 +08:00
|
|
|
showFirstRunSetup.Value = false;
|
2022-04-19 13:46:01 +08:00
|
|
|
currentStepIndex = null;
|
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateButtonText()
|
|
|
|
{
|
|
|
|
Debug.Assert(currentStepIndex != null);
|
|
|
|
|
|
|
|
NextButton.Text = currentStepIndex + 1 < steps.Length
|
|
|
|
? FirstRunSetupOverlayStrings.Next(steps[currentStepIndex.Value + 1].Description)
|
|
|
|
: CommonStrings.Finish;
|
|
|
|
}
|
|
|
|
|
2022-04-18 15:07:30 +08:00
|
|
|
private class FirstRunStep
|
|
|
|
{
|
|
|
|
public readonly Type ScreenType;
|
|
|
|
public readonly LocalisableString Description;
|
|
|
|
|
|
|
|
public FirstRunStep(Type screenType, LocalisableString description)
|
|
|
|
{
|
|
|
|
ScreenType = screenType;
|
|
|
|
Description = description;
|
|
|
|
}
|
|
|
|
}
|
2022-04-06 16:42:10 +08:00
|
|
|
}
|
|
|
|
}
|