Detach gameplay score from replay recorder before importing

Closes #13320.
This commit is contained in:
Dean Herbert
2021-06-04 01:59:56 +09:00
parent daff4a1a00
commit d444fed46f
3 changed files with 14 additions and 3 deletions

View File

@ -267,6 +267,12 @@ namespace osu.Game.Rulesets.UI
if (!(KeyBindingInputManager is IHasRecordingHandler recordingInputManager)) if (!(KeyBindingInputManager is IHasRecordingHandler recordingInputManager))
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports recording is not available"); throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports recording is not available");
if (score == null)
{
recordingInputManager.Recorder = null;
return;
}
var recorder = CreateReplayRecorder(score); var recorder = CreateReplayRecorder(score);
if (recorder == null) if (recorder == null)
@ -511,7 +517,7 @@ namespace osu.Game.Rulesets.UI
/// Sets a replay to be used to record gameplay. /// Sets a replay to be used to record gameplay.
/// </summary> /// </summary>
/// <param name="score">The target to be recorded to.</param> /// <param name="score">The target to be recorded to.</param>
public abstract void SetRecordTarget(Score score); public abstract void SetRecordTarget([CanBeNull] Score score);
/// <summary> /// <summary>
/// Invoked when the interactive user requests resuming from a paused state. /// Invoked when the interactive user requests resuming from a paused state.

View File

@ -30,11 +30,13 @@ namespace osu.Game.Rulesets.UI
{ {
set set
{ {
if (recorder != null) if (value != null && recorder != null)
throw new InvalidOperationException("Cannot attach more than one recorder"); throw new InvalidOperationException("Cannot attach more than one recorder");
recorder?.Expire();
recorder = value; recorder = value;
if (recorder != null)
KeyBindingContainer.Add(recorder); KeyBindingContainer.Add(recorder);
} }
} }

View File

@ -636,6 +636,9 @@ namespace osu.Game.Screens.Play
ValidForResume = false; ValidForResume = false;
// ensure we are not writing to the replay any more, as we are about to consume and store the score.
DrawableRuleset.SetRecordTarget(null);
if (!Configuration.ShowResults) return; if (!Configuration.ShowResults) return;
prepareScoreForDisplayTask ??= Task.Run(async () => prepareScoreForDisplayTask ??= Task.Run(async () =>