1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 01:02:56 +08:00

Merge branch 'master' into realm-beatmap-file-relation

This commit is contained in:
Dean Herbert 2021-11-23 10:20:22 +09:00 committed by GitHub
commit 119ac19f86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 67 deletions

View File

@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
new Drawable[] 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 Recorder = recorder = new TestReplayRecorder(new Score
{ {
@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}, },
new Drawable[] new Drawable[]
{ {
playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
ReplayInputHandler = new TestFramedReplayInputHandler(replay) ReplayInputHandler = new TestFramedReplayInputHandler(replay)
{ {

View File

@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
new Drawable[] new Drawable[]
{ {
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
Recorder = new TestReplayRecorder(new Score Recorder = new TestReplayRecorder(new Score
{ {
@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}, },
new Drawable[] new Drawable[]
{ {
playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
ReplayInputHandler = new TestFramedReplayInputHandler(replay) ReplayInputHandler = new TestFramedReplayInputHandler(replay)
{ {

View File

@ -109,7 +109,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
new Drawable[] new Drawable[]
{ {
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
Recorder = recorder = new TestReplayRecorder Recorder = recorder = new TestReplayRecorder
{ {
@ -139,7 +139,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}, },
new Drawable[] new Drawable[]
{ {
playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
Clock = new FramedClock(manualClock), Clock = new FramedClock(manualClock),
ReplayInputHandler = replayHandler = new TestFramedReplayInputHandler(replay) ReplayInputHandler = replayHandler = new TestFramedReplayInputHandler(replay)

View File

@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
SelectedMods.Value = Array.Empty<Mod>(); SelectedMods.Value = Array.Empty<Mod>();
Ruleset.Value = new TestRulesetInfo(); Ruleset.Value = CreateTestRulesetInfo();
}); });
[Test] [Test]
@ -170,40 +170,32 @@ namespace osu.Game.Tests.Visual.UserInterface
ModSettingsContainer.Parent.Width = newWidth; 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 override IEnumerable<Mod> GetModsFor(ModType type)
public TestRulesetInfo()
{ {
Available = true; if (type == ModType.Conversion)
}
public class TestCustomisableModRuleset : Ruleset
{
public override IEnumerable<Mod> GetModsFor(ModType type)
{ {
if (type == ModType.Conversion) return new Mod[]
{ {
return new Mod[] new TestModCustomisable1(),
{ new TestModCustomisable2()
new TestModCustomisable1(), };
new TestModCustomisable2()
};
}
return Array.Empty<Mod>();
} }
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => throw new NotImplementedException(); return Array.Empty<Mod>();
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";
} }
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> 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 private class TestModCustomisable1 : TestModCustomisable

View File

@ -38,7 +38,7 @@ namespace osu.Game.Beatmaps
CircleSize = 0, CircleSize = 0,
OverallDifficulty = 0, OverallDifficulty = 0,
}, },
Ruleset = new DummyRulesetInfo() Ruleset = new DummyRuleset().RulesetInfo
}, audio) }, audio)
{ {
this.textures = textures; this.textures = textures;
@ -54,42 +54,37 @@ namespace osu.Game.Beatmaps
public override Stream GetStream(string storagePath) => null; public override Stream GetStream(string storagePath) => null;
private class DummyRulesetInfo : RulesetInfo private class DummyRuleset : Ruleset
{ {
public override Ruleset CreateInstance() => new DummyRuleset(); public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>();
private class DummyRuleset : Ruleset public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
{ {
public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>(); throw new NotImplementedException();
}
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> 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<HitObject, IEnumerable<HitObject>> 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 }; return 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<HitObject, IEnumerable<HitObject>> 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;
}
} }
} }
} }

View File

@ -10,7 +10,7 @@ using osu.Framework.Testing;
namespace osu.Game.Rulesets namespace osu.Game.Rulesets
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public class RulesetInfo : IEquatable<RulesetInfo>, IRulesetInfo public sealed class RulesetInfo : IEquatable<RulesetInfo>, IRulesetInfo
{ {
public int? ID { get; set; } public int? ID { get; set; }
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets
public bool Available { get; set; } public bool Available { get; set; }
// TODO: this should probably be moved to RulesetStore. // TODO: this should probably be moved to RulesetStore.
public virtual Ruleset CreateInstance() public Ruleset CreateInstance()
{ {
if (!Available) return null; if (!Available) return null;