diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneStarCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneStarCounter.cs index b002e90bb0..fa17b77b55 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneStarCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneStarCounter.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Utils; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -14,39 +15,47 @@ namespace osu.Game.Tests.Visual.Gameplay public partial class TestSceneStarCounter : OsuTestScene { private readonly StarCounter starCounter; + private readonly StarCounter twentyStarCounter; private readonly OsuSpriteText starsLabel; public TestSceneStarCounter() { - starCounter = new StarCounter + Add(new FillFlowContainer { - Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, - }; - - Add(starCounter); - - starsLabel = new OsuSpriteText - { Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Scale = new Vector2(2), - Y = 50, - }; - - Add(starsLabel); + 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), + }, + } + }); setStars(5); - AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (starCounter.StarCount + 1)), 10); - AddSliderStep("exact value", 0f, 10f, 5f, setStars); - AddStep("stop animation", () => starCounter.StopAnimation()); + AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (twentyStarCounter.StarCount + 1)), 10); + AddSliderStep("exact value", 0f, 20f, 5f, setStars); + AddStep("stop animation", () => + { + starCounter.StopAnimation(); + twentyStarCounter.StopAnimation(); + }); AddStep("reset", () => setStars(0)); } private void setStars(float stars) { starCounter.Current = stars; + twentyStarCounter.Current = stars; starsLabel.Text = starCounter.Current.ToString("0.00"); } } diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index 720f479216..4e9e34d840 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -115,7 +115,7 @@ namespace osu.Game.Graphics.UserInterface star.ClearTransforms(true); - double delay = (current <= newValue ? Math.Max(i - current, 0) : Math.Max(current - 1 - i, 0)) * AnimationDelay; + double delay = Math.Max(current <= newValue ? i - current : Math.Min(current, StarCount) - 1 - i, 0) * AnimationDelay; using (star.BeginDelayedSequence(delay)) star.DisplayAt(getStarScale(i, newValue));