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

Move the CreateConvertibleReplayFrame() into the base ruleset class for avoid api breaking change in the customized ruleset.

This commit is contained in:
andy840119 2022-09-10 11:07:23 +08:00
parent 1398a7e11e
commit 3d7367a842
8 changed files with 15 additions and 19 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,6 @@
// 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.Game.Rulesets.Replays.Types;
namespace osu.Game.Rulesets
{
public interface ILegacyRuleset
@ -13,12 +11,5 @@ 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

@ -23,6 +23,7 @@ using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Filter;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Replays.Types;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
@ -302,6 +303,13 @@ namespace osu.Game.Rulesets
/// <returns>A descriptive name of the variant.</returns>
public virtual LocalisableString 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 as ILegacyRuleset)?.CreateConvertibleReplayFrame();
var convertible = currentRuleset.CreateConvertibleReplayFrame();
if (convertible == null)
throw new InvalidOperationException($"Legacy replay cannot be converted for the ruleset: {currentRuleset.Description}");

View File

@ -11,7 +11,6 @@ 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;
@ -81,14 +80,12 @@ namespace osu.Game.Screens.Play
if (!this.IsCurrentScreen())
return;
var legacyRuleset = GameplayState.Ruleset as ILegacyRuleset;
Debug.Assert(legacyRuleset != null);
bool isFirstBundle = score.Replay.Frames.Count == 0;
foreach (var frame in bundle.Frames)
{
IConvertibleReplayFrame convertibleFrame = legacyRuleset.CreateConvertibleReplayFrame();
IConvertibleReplayFrame convertibleFrame = GameplayState.Ruleset.CreateConvertibleReplayFrame();
Debug.Assert(convertibleFrame != null);
convertibleFrame.FromLegacy(frame, GameplayState.Beatmap);
var convertedFrame = (ReplayFrame)convertibleFrame;