mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 15:22:55 +08:00
Test scene for mod development
This commit is contained in:
parent
5459b7e7da
commit
089ec4c792
28
osu.Game.Rulesets.Catch.Tests/TestSceneCatchModSandbox.cs
Normal file
28
osu.Game.Rulesets.Catch.Tests/TestSceneCatchModSandbox.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneCatchModSandbox : TestSceneModSandbox
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Append(typeof(TestSceneCatchModSandbox)).ToList();
|
||||
|
||||
public TestSceneCatchModSandbox()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public TestSceneCatchModSandbox(Mod mod = null)
|
||||
: base(new CatchRuleset(), mod)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
28
osu.Game.Rulesets.Mania.Tests/TestSceneManiaModSandbox.cs
Normal file
28
osu.Game.Rulesets.Mania.Tests/TestSceneManiaModSandbox.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneManiaModSandbox : TestSceneModSandbox
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Append(typeof(TestSceneManiaModSandbox)).ToList();
|
||||
|
||||
public TestSceneManiaModSandbox()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public TestSceneManiaModSandbox(Mod mod = null)
|
||||
: base(new ManiaRuleset(), mod)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
{
|
||||
public class TestSceneOsuModDifficultyAdjust : TestSceneOsuModSandbox
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Append(typeof(OsuModDifficultyAdjust)).ToList();
|
||||
|
||||
public TestSceneOsuModDifficultyAdjust()
|
||||
: base(new OsuModDifficultyAdjust())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
28
osu.Game.Rulesets.Osu.Tests/TestSceneOsuModSandbox.cs
Normal file
28
osu.Game.Rulesets.Osu.Tests/TestSceneOsuModSandbox.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneOsuModSandbox : TestSceneModSandbox
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Append(typeof(TestSceneOsuModSandbox)).ToList();
|
||||
|
||||
public TestSceneOsuModSandbox()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public TestSceneOsuModSandbox(Mod mod = null)
|
||||
: base(new OsuRuleset(), mod)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
28
osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoModSandbox.cs
Normal file
28
osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoModSandbox.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneTaikoModSandbox : TestSceneModSandbox
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Append(typeof(TestSceneTaikoModSandbox)).ToList();
|
||||
|
||||
public TestSceneTaikoModSandbox()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public TestSceneTaikoModSandbox(Mod mod = null)
|
||||
: base(new TaikoRuleset(), mod)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep(ruleset.RulesetInfo.Name, loadPlayer);
|
||||
AddStep(ruleset.RulesetInfo.Name, LoadPlayer);
|
||||
AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1);
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected virtual bool Autoplay => false;
|
||||
|
||||
private void loadPlayer()
|
||||
protected void LoadPlayer()
|
||||
{
|
||||
var beatmap = CreateBeatmap(ruleset.RulesetInfo);
|
||||
|
||||
|
108
osu.Game/Tests/Visual/TestSceneModSandbox.cs
Normal file
108
osu.Game/Tests/Visual/TestSceneModSandbox.cs
Normal file
@ -0,0 +1,108 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public abstract class TestSceneModSandbox : PlayerTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TestSceneModSandbox)
|
||||
};
|
||||
|
||||
protected Mod Mod;
|
||||
private readonly TriangleButton button;
|
||||
|
||||
protected TestSceneModSandbox(Ruleset ruleset, Mod mod = null)
|
||||
: base(ruleset)
|
||||
{
|
||||
Mod = mod ?? new SandboxMod();
|
||||
|
||||
var props = Mod.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance);
|
||||
var hasSettings = props.Any(prop => prop.GetCustomAttribute<SettingSourceAttribute>(true) != null);
|
||||
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding(50),
|
||||
Margin = new MarginPadding { Bottom = 20 },
|
||||
Width = 0.4f,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ModControlSection(Mod, Mod.CreateSettingsControls()),
|
||||
button = new TriangleButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.5f,
|
||||
Text = "Start",
|
||||
Action = () =>
|
||||
{
|
||||
button.Text = hasSettings ? "Apply Settings" : "Restart";
|
||||
LoadPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LocalConfig.GetBindable<bool>(OsuSetting.KeyOverlay).Value = true;
|
||||
}
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
SelectedMods.Value = SelectedMods.Value.Append(Mod).ToArray();
|
||||
|
||||
return base.CreatePlayer(ruleset);
|
||||
}
|
||||
|
||||
protected class SandboxMod : Mod
|
||||
{
|
||||
public override string Name => "Sandbox Test";
|
||||
public override string Acronym => "ST";
|
||||
public override double ScoreMultiplier => 1.0;
|
||||
|
||||
[SettingSource("Test Setting")]
|
||||
public Bindable<bool> TestSetting1 { get; } = new BindableBool
|
||||
{
|
||||
Default = true,
|
||||
Value = true
|
||||
};
|
||||
|
||||
[SettingSource("Test Setting 2")]
|
||||
public Bindable<float> TestSetting2 { get; } = new BindableFloat
|
||||
{
|
||||
Precision = 0.1f,
|
||||
MinValue = 0,
|
||||
MaxValue = 20
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user