Add encoding and import support

This commit is contained in:
Dean Herbert
2020-03-24 14:13:46 +09:00
parent 68ebe98fde
commit 022465f546
9 changed files with 220 additions and 18 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -17,6 +18,7 @@ using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.IO.Archives;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Replays;
@ -25,6 +27,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
using osu.Game.Screens.Ranking;
using osu.Game.Skinning;
using osu.Game.Users;
@ -643,19 +646,29 @@ namespace osu.Game.Screens.Play
completionProgressDelegate?.Cancel();
completionProgressDelegate = Schedule(delegate
{
var score = CreateScore();
if (DrawableRuleset.ReplayScore == null)
{
scoreManager.Import(score).ContinueWith(_ => Schedule(() =>
{
// screen may be in the exiting transition phase.
if (this.IsCurrentScreen())
this.Push(CreateResults(score));
}));
}
if (DrawableRuleset.ReplayScore != null)
this.Push(CreateResults(DrawableRuleset.ReplayScore.ScoreInfo));
else
this.Push(CreateResults(score));
{
var score = new Score
{
ScoreInfo = CreateScore(),
Replay = recordingReplay
};
using (var stream = new MemoryStream())
{
new LegacyScoreEncoder(score, gameplayBeatmap).Encode(stream);
scoreManager.Import(score.ScoreInfo, new LegacyByteArrayReader(stream.ToArray(), "replay.osr"))
.ContinueWith(imported => Schedule(() =>
{
// screen may be in the exiting transition phase.
if (this.IsCurrentScreen())
this.Push(CreateResults(imported.Result));
}));
}
}
});
}