2021-10-16 03:44:56 +08: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 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-10-16 03:44:56 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Settings
|
|
|
|
{
|
2023-07-13 12:46:50 +08:00
|
|
|
public partial class TestSceneRevertToDefaultButton : OsuTestScene
|
2021-10-16 03:44:56 +08:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
2021-10-18 12:53:27 +08:00
|
|
|
private float scale = 1;
|
|
|
|
|
|
|
|
private readonly Bindable<float> current = new Bindable<float>
|
|
|
|
{
|
|
|
|
Default = default,
|
|
|
|
Value = 1,
|
|
|
|
};
|
|
|
|
|
2021-10-16 03:44:56 +08:00
|
|
|
[Test]
|
|
|
|
public void TestBasic()
|
|
|
|
{
|
2023-07-13 12:46:50 +08:00
|
|
|
RevertToDefaultButton<float> revertToDefaultButton = null;
|
2021-10-16 03:44:56 +08:00
|
|
|
|
|
|
|
AddStep("create button", () => Child = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-12-10 13:15:00 +08:00
|
|
|
Colour = colours.GreySeaFoam
|
2021-10-16 03:44:56 +08:00
|
|
|
},
|
2023-07-13 12:46:50 +08:00
|
|
|
revertToDefaultButton = new RevertToDefaultButton<float>
|
2021-10-16 03:44:56 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-10-18 12:53:27 +08:00
|
|
|
Scale = new Vector2(scale),
|
|
|
|
Current = current,
|
2021-10-16 03:44:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
AddSliderStep("set scale", 1, 4, 1, scale =>
|
|
|
|
{
|
2021-10-18 12:53:27 +08:00
|
|
|
this.scale = scale;
|
2023-07-13 12:46:50 +08:00
|
|
|
if (revertToDefaultButton != null)
|
|
|
|
revertToDefaultButton.Scale = new Vector2(scale);
|
2021-10-16 03:44:56 +08:00
|
|
|
});
|
2021-10-18 12:53:27 +08:00
|
|
|
AddToggleStep("toggle default state", state => current.Value = state ? default : 1);
|
|
|
|
AddToggleStep("toggle disabled state", state => current.Disabled = state);
|
2021-10-16 03:44:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|