1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 02:32:59 +08:00

Add basic quick exit functionality

This commit is contained in:
HoutarouOreki 2018-07-10 21:57:09 +02:00
parent 1444715641
commit ffe82aad25
3 changed files with 44 additions and 0 deletions

View File

@ -49,6 +49,7 @@ namespace osu.Game.Input.Bindings
{
new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene),
new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry),
new KeyBinding(new[] { InputKey.Alt, InputKey.Tilde }, GlobalAction.QuickExit),
new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed),
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
};
@ -83,6 +84,8 @@ namespace osu.Game.Input.Bindings
SkipCutscene,
[Description("Quick Retry (Hold)")]
QuickRetry,
[Description("Quick Exit (Hold)")]
QuickExit,
[Description("Take screenshot")]
TakeScreenshot,

View File

@ -71,6 +71,7 @@ namespace osu.Game.Screens.Play
private APIAccess api;
private SampleChannel sampleRestart;
private SampleChannel sampleExit;
protected ScoreProcessor ScoreProcessor;
protected RulesetContainer RulesetContainer;
@ -93,6 +94,7 @@ namespace osu.Game.Screens.Play
return;
sampleRestart = audio.Sample.Get(@"Gameplay/restart");
sampleExit = audio.Sample.Get(@"UI/screen-back");
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
@ -224,6 +226,17 @@ namespace osu.Game.Screens.Play
RulesetContainer?.Hide();
Restart();
},
},
new QuickExit
{
Action = () =>
{
if (!IsCurrentScreen) return;
sampleExit?.Play();
ValidForResume = false;
Exit();
}
}
};

View File

@ -0,0 +1,28 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCEusing System;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
namespace osu.Game.Screens.Play
{
public class QuickExit : HoldToConfirmOverlay, IKeyBindingHandler<GlobalAction>
{
public bool OnPressed(GlobalAction action)
{
if (action != GlobalAction.QuickExit) return false;
BeginConfirm();
return true;
}
public bool OnReleased(GlobalAction action)
{
if (action != GlobalAction.QuickExit) return false;
AbortConfirm();
return true;
}
}
}