From c9c65cab53548490585ee0c650ed7956345aa1de Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 1 Mar 2018 01:32:32 +0900 Subject: [PATCH] CreateReplayFrame -> CreateConvertibleReplayFrame --- osu.Game.Rulesets.Catch/CatchRuleset.cs | 4 ++-- osu.Game.Rulesets.Mania/ManiaRuleset.cs | 4 ++-- osu.Game.Rulesets.Osu/OsuRuleset.cs | 4 ++-- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 4 ++-- osu.Game/Rulesets/Ruleset.cs | 4 ++-- .../Rulesets/Scoring/Legacy/LegacyScoreParser.cs | 13 ++++++------- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index 0228a23166..d49e9c7c26 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Catch.Replays; -using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.Replays.Types; namespace osu.Game.Rulesets.Catch { @@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Catch public override int LegacyID => 2; - public override ReplayFrame CreateReplayFrame() => new CatchReplayFrame(); + public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new CatchReplayFrame(); public CatchRuleset(RulesetInfo rulesetInfo = null) : base(rulesetInfo) diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 611c5e7143..3ad498e6ea 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -13,7 +13,7 @@ using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Replays; -using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.Replays.Types; namespace osu.Game.Rulesets.Mania { @@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania public override int LegacyID => 3; - public override ReplayFrame CreateReplayFrame() => new ManiaReplayFrame(); + public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new ManiaReplayFrame(); public ManiaRuleset(RulesetInfo rulesetInfo = null) : base(rulesetInfo) diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 42ead91f0d..3f0aea5cb2 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -20,7 +20,7 @@ using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Replays; -using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.Replays.Types; namespace osu.Game.Rulesets.Osu { @@ -147,7 +147,7 @@ namespace osu.Game.Rulesets.Osu public override int LegacyID => 0; - public override ReplayFrame CreateReplayFrame() => new OsuReplayFrame(); + public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame(); public OsuRuleset(RulesetInfo rulesetInfo = null) : base(rulesetInfo) diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 9965b3d3f2..713506e831 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -10,7 +10,7 @@ using osu.Game.Rulesets.UI; using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; -using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Taiko.Replays; namespace osu.Game.Rulesets.Taiko @@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Taiko public override int LegacyID => 1; - public override ReplayFrame CreateReplayFrame() => new TaikoReplayFrame(); + public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TaikoReplayFrame(); public TaikoRuleset(RulesetInfo rulesetInfo = null) : base(rulesetInfo) diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index 9d49ebe37d..7b6219da9a 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -11,7 +11,7 @@ using osu.Game.Graphics; using osu.Game.Overlays.Settings; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -90,7 +90,7 @@ namespace osu.Game.Rulesets /// A descriptive name of the variant. public virtual string GetVariantName(int variant) => string.Empty; - public virtual ReplayFrame CreateReplayFrame() => new ReplayFrame(); + public virtual IConvertibleReplayFrame CreateConvertibleReplayFrame() => null; /// /// Create a ruleset info based on this ruleset. diff --git a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs index 5610a36a83..ea36b818b3 100644 --- a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs +++ b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs @@ -1,12 +1,12 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.IO; using osu.Game.Beatmaps; using osu.Game.IO.Legacy; using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays.Legacy; -using osu.Game.Rulesets.Replays.Types; using osu.Game.Users; using SharpCompress.Compressors.LZMA; @@ -139,13 +139,12 @@ namespace osu.Game.Rulesets.Scoring.Legacy private ReplayFrame convertFrame(LegacyReplayFrame legacyFrame) { - var converted = currentRuleset.CreateReplayFrame(); - converted.Time = legacyFrame.Time; + var convertible = currentRuleset.CreateConvertibleReplayFrame(); + if (convertible == null) + throw new InvalidOperationException($"Legacy replay cannot be converted for the ruleset: {currentRuleset.Description}"); + convertible.ConvertFrom(legacyFrame, currentScore, currentBeatmap); - if (converted is IConvertibleReplayFrame convertible) - convertible.ConvertFrom(legacyFrame, currentScore, currentBeatmap); - - return converted; + return (ReplayFrame)convertible; } } }