allow "go back" keybind in play

This commit is contained in:
Aergwyn 2018-06-09 09:14:52 +02:00
parent d3570df64f
commit 792d3b8215
3 changed files with 25 additions and 23 deletions

View File

@ -1,16 +1,16 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 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.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; using System.Linq;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
public class FailOverlay : GameplayMenuOverlay public class FailOverlay : GameplayMenuOverlay, IKeyBindingHandler<GlobalAction>
{ {
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?";
@ -22,15 +22,17 @@ namespace osu.Game.Screens.Play
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) public bool OnPressed(GlobalAction action)
{ {
if (!args.Repeat && args.Key == Key.Escape) if (action == GlobalAction.Back)
{ {
InternalButtons.Children.Last().TriggerOnClick(); InternalButtons.Children.Last().TriggerOnClick();
return true; return true;
} }
return base.OnKeyDown(state, args); return false;
} }
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
} }
} }

View File

@ -6,11 +6,11 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Framework.Input.Bindings;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Input.Bindings;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -131,24 +131,13 @@ namespace osu.Game.Screens.Play
base.Update(); base.Update();
} }
public class PauseOverlay : GameplayMenuOverlay public class PauseOverlay : GameplayMenuOverlay, IKeyBindingHandler<GlobalAction>
{ {
public Action OnResume; public Action OnResume;
public override string Header => "paused"; public override string Header => "paused";
public override string Description => "you're not going to do what i think you're going to do, are ya?"; public override string Description => "you're not going to do what i think you're going to do, are ya?";
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (!args.Repeat && args.Key == Key.Escape)
{
InternalButtons.Children.First().TriggerOnClick();
return true;
}
return base.OnKeyDown(state, args);
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
@ -156,6 +145,19 @@ namespace osu.Game.Screens.Play
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
} }
public bool OnPressed(GlobalAction action)
{
if (action == GlobalAction.Back)
{
InternalButtons.Children.First().TriggerOnClick();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
} }
} }
} }

View File

@ -49,8 +49,6 @@ namespace osu.Game.Screens.Play
public bool AllowLeadIn { get; set; } = true; public bool AllowLeadIn { get; set; } = true;
public bool AllowResults { get; set; } = true; public bool AllowResults { get; set; } = true;
protected override bool AllowBackButton => false;
private Bindable<bool> mouseWheelDisabled; private Bindable<bool> mouseWheelDisabled;
private Bindable<double> userAudioOffset; private Bindable<double> userAudioOffset;