Fix Alt-F4 being blocked during gameplay (#6369)

Fix Alt-F4 being blocked during gameplay

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert
2019-10-04 13:33:00 +08:00
committed by GitHub
2 changed files with 45 additions and 15 deletions

View File

@ -127,14 +127,47 @@ namespace osu.Game.Tests.Visual.Gameplay
exitAndConfirm(); exitAndConfirm();
} }
[Test]
public void TestExitFromFailedGameplay()
{
AddUntilStep("wait for fail", () => Player.HasFailed);
AddStep("exit", () => Player.Exit());
confirmExited();
}
[Test]
public void TestQuickRetryFromFailedGameplay()
{
AddUntilStep("wait for fail", () => Player.HasFailed);
AddStep("quick retry", () => Player.GameplayClockContainer.OfType<HotkeyRetryOverlay>().First().Action?.Invoke());
confirmExited();
}
[Test]
public void TestQuickExitFromFailedGameplay()
{
AddUntilStep("wait for fail", () => Player.HasFailed);
AddStep("quick exit", () => Player.GameplayClockContainer.OfType<HotkeyExitOverlay>().First().Action?.Invoke());
confirmExited();
}
[Test] [Test]
public void TestExitFromGameplay() public void TestExitFromGameplay()
{ {
AddStep("exit", () => Player.Exit()); AddStep("exit", () => Player.Exit());
confirmPaused(); confirmExited();
}
exitAndConfirm(); [Test]
public void TestQuickExitFromGameplay()
{
AddStep("quick exit", () => Player.GameplayClockContainer.OfType<HotkeyExitOverlay>().First().Action?.Invoke());
confirmExited();
} }
[Test] [Test]

View File

@ -299,7 +299,16 @@ namespace osu.Game.Screens.Play
{ {
if (!this.IsCurrentScreen()) return; if (!this.IsCurrentScreen()) return;
this.Exit(); if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
{
failAnimation.FinishTransforms(true);
return;
}
if (canPause)
Pause();
else
this.Exit();
} }
public void Restart() public void Restart()
@ -508,24 +517,12 @@ namespace osu.Game.Screens.Play
return true; return true;
} }
if (canPause)
{
Pause();
return true;
}
// ValidForResume is false when restarting // ValidForResume is false when restarting
if (ValidForResume) if (ValidForResume)
{ {
if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value) if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value)
// still want to block if we are within the cooldown period and not already paused. // still want to block if we are within the cooldown period and not already paused.
return true; return true;
if (HasFailed && !FailOverlay.IsPresent)
{
failAnimation.FinishTransforms(true);
return true;
}
} }
GameplayClockContainer.ResetLocalAdjustments(); GameplayClockContainer.ResetLocalAdjustments();