Save score button on failed screen

This commit is contained in:
cdwcgt
2022-06-19 23:59:37 +09:00
parent 9518e1db05
commit 9a6f4ef76d
2 changed files with 19 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#nullable disable #nullable disable
using System;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -11,12 +12,14 @@ namespace osu.Game.Screens.Play
{ {
public class FailOverlay : GameplayMenuOverlay public class FailOverlay : GameplayMenuOverlay
{ {
public Action SaveReplay;
public override string Header => "failed"; public override string Header => "failed";
public override string Description => "you're dead, try again?"; public override string Description => "you're dead, try again?";
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
AddButton("Save replay and Quit", colours.Blue, () => SaveReplay?.Invoke());
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
} }

View File

@ -266,6 +266,7 @@ namespace osu.Game.Screens.Play
}, },
FailOverlay = new FailOverlay FailOverlay = new FailOverlay
{ {
SaveReplay = saveReplay,
OnRetry = Restart, OnRetry = Restart,
OnQuit = () => PerformExit(true), OnQuit = () => PerformExit(true),
}, },
@ -1043,6 +1044,21 @@ namespace osu.Game.Screens.Play
return base.OnExiting(e); 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);
}
/// <summary> /// <summary>
/// Creates the player's <see cref="Scoring.Score"/>. /// Creates the player's <see cref="Scoring.Score"/>.
/// </summary> /// </summary>