2021-07-13 10:29:16 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
|
|
|
public class TestSceneStarRatingDisplayV2 : OsuTestScene
|
|
|
|
{
|
2021-07-17 10:48:38 +08:00
|
|
|
[TestCase(52f, 20f)]
|
|
|
|
[TestCase(52f, 16f)]
|
|
|
|
[TestCase(50f, 14f)]
|
|
|
|
public void TestDisplay(float width, float height)
|
2021-07-13 10:29:16 +08:00
|
|
|
{
|
|
|
|
AddStep("load displays", () =>
|
|
|
|
{
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Spacing = new Vector2(2f),
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
ChildrenEnumerable = Enumerable.Range(0, 10).Select(i => new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Spacing = new Vector2(2f),
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
ChildrenEnumerable = Enumerable.Range(0, 10).Select(j => new StarRatingDisplayV2(new StarDifficulty(i + j * 0.1f, 0))
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-07-17 10:48:38 +08:00
|
|
|
Size = new Vector2(width, height),
|
2021-07-13 10:29:16 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangingStarRatingDisplay()
|
|
|
|
{
|
|
|
|
StarRatingDisplayV2 starRating = null;
|
|
|
|
|
|
|
|
AddStep("load display", () => Child = starRating = new StarRatingDisplayV2(new StarDifficulty(5.55, 1))
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-07-17 10:48:38 +08:00
|
|
|
Size = new Vector2(52f, 20f),
|
2021-07-13 10:29:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
AddRepeatStep("set random value", () =>
|
|
|
|
{
|
|
|
|
starRating.Current.Value = new StarDifficulty(RNG.NextDouble(0.0, 11.0), 1);
|
|
|
|
}, 10);
|
|
|
|
|
|
|
|
AddSliderStep("set exact stars", 0.0, 11.0, 5.55, d =>
|
|
|
|
{
|
|
|
|
if (starRating != null)
|
|
|
|
starRating.Current.Value = new StarDifficulty(d, 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|