1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-19 03:19:52 +08:00

Update save score button to check availability after import

Previously was relying on whether `SaveReplay` returns null, but since
I've changed it to use the standard "prepare score for import" path, the
button has to check for local availability after import since that path
doesn't return null on fail.
This commit is contained in:
Salman Ahmed
2022-07-15 23:39:04 +03:00
Unverified
parent 6285442b7d
commit e6236ba088
2 changed files with 9 additions and 10 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ namespace osu.Game.Screens.Play
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new SaveFailedScoreButton(() => SaveReplay())
new SaveFailedScoreButton(SaveReplay)
{
Width = 300
},
@@ -22,7 +22,7 @@ namespace osu.Game.Screens.Play
private readonly Func<Task<ScoreInfo>> importFailedScore;
private ScoreInfo? score;
private ScoreInfo? importedScore;
private DownloadButton button = null!;
@@ -45,17 +45,16 @@ namespace osu.Game.Screens.Play
switch (state.Value)
{
case DownloadState.LocallyAvailable:
game?.PresentScore(score, ScorePresentType.Gameplay);
game?.PresentScore(importedScore, ScorePresentType.Gameplay);
break;
case DownloadState.NotDownloaded:
state.Value = DownloadState.Importing;
Task.Run(importFailedScore).ContinueWith(result => Schedule(() =>
Task.Run(importFailedScore).ContinueWith(t =>
{
score = result.GetResultSafely();
state.Value = score != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded;
}));
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
});
break;
}
}
@@ -63,8 +62,8 @@ namespace osu.Game.Screens.Play
if (player != null)
{
score = realm.Run(r => r.Find<ScoreInfo>(player.Score.ScoreInfo.ID)?.Detach());
if (score != null)
importedScore = realm.Run(r => r.Find<ScoreInfo>(player.Score.ScoreInfo.ID)?.Detach());
if (importedScore != null)
state.Value = DownloadState.LocallyAvailable;
}