1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

Use existing blocking / exit logic provided by OsuFocusedOverlayContainer

This commit is contained in:
Dean Herbert 2022-04-18 19:36:12 +09:00
parent 9074eb283d
commit 2682373bf2

View File

@ -11,15 +11,15 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.FirstRunSetup; using osu.Game.Overlays.FirstRunSetup;
using osu.Game.Overlays.Notifications;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.OnlinePlay.Match.Components; using osu.Game.Screens.OnlinePlay.Match.Components;
@ -33,17 +33,16 @@ namespace osu.Game.Overlays
{ {
protected override bool StartHidden => true; protected override bool StartHidden => true;
[Resolved]
private IDialogOverlay dialogOverlay { get; set; } = null!;
[Resolved] [Resolved]
private IPerformFromScreenRunner performer { get; set; } = null!; private IPerformFromScreenRunner performer { get; set; } = null!;
[Resolved(canBeNull: true)]
private NotificationOverlay notificationOverlay { get; set; } = null!;
private ScreenStack stack = null!; private ScreenStack stack = null!;
public PurpleTriangleButton NextButton = null!; public PurpleTriangleButton NextButton = null!;
public DangerousTriangleButton BackButton = null!; public DangerousTriangleButton BackButton = null!;
private Container mainContent = null!;
[Cached] [Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
@ -61,6 +60,8 @@ namespace osu.Game.Overlays
new FirstRunStep(typeof(ScreenUIScale), "UI Scale"), new FirstRunStep(typeof(ScreenUIScale), "UI Scale"),
}; };
private Container stackContainer = null!;
public FirstRunSetupOverlay() public FirstRunSetupOverlay()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -69,151 +70,140 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
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;
Children = new Drawable[] Children = new Drawable[]
{ {
mainContent = new BlockingContainer new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Colour = colourProvider.Background6,
Origin = Anchor.Centre, },
Size = new Vector2(0.95f), new GridContainer
EdgeEffect = new EdgeEffectParameters {
RelativeSizeAxes = Axes.Both,
RowDimensions = new[]
{ {
Type = EdgeEffectType.Shadow, new Dimension(GridSizeMode.AutoSize),
Radius = 5, new Dimension(),
Colour = Color4.Black.Opacity(0.2f), new Dimension(GridSizeMode.AutoSize),
}, },
Masking = true, Content = new[]
CornerRadius = 10,
Children = new Drawable[]
{ {
new Box new Drawable[]
{ {
RelativeSizeAxes = Axes.Both, new Container
Colour = colourProvider.Background6,
},
new GridContainer
{
RelativeSizeAxes = Axes.Both,
RowDimensions = new[]
{ {
new Dimension(GridSizeMode.AutoSize), RelativeSizeAxes = Axes.X,
new Dimension(), AutoSizeAxes = Axes.Y,
new Dimension(GridSizeMode.AutoSize), Children = new Drawable[]
},
Content = new[]
{
new Drawable[]
{ {
new Container new Box
{
Colour = colourProvider.Background5,
RelativeSizeAxes = Axes.Both,
},
new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Margin = new MarginPadding(10),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new OsuSpriteText
{ {
Colour = colourProvider.Background5, Text = "First run setup",
RelativeSizeAxes = Axes.Both, Font = OsuFont.Default.With(size: 32),
Colour = colourProvider.Content2,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}, },
new FillFlowContainer new OsuTextFlowContainer
{ {
RelativeSizeAxes = Axes.X, Text = "Setup osu! to suit you",
Margin = new MarginPadding(10), Colour = colourProvider.Content1,
AutoSizeAxes = Axes.Y, Anchor = Anchor.TopCentre,
Direction = FillDirection.Vertical, Origin = Anchor.TopCentre,
Children = new Drawable[] AutoSizeAxes = Axes.Both,
{
new OsuSpriteText
{
Text = "First run setup",
Font = OsuFont.Default.With(size: 32),
Colour = colourProvider.Content2,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
new OsuTextFlowContainer
{
Text = "Setup osu! to suit you",
Colour = colourProvider.Content1,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
},
}
}, },
} }
}, },
}, }
new Drawable[] },
},
new Drawable[]
{
stackContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(20),
},
},
new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(20),
Child = new GridContainer
{ {
new Container RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{ {
RelativeSizeAxes = Axes.Both, new Dimension(GridSizeMode.AutoSize),
Padding = new MarginPadding(20), new Dimension(GridSizeMode.Absolute, 10),
Child = stack = new ScreenStack new Dimension(),
{
RelativeSizeAxes = Axes.Both,
},
}, },
}, RowDimensions = new[]
new Drawable[]
{
new Container
{ {
RelativeSizeAxes = Axes.X, new Dimension(GridSizeMode.AutoSize),
AutoSizeAxes = Axes.Y, },
Padding = new MarginPadding(20), Content = new[]
Child = new GridContainer {
new[]
{ {
RelativeSizeAxes = Axes.X, BackButton = new DangerousTriangleButton
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{ {
new Dimension(GridSizeMode.AutoSize), Width = 200,
new Dimension(GridSizeMode.Absolute, 10), Text = "Back",
new Dimension(), Action = showLastStep,
Enabled = { Value = false },
}, },
RowDimensions = new[] Empty(),
NextButton = new PurpleTriangleButton
{ {
new Dimension(GridSizeMode.AutoSize), RelativeSizeAxes = Axes.X,
}, Width = 1,
Content = new[] Text = "Get started",
{ Action = showNextStep
new[]
{
BackButton = new DangerousTriangleButton
{
Width = 200,
Text = "Back",
Action = showLastStep,
Enabled = { Value = false },
},
Empty(),
NextButton = new PurpleTriangleButton
{
RelativeSizeAxes = Axes.X,
Width = 1,
Text = "Get started",
Action = showNextStep
}
},
} }
}, },
} }
} },
} }
}, }
} }
} },
}; };
} }
private class BlockingContainer : Container
{
protected override bool OnMouseDown(MouseDownEvent e) => true;
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
@ -246,7 +236,14 @@ namespace osu.Game.Overlays
private void showNextStep() private void showNextStep()
{ {
if (currentStepIndex == null) if (currentStepIndex == null)
{
stackContainer.Child = stack = new ScreenStack
{
RelativeSizeAxes = Axes.Both,
};
currentStepIndex = 0; currentStepIndex = 0;
}
else else
currentStepIndex++; currentStepIndex++;
@ -260,8 +257,11 @@ namespace osu.Game.Overlays
} }
else else
{ {
Hide(); stack.FadeOut(500);
stack.Expire();
currentStepIndex = null; currentStepIndex = null;
Hide();
} }
} }