mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 23:12:56 +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:
commit
2adc8b15e7
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -14,39 +15,47 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
public partial class TestSceneStarCounter : OsuTestScene
|
public partial class TestSceneStarCounter : OsuTestScene
|
||||||
{
|
{
|
||||||
private readonly StarCounter starCounter;
|
private readonly StarCounter starCounter;
|
||||||
|
private readonly StarCounter twentyStarCounter;
|
||||||
private readonly OsuSpriteText starsLabel;
|
private readonly OsuSpriteText starsLabel;
|
||||||
|
|
||||||
public TestSceneStarCounter()
|
public TestSceneStarCounter()
|
||||||
{
|
{
|
||||||
starCounter = new StarCounter
|
Add(new FillFlowContainer
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
AutoSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
};
|
Origin = Anchor.Centre,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
Add(starCounter);
|
Spacing = new Vector2(20),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
starCounter = new StarCounter(),
|
||||||
|
twentyStarCounter = new StarCounter(20),
|
||||||
starsLabel = new OsuSpriteText
|
starsLabel = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Anchor = Anchor.TopCentre,
|
||||||
Anchor = Anchor.Centre,
|
Origin = Anchor.TopCentre,
|
||||||
Scale = new Vector2(2),
|
Scale = new Vector2(2),
|
||||||
Y = 50,
|
},
|
||||||
};
|
}
|
||||||
|
});
|
||||||
Add(starsLabel);
|
|
||||||
|
|
||||||
setStars(5);
|
setStars(5);
|
||||||
|
|
||||||
AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (starCounter.StarCount + 1)), 10);
|
AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (twentyStarCounter.StarCount + 1)), 10);
|
||||||
AddSliderStep("exact value", 0f, 10f, 5f, setStars);
|
AddSliderStep("exact value", 0f, 20f, 5f, setStars);
|
||||||
AddStep("stop animation", () => starCounter.StopAnimation());
|
AddStep("stop animation", () =>
|
||||||
|
{
|
||||||
|
starCounter.StopAnimation();
|
||||||
|
twentyStarCounter.StopAnimation();
|
||||||
|
});
|
||||||
AddStep("reset", () => setStars(0));
|
AddStep("reset", () => setStars(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setStars(float stars)
|
private void setStars(float stars)
|
||||||
{
|
{
|
||||||
starCounter.Current = stars;
|
starCounter.Current = stars;
|
||||||
|
twentyStarCounter.Current = stars;
|
||||||
starsLabel.Text = starCounter.Current.ToString("0.00");
|
starsLabel.Text = starCounter.Current.ToString("0.00");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
star.ClearTransforms(true);
|
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))
|
using (star.BeginDelayedSequence(delay))
|
||||||
star.DisplayAt(getStarScale(i, newValue));
|
star.DisplayAt(getStarScale(i, newValue));
|
||||||
|
Loading…
Reference in New Issue
Block a user