mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Split submission and import into two methods
This commit is contained in:
@ -103,8 +103,10 @@ namespace osu.Game.Screens.Multi.Play
|
|||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<ScoreInfo> SubmitScore(Score score)
|
protected override async Task SubmitScore(Score score)
|
||||||
{
|
{
|
||||||
|
await base.SubmitScore(score);
|
||||||
|
|
||||||
Debug.Assert(token != null);
|
Debug.Assert(token != null);
|
||||||
|
|
||||||
var tcs = new TaskCompletionSource<bool>();
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
@ -124,8 +126,6 @@ namespace osu.Game.Screens.Multi.Play
|
|||||||
|
|
||||||
api.Queue(request);
|
api.Queue(request);
|
||||||
await tcs.Task;
|
await tcs.Task;
|
||||||
|
|
||||||
return await base.SubmitScore(score);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -537,13 +537,23 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return await SubmitScore(score);
|
await SubmitScore(score);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error(ex, "Score submission failed!");
|
Logger.Error(ex, "Score submission failed!");
|
||||||
return score.ScoreInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ImportScore(score);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error(ex, "Score import failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return score.ScoreInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
using (BeginDelayedSequence(RESULTS_DISPLAY_DELAY))
|
using (BeginDelayedSequence(RESULTS_DISPLAY_DELAY))
|
||||||
@ -792,15 +802,15 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Submits the player's <see cref="Score"/>.
|
/// Imports the player's <see cref="Score"/> to the local database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="score">The <see cref="Score"/> to submit.</param>
|
/// <param name="score">The <see cref="Score"/> to import.</param>
|
||||||
/// <returns>The submitted score.</returns>
|
/// <returns>The imported score.</returns>
|
||||||
protected virtual async Task<ScoreInfo> SubmitScore(Score score)
|
protected virtual async Task ImportScore(Score score)
|
||||||
{
|
{
|
||||||
// Replays are already populated and present in the game's database, so should not be re-imported.
|
// Replays are already populated and present in the game's database, so should not be re-imported.
|
||||||
if (DrawableRuleset.ReplayScore != null)
|
if (DrawableRuleset.ReplayScore != null)
|
||||||
return score.ScoreInfo;
|
return;
|
||||||
|
|
||||||
LegacyByteArrayReader replayReader;
|
LegacyByteArrayReader replayReader;
|
||||||
|
|
||||||
@ -810,9 +820,16 @@ namespace osu.Game.Screens.Play
|
|||||||
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
|
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await scoreManager.Import(score.ScoreInfo, replayReader);
|
await scoreManager.Import(score.ScoreInfo, replayReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Submits the player's <see cref="Score"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="score">The <see cref="Score"/> to submit.</param>
|
||||||
|
/// <returns>The submitted score.</returns>
|
||||||
|
protected virtual Task SubmitScore(Score score) => Task.CompletedTask;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the <see cref="ResultsScreen"/> for a <see cref="ScoreInfo"/>.
|
/// Creates the <see cref="ResultsScreen"/> for a <see cref="ScoreInfo"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -37,7 +37,8 @@ namespace osu.Game.Screens.Play
|
|||||||
return Score;
|
return Score;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task<ScoreInfo> SubmitScore(Score score) => Task.FromResult(score.ScoreInfo);
|
// Don't re-import replay scores as they're already present in the database.
|
||||||
|
protected override Task ImportScore(Score score) => Task.CompletedTask;
|
||||||
|
|
||||||
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);
|
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user