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

Improve "escape" pressing logic in pause/fail menus.

This commit is contained in:
Dean Herbert 2017-04-13 11:35:36 +09:00
parent 37d458e562
commit 359fea7e25
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
3 changed files with 19 additions and 21 deletions

View File

@ -1,31 +1,19 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using OpenTK.Input;
using osu.Game.Graphics;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using System.Linq;
namespace osu.Game.Screens.Play
{
public class FailOverlay : MenuOverlay
{
public override string Header => "failed";
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]
private void load(OsuColour colours)
@ -33,5 +21,16 @@ namespace osu.Game.Screens.Play
AddButton("Retry", colours.YellowDark, OnRetry);
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);
}
}
}

View File

@ -13,6 +13,7 @@ using OpenTK;
using OpenTK.Graphics;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Play
{
@ -30,7 +31,7 @@ namespace osu.Game.Screens.Play
public abstract string Header { get; }
public abstract string Description { get; }
private FillFlowContainer buttons;
protected FillFlowContainer<DialogButton> Buttons;
public int Retries
{
@ -84,7 +85,7 @@ namespace osu.Game.Screens.Play
protected void AddButton(string text, Color4 colour, Action action)
{
buttons.Add(new PauseButton
Buttons.Add(new PauseButton
{
Text = text,
ButtonColour = colour,
@ -151,7 +152,7 @@ namespace osu.Game.Screens.Play
}
}
},
buttons = new FillFlowContainer
Buttons = new FillFlowContainer<DialogButton>
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,

View File

@ -2,10 +2,10 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Input;
using osu.Game.Graphics;
using OpenTK.Input;
using osu.Framework.Graphics.Containers;
using OpenTK.Graphics;
using osu.Framework.Allocation;
@ -20,10 +20,9 @@ namespace osu.Game.Screens.Play
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;
OnResume();
Buttons.Children.First().TriggerClick();
return true;
}
@ -39,4 +38,3 @@ namespace osu.Game.Screens.Play
}
}
}