Make a RulesetDatabase.

This commit is contained in:
Dean Herbert
2017-04-17 17:43:48 +09:00
parent 83b083ce64
commit a4e2f34ee7
38 changed files with 298 additions and 201 deletions

View File

@ -4,11 +4,6 @@
using System;
using osu.Framework.Desktop;
using osu.Framework.Platform;
using osu.Game.Modes;
using osu.Game.Modes.Catch;
using osu.Game.Modes.Mania;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Taiko;
namespace osu.Desktop.VisualTests
{
@ -21,11 +16,6 @@ namespace osu.Desktop.VisualTests
using (GameHost host = Host.GetSuitableHost(@"osu"))
{
RulesetCollection.Register(typeof(OsuRuleset));
RulesetCollection.Register(typeof(TaikoRuleset));
RulesetCollection.Register(typeof(ManiaRuleset));
RulesetCollection.Register(typeof(CatchRuleset));
if (benchmark)
host.Run(new AutomatedVisualTestGame());
else

View File

@ -1,10 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Overlays.Mods;
using osu.Framework.Testing;
using osu.Game.Modes;
using osu.Game.Database;
namespace osu.Desktop.VisualTests.Tests
{
@ -13,6 +14,13 @@ namespace osu.Desktop.VisualTests.Tests
public override string Description => @"Tests the mod select overlay";
private ModSelectOverlay modSelect;
private RulesetDatabase rulesets;
[BackgroundDependencyLoader]
private void load(RulesetDatabase rulesets)
{
this.rulesets = rulesets;
}
public override void Reset()
{
@ -27,8 +35,8 @@ namespace osu.Desktop.VisualTests.Tests
AddStep("Toggle", modSelect.ToggleVisibility);
foreach (var ruleset in RulesetCollection.AllRulesets)
AddStep(ruleset.Description, () => modSelect.Ruleset.Value = ruleset);
foreach (var ruleset in rulesets.AllRulesets)
AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset);
}
}
}

View File

@ -3,12 +3,12 @@
using System.Collections.Generic;
using osu.Desktop.VisualTests.Platform;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Framework.MathUtils;
using osu.Game.Database;
using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Filter;
using osu.Game.Modes;
namespace osu.Desktop.VisualTests.Tests
{
@ -20,6 +20,14 @@ namespace osu.Desktop.VisualTests.Tests
public override string Description => @"with fake data";
private RulesetDatabase rulesets;
[BackgroundDependencyLoader]
private void load(RulesetDatabase rulesets)
{
this.rulesets = rulesets;
}
public override void Reset()
{
base.Reset();
@ -72,7 +80,7 @@ namespace osu.Desktop.VisualTests.Tests
new BeatmapInfo
{
OnlineBeatmapID = 1234 + i,
Ruleset = RulesetCollection.GetRuleset(0),
Ruleset = rulesets.Query<RulesetInfo>().First(),
Path = "normal.osu",
Version = "Normal",
Difficulty = new BeatmapDifficulty
@ -83,7 +91,7 @@ namespace osu.Desktop.VisualTests.Tests
new BeatmapInfo
{
OnlineBeatmapID = 1235 + i,
Ruleset = RulesetCollection.GetRuleset(0),
Ruleset = rulesets.Query<RulesetInfo>().First(),
Path = "hard.osu",
Version = "Hard",
Difficulty = new BeatmapDifficulty
@ -94,7 +102,7 @@ namespace osu.Desktop.VisualTests.Tests
new BeatmapInfo
{
OnlineBeatmapID = 1236 + i,
Ruleset = RulesetCollection.GetRuleset(0),
Ruleset = rulesets.Query<RulesetInfo>().First(),
Path = "insane.osu",
Version = "Insane",
Difficulty = new BeatmapDifficulty

View File

@ -37,7 +37,7 @@ namespace osu.Desktop.VisualTests.Tests
WorkingBeatmap beatmap = null;
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.Ruleset is OsuRuleset);
var beatmapInfo = db.Query<BeatmapInfo>().FirstOrDefault(b => b.Ruleset.CreateInstance() is OsuRuleset);
if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo);