mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Add CreateRuleset
in OsuTestScene for scenes that depend on it
This commit is contained in:
parent
5ec8d49241
commit
67bd7bfa39
@ -70,6 +70,17 @@ namespace osu.Game.Tests.Visual
|
|||||||
Beatmap.SetDefault();
|
Beatmap.SetDefault();
|
||||||
|
|
||||||
Ruleset = Dependencies.Ruleset;
|
Ruleset = Dependencies.Ruleset;
|
||||||
|
|
||||||
|
var definedRuleset = CreateRuleset()?.RulesetInfo;
|
||||||
|
|
||||||
|
if (definedRuleset != null)
|
||||||
|
{
|
||||||
|
// Set global ruleset bindable to the ruleset defined
|
||||||
|
// for this test scene and disallow changing it.
|
||||||
|
Ruleset.Value = definedRuleset;
|
||||||
|
Ruleset.Disabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
Ruleset.SetDefault();
|
Ruleset.SetDefault();
|
||||||
|
|
||||||
SelectedMods = Dependencies.Mods;
|
SelectedMods = Dependencies.Mods;
|
||||||
@ -124,6 +135,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
protected AudioManager Audio { get; private set; }
|
protected AudioManager Audio { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the ruleset to be used for this test scene.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// When testing against ruleset-specific components, this method must be overriden to their ruleset.
|
||||||
|
/// </remarks>
|
||||||
|
protected virtual Ruleset CreateRuleset() => null;
|
||||||
|
|
||||||
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
||||||
|
|
||||||
protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) =>
|
protected WorkingBeatmap CreateWorkingBeatmap(RulesetInfo ruleset) =>
|
||||||
@ -135,6 +154,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(RulesetStore rulesets)
|
private void load(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
|
if (!Ruleset.Disabled)
|
||||||
Ruleset.Value = rulesets.AvailableRulesets.First();
|
Ruleset.Value = rulesets.AvailableRulesets.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user