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

Fix auto mod results not displaying correctly

This commit is contained in:
Dean Herbert 2020-03-29 22:51:28 +09:00
parent de969c07ea
commit 4f5557096c
2 changed files with 40 additions and 30 deletions

View File

@ -637,6 +637,39 @@ namespace osu.Game.Screens.Play
return base.OnExiting(next);
}
protected virtual void GotoRanking()
{
if (DrawableRuleset.ReplayScore != null)
{
// if a replay is present, we likely don't want to import into the local database.
this.Push(CreateResults(CreateScore()));
return;
}
LegacyByteArrayReader replayReader = null;
var score = new Score { ScoreInfo = CreateScore() };
if (recordingReplay?.Frames.Count > 0)
{
score.Replay = recordingReplay;
using (var stream = new MemoryStream())
{
new LegacyScoreEncoder(score, gameplayBeatmap.PlayableBeatmap).Encode(stream);
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
}
}
scoreManager.Import(score.ScoreInfo, replayReader)
.ContinueWith(imported => Schedule(() =>
{
// screen may be in the exiting transition phase.
if (this.IsCurrentScreen())
this.Push(CreateResults(imported.Result));
}));
}
private void fadeOut(bool instant = false)
{
float fadeOutDuration = instant ? 0 : 250;
@ -649,36 +682,7 @@ namespace osu.Game.Screens.Play
private void scheduleGotoRanking()
{
completionProgressDelegate?.Cancel();
completionProgressDelegate = Schedule(delegate
{
if (DrawableRuleset.ReplayScore != null)
this.Push(CreateResults(DrawableRuleset.ReplayScore.ScoreInfo));
else
{
var score = new Score { ScoreInfo = CreateScore() };
LegacyByteArrayReader replayReader = null;
if (recordingReplay?.Frames.Count > 0)
{
score.Replay = recordingReplay;
using (var stream = new MemoryStream())
{
new LegacyScoreEncoder(score, gameplayBeatmap.PlayableBeatmap).Encode(stream);
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
}
}
scoreManager.Import(score.ScoreInfo, replayReader)
.ContinueWith(imported => Schedule(() =>
{
// screen may be in the exiting transition phase.
if (this.IsCurrentScreen())
this.Push(CreateResults(imported.Result));
}));
}
});
completionProgressDelegate = Schedule(GotoRanking);
}
#endregion

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Screens;
using osu.Game.Scoring;
namespace osu.Game.Screens.Play
@ -23,6 +24,11 @@ namespace osu.Game.Screens.Play
DrawableRuleset?.SetReplayScore(score);
}
protected override void GotoRanking()
{
this.Push(CreateResults(DrawableRuleset.ReplayScore.ScoreInfo));
}
protected override ScoreInfo CreateScore() => score.ScoreInfo;
}
}