1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Move back button to OsuGame

This commit is contained in:
smoogipoo 2019-06-25 16:55:49 +09:00
parent 1ea24756bd
commit 8c96e4c1fa
12 changed files with 52 additions and 56 deletions

View File

@ -29,6 +29,7 @@ using osu.Framework.Threading;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input; using osu.Game.Input;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
@ -82,6 +83,7 @@ namespace osu.Game
private OsuScreenStack screenStack; private OsuScreenStack screenStack;
private VolumeOverlay volume; private VolumeOverlay volume;
private OsuLogo osuLogo; private OsuLogo osuLogo;
private BackButton backButton;
private MainMenu menuScreen; private MainMenu menuScreen;
private Intro introScreen; private Intro introScreen;
@ -402,6 +404,13 @@ namespace osu.Game
logoContainer = new Container { RelativeSizeAxes = Axes.Both }, logoContainer = new Container { RelativeSizeAxes = Axes.Both },
} }
}, },
backButton = new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Alpha = 0,
Action = screenStack.Exit
},
overlayContent = new Container { RelativeSizeAxes = Axes.Both }, overlayContent = new Container { RelativeSizeAxes = Axes.Both },
rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both }, rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both }, leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
@ -795,6 +804,8 @@ namespace osu.Game
CloseAllOverlays(); CloseAllOverlays();
else else
Toolbar.Show(); Toolbar.Show();
backButton.Alpha = newOsuScreen.ShowBackButton ? 1 : 0;
} }
} }

View File

@ -32,6 +32,8 @@ namespace osu.Game.Screens.Edit
{ {
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
public override bool AllowBackButton => false;
public override bool HideOverlaysOnEnter => true; public override bool HideOverlaysOnEnter => true;
public override bool DisallowExternalBeatmapRulesetChanges => true; public override bool DisallowExternalBeatmapRulesetChanges => true;

View File

@ -17,6 +17,16 @@ namespace osu.Game.Screens
/// </summary> /// </summary>
bool DisallowExternalBeatmapRulesetChanges { get; } bool DisallowExternalBeatmapRulesetChanges { get; }
/// <summary>
/// Whether a visual display for the back button should be shown.
/// </summary>
bool ShowBackButton { get; }
/// <summary>
/// Whether the user can exit this this <see cref="IOsuScreen"/> by pressing the back button.
/// </summary>
bool AllowBackButton { get; }
/// <summary> /// <summary>
/// Whether a top-level component should be allowed to exit the current screen to, for example, /// Whether a top-level component should be allowed to exit the current screen to, for example,
/// complete an import. Note that this can be overridden by a user if they specifically request. /// complete an import. Note that this can be overridden by a user if they specifically request.

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens
public override bool CursorVisible => false; public override bool CursorVisible => false;
protected override bool AllowBackButton => false; public override bool AllowBackButton => false;
public Loader() public Loader()
{ {

View File

@ -32,6 +32,8 @@ namespace osu.Game.Screens.Menu
private SampleChannel welcome; private SampleChannel welcome;
private SampleChannel seeya; private SampleChannel seeya;
public override bool AllowBackButton => false;
public override bool HideOverlaysOnEnter => true; public override bool HideOverlaysOnEnter => true;
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled; public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;

View File

@ -27,7 +27,9 @@ namespace osu.Game.Screens.Menu
public override bool HideOverlaysOnEnter => buttons == null || buttons.State == ButtonSystemState.Initial; public override bool HideOverlaysOnEnter => buttons == null || buttons.State == ButtonSystemState.Initial;
protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial && host.CanExit; public override bool ShowBackButton => false;
public override bool AllowBackButton => buttons.State != ButtonSystemState.Initial && host.CanExit;
public override bool AllowExternalScreenChange => true; public override bool AllowExternalScreenChange => true;

View File

@ -36,7 +36,9 @@ namespace osu.Game.Screens
public string Description => Title; public string Description => Title;
protected virtual bool AllowBackButton => true; public virtual bool ShowBackButton => AllowBackButton;
public virtual bool AllowBackButton => true;
public virtual bool AllowExternalScreenChange => false; public virtual bool AllowExternalScreenChange => false;

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Play
{ {
public class Player : ScreenWithBeatmapBackground public class Player : ScreenWithBeatmapBackground
{ {
protected override bool AllowBackButton => false; // handled by HoldForMenuButton public override bool AllowBackButton => false; // handled by HoldForMenuButton
protected override UserActivity InitialActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); protected override UserActivity InitialActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);

View File

@ -16,7 +16,6 @@ using osu.Game.Screens.Backgrounds;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -254,13 +253,7 @@ namespace osu.Game.Screens.Ranking
} }
} }
} }
}, }
new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = this.Exit
},
}; };
foreach (var t in CreateResultPages()) foreach (var t in CreateResultPages())

View File

@ -20,8 +20,6 @@ namespace osu.Game.Screens
{ {
public class ScreenWhiteBox : OsuScreen public class ScreenWhiteBox : OsuScreen
{ {
private readonly BackButton popButton;
private const double transition_time = 1000; private const double transition_time = 1000;
protected virtual IEnumerable<Type> PossibleChildren => null; protected virtual IEnumerable<Type> PossibleChildren => null;
@ -35,10 +33,6 @@ namespace osu.Game.Screens
{ {
base.OnEntering(last); base.OnEntering(last);
//only show the pop button if we are entered form another screen.
if (last != null)
popButton.Alpha = 1;
Alpha = 0; Alpha = 0;
textContainer.Position = new Vector2(DrawSize.X / 16, 0); textContainer.Position = new Vector2(DrawSize.X / 16, 0);
@ -144,13 +138,6 @@ namespace osu.Game.Screens
}, },
} }
}, },
popButton = new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Alpha = 0,
Action = this.Exit
},
childModeButtons = new FillFlowContainer childModeButtons = new FillFlowContainer
{ {
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osuTK; using osuTK;
@ -25,8 +24,6 @@ namespace osu.Game.Screens.Select
private const float padding = 80; private const float padding = 80;
public Action OnBack;
private readonly FillFlowContainer<FooterButton> buttons; private readonly FillFlowContainer<FooterButton> buttons;
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>(); private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
@ -83,12 +80,6 @@ namespace osu.Game.Screens.Select
Height = 3, Height = 3,
Position = new Vector2(0, -3), Position = new Vector2(0, -3),
}, },
new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = () => OnBack?.Invoke()
},
new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,

View File

@ -186,23 +186,16 @@ namespace osu.Game.Screens.Select
if (ShowFooter) if (ShowFooter)
{ {
AddInternal(FooterPanels = new Container AddRangeInternal(new[]
{
FooterPanels = new Container
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding Margin = new MarginPadding { Bottom = Footer.HEIGHT },
{ Children = new Drawable[]
Bottom = Footer.HEIGHT,
},
});
AddInternal(Footer = new Footer
{
OnBack = ExitFromBack,
});
FooterPanels.AddRange(new Drawable[]
{ {
BeatmapOptions = new BeatmapOptionsOverlay(), BeatmapOptions = new BeatmapOptionsOverlay(),
ModSelect = new ModSelectOverlay ModSelect = new ModSelectOverlay
@ -211,6 +204,9 @@ namespace osu.Game.Screens.Select
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
} }
}
},
Footer = new Footer()
}); });
} }