diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 1a31b0f462..b09a7de631 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -3,6 +3,7 @@ #nullable disable +using System; using osu.Game.Graphics; using osuTK.Graphics; using osu.Framework.Allocation; @@ -11,12 +12,14 @@ namespace osu.Game.Screens.Play { public class FailOverlay : GameplayMenuOverlay { + public Action SaveReplay; public override string Header => "failed"; public override string Description => "you're dead, try again?"; [BackgroundDependencyLoader] private void load(OsuColour colours) { + AddButton("Save replay and Quit", colours.Blue, () => SaveReplay?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 4a8460ff46..c404510487 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -266,6 +266,7 @@ namespace osu.Game.Screens.Play }, FailOverlay = new FailOverlay { + SaveReplay = saveReplay, OnRetry = Restart, OnQuit = () => PerformExit(true), }, @@ -1043,6 +1044,21 @@ namespace osu.Game.Screens.Play return base.OnExiting(e); } + // Don't know if prepareScoreForResults useful + private async void saveReplay() + { + var scoreCopy = Score.DeepClone(); + try + { + await ImportScore(scoreCopy).ConfigureAwait(false); + } + catch (Exception ex) + { + Logger.Error(ex, @"Score import failed!"); + } + PerformExit(true); + } + /// /// Creates the player's . ///