mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 17:52:56 +08:00
Improve "escape" pressing logic in pause/fail menus.
This commit is contained in:
parent
37d458e562
commit
359fea7e25
@ -1,31 +1,19 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class FailOverlay : MenuOverlay
|
public class FailOverlay : MenuOverlay
|
||||||
{
|
{
|
||||||
|
|
||||||
public override string Header => "failed";
|
public override string Header => "failed";
|
||||||
public override string Description => "you're dead, try again?";
|
public override string Description => "you're dead, try again?";
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
||||||
{
|
|
||||||
if (args.Key == Key.Escape)
|
|
||||||
{
|
|
||||||
if (State == Visibility.Hidden) return false;
|
|
||||||
OnQuit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnKeyDown(state, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
@ -33,5 +21,16 @@ namespace osu.Game.Screens.Play
|
|||||||
AddButton("Retry", colours.YellowDark, OnRetry);
|
AddButton("Retry", colours.YellowDark, OnRetry);
|
||||||
AddButton("Quit", new Color4(170, 27, 39, 255), OnQuit);
|
AddButton("Quit", new Color4(170, 27, 39, 255), OnQuit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
{
|
||||||
|
if (!args.Repeat && args.Key == Key.Escape)
|
||||||
|
{
|
||||||
|
Buttons.Children.Last().TriggerClick();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnKeyDown(state, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ using OpenTK;
|
|||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -30,7 +31,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public abstract string Header { get; }
|
public abstract string Header { get; }
|
||||||
public abstract string Description { get; }
|
public abstract string Description { get; }
|
||||||
|
|
||||||
private FillFlowContainer buttons;
|
protected FillFlowContainer<DialogButton> Buttons;
|
||||||
|
|
||||||
public int Retries
|
public int Retries
|
||||||
{
|
{
|
||||||
@ -84,7 +85,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected void AddButton(string text, Color4 colour, Action action)
|
protected void AddButton(string text, Color4 colour, Action action)
|
||||||
{
|
{
|
||||||
buttons.Add(new PauseButton
|
Buttons.Add(new PauseButton
|
||||||
{
|
{
|
||||||
Text = text,
|
Text = text,
|
||||||
ButtonColour = colour,
|
ButtonColour = colour,
|
||||||
@ -151,7 +152,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buttons = new FillFlowContainer
|
Buttons = new FillFlowContainer<DialogButton>
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
|
||||||
@ -20,10 +20,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Key == Key.Escape)
|
if (!args.Repeat && args.Key == Key.Escape)
|
||||||
{
|
{
|
||||||
if (State == Visibility.Hidden) return false;
|
Buttons.Children.First().TriggerClick();
|
||||||
OnResume();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,4 +38,3 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user