osu/osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
3.0 KiB
C#
Raw Normal View History

2019-12-06 08:49:52 +00:00
// 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.
2022-06-17 07:37:17 +00:00
#nullable disable
2019-12-06 08:49:52 +00:00
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
2019-12-06 08:49:52 +00:00
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
2019-12-06 08:49:52 +00:00
using osuTK;
namespace osu.Game.Tests.Visual.Settings
{
[TestFixture]
public class TestSceneSettingsSource : OsuTestScene
{
public TestSceneSettingsSource()
{
Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(20),
Width = 0.5f,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Padding = new MarginPadding(50),
ChildrenEnumerable = new TestTargetClass().CreateSettingsControls()
},
};
}
private class TestTargetClass
{
[SettingSource("Sample bool", "Clicking this changes a setting")]
public BindableBool TickBindable { get; } = new BindableBool();
[SettingSource(typeof(TestStrings), nameof(TestStrings.LocalisableLabel), nameof(TestStrings.LocalisableDescription))]
public BindableBool LocalisableBindable { get; } = new BindableBool(true);
2019-12-06 08:49:52 +00:00
[SettingSource("Sample float", "Change something for a mod")]
public BindableFloat SliderBindable { get; } = new BindableFloat
{
MinValue = 0,
MaxValue = 10,
Default = 5,
Value = 7
};
[SettingSource("Sample enum", "Change something for a mod")]
public Bindable<TestEnum> EnumBindable { get; } = new Bindable<TestEnum>
{
Default = TestEnum.Value1,
Value = TestEnum.Value2
};
[SettingSource("Sample string", "Change something for a mod")]
public Bindable<string> StringBindable { get; } = new Bindable<string>
{
Default = string.Empty,
Value = "Sample text"
};
[SettingSource("Sample number textbox", "Textbox number entry", SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> IntTextBoxBindable { get; } = new Bindable<int?>
{
Default = null,
Value = null
};
2019-12-06 08:49:52 +00:00
}
private enum TestEnum
{
Value1,
Value2
}
private class TestStrings
{
public static LocalisableString LocalisableLabel => new LocalisableString("Sample localisable label");
public static LocalisableString LocalisableDescription => new LocalisableString("Sample localisable description");
}
2019-12-06 08:49:52 +00:00
}
}