mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:33:22 +08:00
Merge pull request #30623 from peppy/fix-flash-transition-player
Fix occasional flash when quick exiting / retrying from player
This commit is contained in:
commit
21d407680b
@ -223,7 +223,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected partial class OutroPlayer : TestPlayer
|
||||
{
|
||||
public void ExitViaPause() => PerformExit(true);
|
||||
public void ExitViaPause() => PerformExitWithConfirmation();
|
||||
|
||||
public new FailOverlay FailOverlay => base.FailOverlay;
|
||||
|
||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
Logger.Log(message, LoggingTarget.Runtime, LogLevel.Important);
|
||||
|
||||
Schedule(() => PerformExit(false));
|
||||
Schedule(() => PerformExit());
|
||||
}
|
||||
|
||||
private void onGameplayStarted() => Scheduler.Add(() =>
|
||||
|
@ -86,6 +86,7 @@ namespace osu.Game.Screens.Play
|
||||
public Action<bool> RestartRequested;
|
||||
|
||||
private bool isRestarting;
|
||||
private bool skipExitTransition;
|
||||
|
||||
private Bindable<bool> mouseWheelDisabled;
|
||||
|
||||
@ -289,7 +290,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
SaveReplay = async () => await prepareAndImportScoreAsync(true).ConfigureAwait(false),
|
||||
OnRetry = Configuration.AllowUserInteraction ? () => Restart() : null,
|
||||
OnQuit = () => PerformExit(true),
|
||||
OnQuit = () => PerformExitWithConfirmation(),
|
||||
},
|
||||
new HotkeyExitOverlay
|
||||
{
|
||||
@ -297,10 +298,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
if (PerformExit(false))
|
||||
// The hotkey overlay dims the screen.
|
||||
// If the operation succeeds, we want to make sure we stay dimmed to keep continuity.
|
||||
fadeOut(true);
|
||||
PerformExit(skipTransition: true);
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -318,10 +316,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
if (Restart(true))
|
||||
// The hotkey overlay dims the screen.
|
||||
// If the operation succeeds, we want to make sure we stay dimmed to keep continuity.
|
||||
fadeOut(true);
|
||||
Restart(true);
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -448,7 +443,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
HoldToQuit =
|
||||
{
|
||||
Action = () => PerformExit(true),
|
||||
Action = () => PerformExitWithConfirmation(),
|
||||
IsPaused = { BindTarget = GameplayClockContainer.IsPaused },
|
||||
ReplayLoaded = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
||||
},
|
||||
@ -485,7 +480,7 @@ namespace osu.Game.Screens.Play
|
||||
OnResume = Resume,
|
||||
Retries = RestartCount,
|
||||
OnRetry = () => Restart(),
|
||||
OnQuit = () => PerformExit(true),
|
||||
OnQuit = () => PerformExitWithConfirmation(),
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -588,25 +583,24 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to complete a user request to exit gameplay.
|
||||
/// Attempts to complete a user request to exit gameplay, with confirmation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <list type="bullet">
|
||||
/// <item>This should only be called in response to a user interaction. Exiting is not guaranteed.</item>
|
||||
/// <item>This will interrupt any pending progression to the results screen, even if the transition has begun.</item>
|
||||
/// </list>
|
||||
///
|
||||
/// This method will show the pause or fail dialog before performing an exit.
|
||||
/// If a dialog is not yet displayed, the exit will be blocked and the relevant dialog will display instead.
|
||||
/// </remarks>
|
||||
/// <param name="showDialogFirst">
|
||||
/// Whether the pause or fail dialog should be shown before performing an exit.
|
||||
/// If <see langword="true"/> and a dialog is not yet displayed, the exit will be blocked and the relevant dialog will display instead.
|
||||
/// </param>
|
||||
/// <returns>Whether this call resulted in a final exit.</returns>
|
||||
protected bool PerformExit(bool showDialogFirst)
|
||||
protected bool PerformExitWithConfirmation()
|
||||
{
|
||||
bool pauseOrFailDialogVisible =
|
||||
PauseOverlay.State.Value == Visibility.Visible || FailOverlay.State.Value == Visibility.Visible;
|
||||
|
||||
if (showDialogFirst && !pauseOrFailDialogVisible)
|
||||
if (!pauseOrFailDialogVisible)
|
||||
{
|
||||
// if the fail animation is currently in progress, accelerate it (it will show the pause dialog on completion).
|
||||
if (ValidForResume && GameplayState.HasFailed)
|
||||
@ -625,6 +619,22 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
return PerformExit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to complete a user request to exit gameplay.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <list type="bullet">
|
||||
/// <item>This should only be called in response to a user interaction. Exiting is not guaranteed.</item>
|
||||
/// <item>This will interrupt any pending progression to the results screen, even if the transition has begun.</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <param name="skipTransition">Whether the exit should perform without a transition, because the screen had faded to black already.</param>
|
||||
/// <returns>Whether this call resulted in a final exit.</returns>
|
||||
protected bool PerformExit(bool skipTransition = false)
|
||||
{
|
||||
// Matching osu!stable behaviour, if the results screen is pending and the user requests an exit,
|
||||
// show the results instead.
|
||||
if (GameplayState.HasPassed && !isRestarting)
|
||||
@ -639,6 +649,8 @@ namespace osu.Game.Screens.Play
|
||||
// Screen may not be current if a restart has been performed.
|
||||
if (this.IsCurrentScreen())
|
||||
{
|
||||
skipExitTransition = skipTransition;
|
||||
|
||||
// The actual exit is performed if
|
||||
// - the pause / fail dialog was not requested
|
||||
// - the pause / fail dialog was requested but is already displayed (user showing intention to exit).
|
||||
@ -707,9 +719,14 @@ namespace osu.Game.Screens.Play
|
||||
// stopping here is to ensure music doesn't become audible after exiting back to PlayerLoader.
|
||||
musicController.Stop();
|
||||
|
||||
RestartRequested?.Invoke(quickRestart);
|
||||
if (RestartRequested != null)
|
||||
{
|
||||
skipExitTransition = quickRestart;
|
||||
RestartRequested?.Invoke(quickRestart);
|
||||
return true;
|
||||
}
|
||||
|
||||
return PerformExit(false);
|
||||
return PerformExit(quickRestart);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1254,10 +1271,10 @@ namespace osu.Game.Screens.Play
|
||||
ShowUserStatistics = true,
|
||||
};
|
||||
|
||||
private void fadeOut(bool instant = false)
|
||||
private void fadeOut()
|
||||
{
|
||||
float fadeOutDuration = instant ? 0 : 250;
|
||||
this.FadeOut(fadeOutDuration);
|
||||
if (!skipExitTransition)
|
||||
this.FadeOut(250);
|
||||
|
||||
if (this.IsCurrentScreen())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user