1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-27 01:03:45 +08:00

Use both OnKeyDown and GlobalAction.Back

This commit is contained in:
Roman Kapustin
2018-05-14 22:09:09 +03:00
Unverified
parent e802b722f0
commit f2f2fb8c73
4 changed files with 21 additions and 0 deletions
+2
View File
@@ -19,6 +19,8 @@ namespace osu.Game.Screens
public override bool ShowOverlaysOnEnter => false;
protected override bool AllowBackButton => false;
public Loader()
{
ValidForResume = false;
+2
View File
@@ -26,6 +26,8 @@ namespace osu.Game.Screens.Menu
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
protected override bool AllowBackButton => buttons.State != MenuState.Initial;
private readonly BackgroundScreenDefault background;
private Screen songSelect;
+16
View File
@@ -7,6 +7,7 @@ using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
@@ -15,6 +16,7 @@ using osu.Game.Input.Bindings;
using osu.Game.Rulesets;
using osu.Game.Screens.Menu;
using OpenTK;
using OpenTK.Input;
namespace osu.Game.Screens
{
@@ -105,6 +107,20 @@ namespace osu.Game.Screens
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back && AllowBackButton;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat || !IsCurrentScreen) return false;
switch (args.Key)
{
case Key.Escape:
Exit();
return true;
}
return base.OnKeyDown(state, args);
}
protected override void OnResuming(Screen last)
{
sampleExit?.Play();
@@ -16,6 +16,7 @@ namespace osu.Game.Screens.Play
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
public override bool AllowBeatmapRulesetChange => false;
protected override bool AllowBackButton => false;
protected const float BACKGROUND_FADE_DURATION = 800;