1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 04:23:24 +08:00
osu-lazer/osu.Game.Tests/Visual/Gameplay/TestSceneStarCounter.cs

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

63 lines
2.0 KiB
C#
Raw Normal View History

2020-03-09 00:26:19 +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 NUnit.Framework;
using osu.Framework.Graphics;
2024-01-22 10:32:07 +08:00
using osu.Framework.Graphics.Containers;
2020-03-09 00:26:19 +08:00
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Tests.Visual.Gameplay
{
[TestFixture]
public partial class TestSceneStarCounter : OsuTestScene
{
2020-11-29 03:29:35 +08:00
private readonly StarCounter starCounter;
2024-01-22 10:32:07 +08:00
private readonly StarCounter twentyStarCounter;
2020-11-29 03:29:35 +08:00
private readonly OsuSpriteText starsLabel;
2020-03-09 00:26:19 +08:00
public TestSceneStarCounter()
{
2024-01-22 10:32:07 +08:00
Add(new FillFlowContainer
2020-03-09 00:26:19 +08:00
{
2024-01-22 10:32:07 +08:00
AutoSizeAxes = Axes.Both,
2020-03-09 00:26:19 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2024-01-22 10:32:07 +08:00
Direction = FillDirection.Vertical,
Spacing = new Vector2(20),
Children = new Drawable[]
{
starCounter = new StarCounter(),
twentyStarCounter = new StarCounter(20),
starsLabel = new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Scale = new Vector2(2),
},
}
});
2020-03-09 00:26:19 +08:00
2020-11-29 03:29:35 +08:00
setStars(5);
2020-03-09 00:26:19 +08:00
2024-01-22 10:32:07 +08:00
AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (twentyStarCounter.StarCount + 1)), 10);
AddSliderStep("exact value", 0f, 20f, 5f, setStars);
AddStep("stop animation", () =>
{
starCounter.StopAnimation();
twentyStarCounter.StopAnimation();
});
2020-11-29 03:29:35 +08:00
AddStep("reset", () => setStars(0));
}
2020-03-09 00:26:19 +08:00
2020-11-29 03:29:35 +08:00
private void setStars(float stars)
{
starCounter.Current = stars;
2024-01-22 10:32:07 +08:00
twentyStarCounter.Current = stars;
2020-11-29 03:29:35 +08:00
starsLabel.Text = starCounter.Current.ToString("0.00");
2020-03-09 00:26:19 +08:00
}
}
}