1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 18:23:04 +08:00

Merge pull request #27205 from Joehuu/fix-star-counter-animation-above-10

Fix star counter decrease animation being delayed when current is over displayed star count
This commit is contained in:
Dean Herbert 2024-02-17 18:16:48 +08:00 committed by GitHub
commit 2adc8b15e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 18 deletions

View File

@ -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");
}
}

View File

@ -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));