1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 09:03:00 +08:00

Move CreateConvertibleReplayFrame() into legacy ruleset interface because technically only legacy ruleset use it to convert the legacy frame.

But seems some of the customized ruleset use it for save the replay frame.
This commit is contained in:
為什麼 2022-07-10 09:53:05 +08:00
parent e67cb4c905
commit 857377e145
8 changed files with 18 additions and 15 deletions

View File

@ -187,7 +187,7 @@ namespace osu.Game.Rulesets.Catch
public int LegacyID => 2;
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new CatchReplayFrame();
public IConvertibleReplayFrame CreateConvertibleReplayFrame() => new CatchReplayFrame();
public override HitObjectComposer CreateHitObjectComposer() => new CatchHitObjectComposer(this);

View File

@ -280,7 +280,7 @@ namespace osu.Game.Rulesets.Mania
public int LegacyID => 3;
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new ManiaReplayFrame();
public IConvertibleReplayFrame CreateConvertibleReplayFrame() => new ManiaReplayFrame();
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new ManiaRulesetConfigManager(settings, RulesetInfo);

View File

@ -234,7 +234,7 @@ namespace osu.Game.Rulesets.Osu
public int LegacyID => 0;
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame();
public IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame();
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new OsuRulesetConfigManager(settings, RulesetInfo);

View File

@ -177,7 +177,7 @@ namespace osu.Game.Rulesets.Taiko
public int LegacyID => 1;
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TaikoReplayFrame();
public IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TaikoReplayFrame();
protected override IEnumerable<HitResult> GetValidHitResults()
{

View File

@ -1,7 +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.
#nullable disable
using osu.Game.Rulesets.Replays.Types;
namespace osu.Game.Rulesets
{
@ -13,5 +13,12 @@ namespace osu.Game.Rulesets
/// Identifies the server-side ID of a legacy ruleset.
/// </summary>
int LegacyID { get; }
/// <summary>
/// For rulesets which support legacy (osu-stable) replay conversion, this method will create an empty replay frame
/// for conversion use.
/// </summary>
/// <returns>An empty frame for the current ruleset, or null if unsupported.</returns>
IConvertibleReplayFrame CreateConvertibleReplayFrame();
}
}

View File

@ -13,7 +13,6 @@ using osu.Game.Beatmaps;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Replays.Types;
using osu.Game.Rulesets.UI;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Configuration;
@ -284,13 +283,6 @@ namespace osu.Game.Rulesets
/// <returns>A descriptive name of the variant.</returns>
public virtual string GetVariantName(int variant) => string.Empty;
/// <summary>
/// For rulesets which support legacy (osu-stable) replay conversion, this method will create an empty replay frame
/// for conversion use.
/// </summary>
/// <returns>An empty frame for the current ruleset, or null if unsupported.</returns>
public virtual IConvertibleReplayFrame CreateConvertibleReplayFrame() => null;
/// <summary>
/// Creates the statistics for a <see cref="ScoreInfo"/> to be displayed in the results screen.
/// </summary>

View File

@ -282,7 +282,7 @@ namespace osu.Game.Scoring.Legacy
private ReplayFrame convertFrame(LegacyReplayFrame currentFrame, ReplayFrame lastFrame)
{
var convertible = currentRuleset.CreateConvertibleReplayFrame();
var convertible = (currentRuleset as ILegacyRuleset)?.CreateConvertibleReplayFrame();
if (convertible == null)
throw new InvalidOperationException($"Legacy replay cannot be converted for the ruleset: {currentRuleset.Description}");

View File

@ -10,6 +10,7 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Spectator;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types;
using osu.Game.Scoring;
@ -79,11 +80,14 @@ namespace osu.Game.Screens.Play
if (!this.IsCurrentScreen())
return;
if (GameplayState.Ruleset is not ILegacyRuleset legacyRuleset)
return;
bool isFirstBundle = score.Replay.Frames.Count == 0;
foreach (var frame in bundle.Frames)
{
IConvertibleReplayFrame convertibleFrame = GameplayState.Ruleset.CreateConvertibleReplayFrame();
IConvertibleReplayFrame convertibleFrame = legacyRuleset.CreateConvertibleReplayFrame();
convertibleFrame.FromLegacy(frame, GameplayState.Beatmap);
var convertedFrame = (ReplayFrame)convertibleFrame;