1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

Store last set score to a SessionStatic

This commit is contained in:
Bartłomiej Dach 2023-12-27 18:38:29 +01:00
parent c2d60006cb
commit d4423d4933
No known key found for this signature in database
3 changed files with 13 additions and 0 deletions

View File

@ -9,6 +9,7 @@ using osu.Game.Input;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Scoring;
namespace osu.Game.Configuration
{
@ -27,6 +28,7 @@ namespace osu.Game.Configuration
SetDefault(Static.LastModSelectPanelSamplePlaybackTime, (double?)null);
SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null);
SetDefault(Static.TouchInputActive, RuntimeInfo.IsMobile);
SetDefault<ScoreInfo>(Static.LastLocalUserScore, null);
}
/// <summary>
@ -73,5 +75,10 @@ namespace osu.Game.Configuration
/// Used in touchscreen detection scenarios (<see cref="TouchInputInterceptor"/>).
/// </summary>
TouchInputActive,
/// <summary>
/// Stores the local user's last score (can be completed or aborted).
/// </summary>
LastLocalUserScore,
}
}

View File

@ -207,6 +207,7 @@ namespace osu.Game.Scoring
clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics);
clone.MaximumStatistics = new Dictionary<HitResult, int>(clone.MaximumStatistics);
clone.HitEvents = new List<HitEvent>(clone.HitEvents);
// Ensure we have fresh mods to avoid any references (ie. after gameplay).
clone.clearAllMods();

View File

@ -11,6 +11,7 @@ using osu.Framework.Allocation;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
@ -37,6 +38,9 @@ namespace osu.Game.Screens.Play
[Resolved]
private SpectatorClient spectatorClient { get; set; }
[Resolved]
private SessionStatics statics { get; set; }
private TaskCompletionSource<bool> scoreSubmissionSource;
protected SubmittingPlayer(PlayerConfiguration configuration = null)
@ -176,6 +180,7 @@ namespace osu.Game.Screens.Play
{
bool exiting = base.OnExiting(e);
submitFromFailOrQuit();
statics.SetValue(Static.LastLocalUserScore, Score.ScoreInfo.DeepClone());
return exiting;
}