Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix occasional flash when quick exiting / retrying from player #30623

Merged
merged 5 commits into from
Nov 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 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);
bdach marked this conversation as resolved.
Show resolved Hide resolved
},
},
});
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)
bdach marked this conversation as resolved.
Show resolved Hide resolved
{
bool pauseOrFailDialogVisible =
PauseOverlay.State.Value == Visibility.Visible || FailOverlay.State.Value == Visibility.Visible;
Expand Down Expand Up @@ -639,6 +635,8 @@ protected bool PerformExit(bool showDialogFirst)
// Screen may not be current if a restart has been performed.
if (this.IsCurrentScreen())
{
noExitTransition = withoutTransition;

// 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 @@ -709,7 +707,7 @@ public bool Restart(bool quickRestart = false)

RestartRequested?.Invoke(quickRestart);

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

/// <summary>
Expand Down Expand Up @@ -1254,10 +1252,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
Loading