diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs index 159d583fc0..dcc193669b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs @@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual.Gameplay { new Drawable[] { - recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) + recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique) { Recorder = recorder = new TestReplayRecorder(new Score { @@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.Gameplay }, new Drawable[] { - playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) + playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique) { ReplayInputHandler = new TestFramedReplayInputHandler(replay) { diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs index 1d4245308d..3f7155f1e2 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecording.cs @@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.Gameplay { new Drawable[] { - recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) + recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique) { Recorder = new TestReplayRecorder(new Score { @@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay }, new Drawable[] { - playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) + playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique) { ReplayInputHandler = new TestFramedReplayInputHandler(replay) { diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs index ef870a32a9..5fbccd54c8 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectatorPlayback.cs @@ -109,7 +109,7 @@ namespace osu.Game.Tests.Visual.Gameplay { new Drawable[] { - recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) + recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique) { Recorder = recorder = new TestReplayRecorder { @@ -139,7 +139,7 @@ namespace osu.Game.Tests.Visual.Gameplay }, new Drawable[] { - playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) + playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique) { Clock = new FramedClock(manualClock), ReplayInputHandler = replayHandler = new TestFramedReplayInputHandler(replay) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs index 4bb5e29589..9a3083e8db 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs @@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.UserInterface public void SetUp() => Schedule(() => { SelectedMods.Value = Array.Empty(); - Ruleset.Value = new TestRulesetInfo(); + Ruleset.Value = CreateTestRulesetInfo(); }); [Test] @@ -170,40 +170,32 @@ namespace osu.Game.Tests.Visual.UserInterface ModSettingsContainer.Parent.Width = newWidth; } - public class TestRulesetInfo : RulesetInfo + public static RulesetInfo CreateTestRulesetInfo() => new TestCustomisableModRuleset().RulesetInfo; + + public class TestCustomisableModRuleset : Ruleset { - public override Ruleset CreateInstance() => new TestCustomisableModRuleset(); - - public TestRulesetInfo() + public override IEnumerable GetModsFor(ModType type) { - Available = true; - } - - public class TestCustomisableModRuleset : Ruleset - { - public override IEnumerable GetModsFor(ModType type) + if (type == ModType.Conversion) { - if (type == ModType.Conversion) + return new Mod[] { - return new Mod[] - { - new TestModCustomisable1(), - new TestModCustomisable2() - }; - } - - return Array.Empty(); + new TestModCustomisable1(), + new TestModCustomisable2() + }; } - public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => throw new NotImplementedException(); - - public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => throw new NotImplementedException(); - - public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => throw new NotImplementedException(); - - public override string Description { get; } = "test"; - public override string ShortName { get; } = "tst"; + return Array.Empty(); } + + public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => throw new NotImplementedException(); + + public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => throw new NotImplementedException(); + + public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => throw new NotImplementedException(); + + public override string Description { get; } = "test"; + public override string ShortName { get; } = "tst"; } private class TestModCustomisable1 : TestModCustomisable diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index fcb44c462d..9ea8517764 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -38,7 +38,7 @@ namespace osu.Game.Beatmaps CircleSize = 0, OverallDifficulty = 0, }, - Ruleset = new DummyRulesetInfo() + Ruleset = new DummyRuleset().RulesetInfo }, audio) { this.textures = textures; @@ -54,42 +54,37 @@ namespace osu.Game.Beatmaps public override Stream GetStream(string storagePath) => null; - private class DummyRulesetInfo : RulesetInfo + private class DummyRuleset : Ruleset { - public override Ruleset CreateInstance() => new DummyRuleset(); + public override IEnumerable GetModsFor(ModType type) => Array.Empty(); - private class DummyRuleset : Ruleset + public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) { - public override IEnumerable GetModsFor(ModType type) => Array.Empty(); + throw new NotImplementedException(); + } - public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) + public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new DummyBeatmapConverter { Beatmap = beatmap }; + + public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null; + + public override string Description => "dummy"; + + public override string ShortName => "dummy"; + + private class DummyBeatmapConverter : IBeatmapConverter + { + public event Action> ObjectConverted; + + public IBeatmap Beatmap { get; set; } + + public bool CanConvert() => true; + + public IBeatmap Convert(CancellationToken cancellationToken = default) { - throw new NotImplementedException(); - } + foreach (var obj in Beatmap.HitObjects) + ObjectConverted?.Invoke(obj, obj.Yield()); - public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new DummyBeatmapConverter { Beatmap = beatmap }; - - public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null; - - public override string Description => "dummy"; - - public override string ShortName => "dummy"; - - private class DummyBeatmapConverter : IBeatmapConverter - { - public event Action> ObjectConverted; - - public IBeatmap Beatmap { get; set; } - - public bool CanConvert() => true; - - public IBeatmap Convert(CancellationToken cancellationToken = default) - { - foreach (var obj in Beatmap.HitObjects) - ObjectConverted?.Invoke(obj, obj.Yield()); - - return Beatmap; - } + return Beatmap; } } } diff --git a/osu.Game/Rulesets/RulesetInfo.cs b/osu.Game/Rulesets/RulesetInfo.cs index 8083041a3b..ccb614fe91 100644 --- a/osu.Game/Rulesets/RulesetInfo.cs +++ b/osu.Game/Rulesets/RulesetInfo.cs @@ -10,7 +10,7 @@ using osu.Framework.Testing; namespace osu.Game.Rulesets { [ExcludeFromDynamicCompile] - public class RulesetInfo : IEquatable, IRulesetInfo + public sealed class RulesetInfo : IEquatable, IRulesetInfo { public int? ID { get; set; } @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets public bool Available { get; set; } // TODO: this should probably be moved to RulesetStore. - public virtual Ruleset CreateInstance() + public Ruleset CreateInstance() { if (!Available) return null;