mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Conditionally add ExitConfirmOverlay and disable back action
This commit is contained in:
parent
add8b8e9c4
commit
61be4f2695
@ -19,6 +19,7 @@ using osu.Game.Screens.Edit;
|
|||||||
using osu.Game.Screens.Multi;
|
using osu.Game.Screens.Multi;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Tournament;
|
using osu.Game.Screens.Tournament;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
{
|
{
|
||||||
@ -28,7 +29,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
public override bool HideOverlaysOnEnter => buttons.State == ButtonSystemState.Initial;
|
public override bool HideOverlaysOnEnter => buttons.State == ButtonSystemState.Initial;
|
||||||
|
|
||||||
protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial;
|
protected override bool AllowBackButton => buttons.State != ButtonSystemState.Initial && host.CanExit;
|
||||||
|
|
||||||
public override bool AllowExternalScreenChange => true;
|
public override bool AllowExternalScreenChange => true;
|
||||||
|
|
||||||
@ -36,33 +37,23 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
private readonly MenuSideFlashes sideFlashes;
|
private readonly MenuSideFlashes sideFlashes;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
||||||
|
|
||||||
public MainMenu()
|
public MainMenu()
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
sideFlashes = new MenuSideFlashes();
|
||||||
|
|
||||||
|
buttons = new ButtonSystem
|
||||||
{
|
{
|
||||||
new ExitConfirmOverlay
|
OnChart = delegate { this.Push(new ChartListing()); },
|
||||||
{
|
OnDirect = delegate { this.Push(new OnlineListing()); },
|
||||||
Action = this.Exit,
|
OnEdit = delegate { this.Push(new Editor()); },
|
||||||
},
|
OnSolo = onSolo,
|
||||||
new ParallaxContainer
|
OnMulti = delegate { this.Push(new Multiplayer()); },
|
||||||
{
|
OnExit = this.Exit,
|
||||||
ParallaxAmount = 0.01f,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
buttons = new ButtonSystem
|
|
||||||
{
|
|
||||||
OnChart = delegate { this.Push(new ChartListing()); },
|
|
||||||
OnDirect = delegate {this.Push(new OnlineListing()); },
|
|
||||||
OnEdit = delegate {this.Push(new Editor()); },
|
|
||||||
OnSolo = onSolo,
|
|
||||||
OnMulti = delegate {this.Push(new Multiplayer()); },
|
|
||||||
OnExit = this.Exit,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sideFlashes = new MenuSideFlashes(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
buttons.StateChanged += state =>
|
buttons.StateChanged += state =>
|
||||||
@ -83,6 +74,22 @@ namespace osu.Game.Screens.Menu
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuGame game = null)
|
private void load(OsuGame game = null)
|
||||||
{
|
{
|
||||||
|
if (host.CanExit)
|
||||||
|
{
|
||||||
|
AddInternal(new ExitConfirmOverlay
|
||||||
|
{
|
||||||
|
Action = this.Exit,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
AddInternal(new ParallaxContainer
|
||||||
|
{
|
||||||
|
ParallaxAmount = 0.01f,
|
||||||
|
Child = buttons,
|
||||||
|
});
|
||||||
|
|
||||||
|
AddInternal(sideFlashes);
|
||||||
|
|
||||||
if (game != null)
|
if (game != null)
|
||||||
{
|
{
|
||||||
buttons.OnSettings = game.ToggleSettings;
|
buttons.OnSettings = game.ToggleSettings;
|
||||||
|
Loading…
Reference in New Issue
Block a user