1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 14:07:25 +08:00

Save score button on failed screen

This commit is contained in:
cdwcgt 2022-06-19 23:59:37 +09:00
parent 9518e1db05
commit 9a6f4ef76d
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
2 changed files with 19 additions and 0 deletions

View File

@ -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());
}

View File

@ -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);
}
/// <summary>
/// Creates the player's <see cref="Scoring.Score"/>.
/// </summary>