diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 5f381da0b9..bea2639512 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -42,11 +42,11 @@ namespace osu.Desktop.Tests { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Position = new Vector2(20, 20), + Position = new Vector2(10, 10), InnerCountPosition = new Vector2(10, 10), IsRollingProportional = true, RollingDuration = 20, - PopOutDuration = 3000, + PopOutDuration = 100, Count = 0, TextSize = 40, }; diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index 9b710174ea..ba41854255 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -52,7 +52,7 @@ namespace osu.Game.Graphics.UserInterface removeTransforms(typeof(TransformULongCounter)); VisibleCount = newValue; } - else + else if (currentValue != 0) transformCount(new TransformULongCounter(Clock), currentValue, newValue); } @@ -62,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface return difference * RollingDuration; } - protected virtual void transformAnimate() + protected virtual void transformAnimate(ulong newValue) { countSpriteText.FadeColour(TintColour, 0); countSpriteText.ScaleTo(new Vector2(1, ScaleFactor)); @@ -72,20 +72,15 @@ namespace osu.Game.Graphics.UserInterface protected override void transformVisibleCount(ulong currentValue, ulong newValue) { - if (countSpriteText != null) - { - countSpriteText.Text = newValue.ToString("#,0"); - if (newValue == 0) - { - countSpriteText.FadeOut(TintDuration); - return; - } + countSpriteText.Text = formatCount(newValue); + + if (newValue == 0) + countSpriteText.FadeOut(TintDuration); + else countSpriteText.Show(); - if (newValue > currentValue || CanAnimateWhenBackwards) - { - transformAnimate(); - } - } + + if (newValue > currentValue || CanAnimateWhenBackwards) + transformAnimate(newValue); } } } diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs index 9fb8caa07a..96249be355 100644 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface removeTransforms(typeof(TransformULongCounter)); VisibleCount = newValue; } - else + else if (currentValue != 0) { // Backwards pop-up animation has no tint colour popOutSpriteText.Colour = countSpriteText.Colour; diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index bfb8031ef3..b22fda1070 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -20,7 +20,9 @@ namespace osu.Game.Graphics.UserInterface /// public class StandardComboCounter : ULongCounter { - public SpriteText popOutSpriteText; + protected SpriteText popOutSpriteText; + + protected volatile int scheduledPopOutCurrentId = 0; public ulong PopOutDuration = 0; public float PopOutBigScale = 2.0f; @@ -82,7 +84,7 @@ namespace osu.Game.Graphics.UserInterface removeTransforms(typeof(TransformULongCounter)); VisibleCount = newValue; } - else + else if (currentValue != 0) transformCount(new TransformULongCounter(Clock), currentValue, newValue); } @@ -97,55 +99,61 @@ namespace osu.Game.Graphics.UserInterface return count.ToString("#,0") + "x"; } - protected virtual void transformPopOut(ulong newValue) + protected virtual void transformPopOut(ulong currentValue, ulong newValue) { + popOutSpriteText.Text = formatCount(newValue); + countSpriteText.Text = formatCount(currentValue); + popOutSpriteText.ScaleTo(PopOutBigScale); popOutSpriteText.FadeTo(PopOutInitialAlpha); - popOutSpriteText.Position = Vector2.Zero; + popOutSpriteText.MoveTo(Vector2.Zero); popOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); popOutSpriteText.FadeOut(PopOutDuration, PopOutEasing); popOutSpriteText.MoveTo(countSpriteText.Position, PopOutDuration, PopOutEasing); + scheduledPopOutCurrentId++; + int newTaskId = scheduledPopOutCurrentId; Scheduler.AddDelayed(delegate { - transformPopOutNew(newValue); + scheduledPopOutSmall(newTaskId, newValue); }, PopOutDuration); } - protected virtual void transformPopOutNew(ulong newValue) - { - // Too late; scheduled task invalidated - if (newValue != VisibleCount) - return; + protected virtual void transformNoPopOut(ulong newValue) + { + scheduledPopOutCurrentId++; + countSpriteText.Text = formatCount(newValue); + countSpriteText.ScaleTo(1); + } + protected virtual void transformPopOutSmall(ulong newValue) + { countSpriteText.Text = formatCount(newValue); countSpriteText.ScaleTo(PopOutSmallScale); countSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); } + protected virtual void scheduledPopOutSmall(int id, ulong newValue) + { + // Too late; scheduled task invalidated + if (id != scheduledPopOutCurrentId) + return; + + transformPopOutSmall(newValue); + } + protected override void transformVisibleCount(ulong currentValue, ulong newValue) { - popOutSpriteText.Text = formatCount(newValue); - if (newValue > currentValue) - { - countSpriteText.Text = formatCount(newValue - 1); - - } - else - { - countSpriteText.Text = formatCount(newValue); - } if (newValue == 0) - { countSpriteText.FadeOut(PopOutDuration); - } else - { countSpriteText.Show(); - if (newValue > currentValue || CanPopOutWhenBackwards) - transformPopOut(newValue); - } + + if (newValue > currentValue || CanPopOutWhenBackwards) + transformPopOut(currentValue, newValue); + else + transformNoPopOut(newValue); } } }