osu/osu.Game.Tests/Visual/Colours/TestSceneStarDifficultyColours.cs

91 lines
3.9 KiB
C#
Raw Normal View History

2023-06-22 16:37:25 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2021-07-13 22:04:01 +00:00
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Tests.Visual.Colours
{
2022-11-24 05:32:20 +00:00
public partial class TestSceneStarDifficultyColours : OsuTestScene
2021-07-13 22:04:01 +00:00
{
[Resolved]
2023-06-22 16:37:25 +00:00
private OsuColour colours { get; set; } = null!;
2021-07-13 22:04:01 +00:00
[Test]
public void TestColours()
{
AddStep("load colour displays", () =>
{
Child = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5f),
ChildrenEnumerable = Enumerable.Range(0, 10).Select(i => new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(10f),
ChildrenEnumerable = Enumerable.Range(0, 10).Select(j =>
{
var colour = colours.ForStarDifficulty(1f * i + 0.1f * j);
return new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0f, 10f),
Children = new Drawable[]
{
new CircularContainer
{
Masking = true,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Size = new Vector2(75f, 25f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colour,
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = OsuColour.ForegroundTextColourFor(colour),
Text = colour.ToHex(),
},
}
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = $"*{(1f * i + 0.1f * j):0.00}",
}
}
};
})
})
};
});
}
}
}