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;
|
2021-08-18 17:34:09 +08:00
|
|
|
using osu.Framework.Bindables;
|
2021-07-13 10:29:16 +08:00
|
|
|
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
|
|
|
|
{
|
2021-07-17 11:54:11 +08:00
|
|
|
public class TestSceneStarRatingDisplay : OsuTestScene
|
2021-07-13 10:29:16 +08:00
|
|
|
{
|
2021-08-18 16:03:35 +08:00
|
|
|
[TestCase(StarRatingDisplaySize.Regular)]
|
|
|
|
[TestCase(StarRatingDisplaySize.Small)]
|
|
|
|
public void TestDisplay(StarRatingDisplaySize size)
|
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,
|
2021-08-08 06:37:45 +08:00
|
|
|
ChildrenEnumerable = Enumerable.Range(0, 15).Select(i => new FillFlowContainer
|
2021-07-13 10:29:16 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Spacing = new Vector2(2f),
|
|
|
|
Direction = FillDirection.Vertical,
|
2021-08-18 16:03:35 +08:00
|
|
|
ChildrenEnumerable = Enumerable.Range(0, 10).Select(j => new StarRatingDisplay(new StarDifficulty(i * (i >= 11 ? 25f : 1f) + j * 0.1f, 0), size)
|
2021-07-13 10:29:16 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-08-08 06:37:45 +08:00
|
|
|
}),
|
2021-07-13 10:29:16 +08:00
|
|
|
})
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-18 17:34:09 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSpectrum()
|
|
|
|
{
|
|
|
|
StarRatingDisplay starRating = null;
|
|
|
|
|
|
|
|
BindableDouble starRatingNumeric;
|
|
|
|
|
|
|
|
AddStep("load display", () =>
|
|
|
|
{
|
|
|
|
Child = starRating = new StarRatingDisplay(new StarDifficulty(5.55, 1))
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Scale = new Vector2(3f),
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("transform over spectrum", () =>
|
|
|
|
{
|
|
|
|
starRatingNumeric = new BindableDouble();
|
|
|
|
starRatingNumeric.BindValueChanged(val => starRating.Current.Value = new StarDifficulty(val.NewValue, 1));
|
|
|
|
this.TransformBindableTo(starRatingNumeric, 10, 10000, Easing.OutQuint);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-13 10:29:16 +08:00
|
|
|
[Test]
|
2021-08-04 22:06:07 +08:00
|
|
|
public void TestChangingStarRatingDisplay()
|
2021-07-13 10:29:16 +08:00
|
|
|
{
|
2021-07-17 11:54:11 +08:00
|
|
|
StarRatingDisplay starRating = null;
|
2021-07-13 10:29:16 +08:00
|
|
|
|
2021-08-04 22:06:07 +08:00
|
|
|
AddStep("load display", () => Child = starRating = new StarRatingDisplay(new StarDifficulty(5.55, 1))
|
2021-07-13 10:29:16 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2021-07-18 13:21:27 +08:00
|
|
|
Scale = new Vector2(3f),
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|