Skip to content

Commit

Permalink
Show results screen when reaching the end of a failed replay
Browse files Browse the repository at this point in the history
Addresses ppy#30577.

Consider this a RFC. There's multiple ways this could be implemented,
but I went for the most stand-alone approach, bypassing all the score
preparation and progress logic (because it's probably simplest this
way?).
  • Loading branch information
peppy committed Nov 14, 2024
1 parent 5cc1cbe commit 1de1825
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public abstract partial class Player : ScreenWithBeatmapBackground, ISamplePlayb
/// </summary>
protected virtual bool PauseOnFocusLost => true;

/// <summary>
/// Whether to show the fail overlay (with buttons to retry / exit) on failing.
/// </summary>
protected virtual bool ShowFailOverlay => true;

public Action<bool> RestartRequested;

private bool isRestarting;
Expand Down Expand Up @@ -990,6 +995,9 @@ private bool onFail()
/// </summary>
private void onFailComplete()
{
if (ShowFailOverlay)
return;

GameplayClockContainer.Stop();

FailOverlay.Retries = RestartCount;
Expand Down
17 changes: 17 additions & 0 deletions osu.Game/Screens/Play/ReplayPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Bindables;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Input.Bindings;
Expand All @@ -34,6 +35,8 @@ public partial class ReplayPlayer : Player, IKeyBindingHandler<GlobalAction>

protected override UserActivity InitialActivity => new UserActivity.WatchingReplay(Score.ScoreInfo);

protected override bool ShowFailOverlay => false;

// Disallow replays from failing. (see https://github.com/ppy/osu/issues/6108)
protected override bool CheckModsAllowFailure()
{
Expand Down Expand Up @@ -157,6 +160,20 @@ public void SeekInDirection(float amount)
Seek(target);
}

protected override void OnFail()
{
// Replays will always show the results screen on failing.
Scheduler.AddDelayed(() =>
{
if (!this.IsCurrentScreen())
// This player instance may already be in the process of exiting.
return;

ValidForResume = false;
this.Push(CreateResults(Score.ScoreInfo));
}, RESULTS_DISPLAY_DELAY);
}

public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
Expand Down

0 comments on commit 1de1825

Please sign in to comment.