Skip to content

Commit

Permalink
Fix occasional flash when quick exiting / retrying from player
Browse files Browse the repository at this point in the history
The gist of the issue is that `fadeOut` was being called *twice* in the
quick exit/retry scenarios, causing weirdness with transforms.

I've restructured things to ensure it's only called once.
  • Loading branch information
peppy committed Nov 14, 2024
1 parent 7ee9802 commit b0e5d5e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public abstract partial class Player : ScreenWithBeatmapBackground, ISamplePlayb
public Action<bool> RestartRequested;

private bool isRestarting;
private bool noExitTransition;

private Bindable<bool> mouseWheelDisabled;

Expand Down Expand Up @@ -297,10 +298,7 @@ private void load(OsuConfigManager config, OsuGameBase game, CancellationToken c
{
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(false, true);
},
},
});
Expand All @@ -318,10 +316,7 @@ private void load(OsuConfigManager config, OsuGameBase game, CancellationToken c
{
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);
},
},
});
Expand Down Expand Up @@ -600,8 +595,9 @@ private IBeatmap loadPlayableBeatmap(Mod[] gameplayMods, CancellationToken cance
/// 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>
/// <param name="withoutTransition">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 showDialogFirst)
protected bool PerformExit(bool showDialogFirst, bool withoutTransition = false)
{
bool pauseOrFailDialogVisible =
PauseOverlay.State.Value == Visibility.Visible || FailOverlay.State.Value == Visibility.Visible;
Expand Down Expand Up @@ -639,6 +635,9 @@ protected bool PerformExit(bool showDialogFirst)
// Screen may not be current if a restart has been performed.
if (this.IsCurrentScreen())
{
if (withoutTransition)
noExitTransition = true;

// 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).
Expand Down Expand Up @@ -702,14 +701,15 @@ public bool Restart(bool quickRestart = false)
return false;

isRestarting = true;
noExitTransition = true;

// at the point of restarting the track should either already be paused or the volume should be zero.
// stopping here is to ensure music doesn't become audible after exiting back to PlayerLoader.
musicController.Stop();

RestartRequested?.Invoke(quickRestart);

return PerformExit(false);
return PerformExit(false, quickRestart);
}

/// <summary>
Expand Down Expand Up @@ -1254,10 +1254,10 @@ protected virtual Task ImportScore(Score score)
ShowUserStatistics = true,
};

private void fadeOut(bool instant = false)
private void fadeOut()
{
float fadeOutDuration = instant ? 0 : 250;
this.FadeOut(fadeOutDuration);
if (!noExitTransition)
this.FadeOut(250);

if (this.IsCurrentScreen())
{
Expand Down

0 comments on commit b0e5d5e

Please sign in to comment.