diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index ba41854255..13dc146a55 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -43,17 +43,23 @@ namespace osu.Game.Graphics.UserInterface SetCountWithoutRolling(0); } - protected override void transformCount(ulong currentValue, ulong newValue) + protected override void transformCount(ulong visibleValue, ulong prevValue, ulong currentValue, ulong newValue) { // Animate rollover only when going backwards if (newValue > currentValue) { updateTransforms(typeof(TransformULongCounter)); removeTransforms(typeof(TransformULongCounter)); + + // If was decreasing, stops roll before increasing + if (currentValue < prevValue) + VisibleCount = currentValue; + VisibleCount = newValue; } - else if (currentValue != 0) - transformCount(new TransformULongCounter(Clock), currentValue, newValue); + // Also, animate only if was not rollbacking already + else if (currentValue > prevValue) + transformCount(new TransformULongCounter(Clock), visibleValue, newValue); } protected override ulong getProportionalDuration(ulong currentValue, ulong newValue) diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs index 96249be355..6f85df9c75 100644 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -25,6 +25,29 @@ namespace osu.Game.Graphics.UserInterface return count.ToString("#,0"); } + protected override void transformCount(ulong visibleValue, ulong prevValue, ulong currentValue, ulong newValue) + { + // Animate rollover only when going backwards + if (newValue > currentValue) + { + updateTransforms(typeof(TransformULongCounter)); + removeTransforms(typeof(TransformULongCounter)); + + // If was decreasing, stops roll before increasing + if (currentValue < prevValue) + VisibleCount = currentValue; + + VisibleCount = newValue; + } + // Also, animate only if was not rollbacking already + else if (currentValue > prevValue) + { + // Backwards pop-up animation has no tint colour + popOutSpriteText.Colour = countSpriteText.Colour; + transformCount(new TransformULongCounter(Clock), visibleValue, newValue); + } + } + protected override void transformCount(ulong currentValue, ulong newValue) { // Animate rollover only when going backwards diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index b26c810497..18826506ca 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -75,6 +75,7 @@ namespace osu.Game.Graphics.UserInterface } } + protected T prevPrevCount; protected T prevCount; protected T count; @@ -89,6 +90,7 @@ namespace osu.Game.Graphics.UserInterface } set { + prevPrevCount = prevCount; prevCount = count; count = value; if (IsLoaded) @@ -97,7 +99,7 @@ namespace osu.Game.Graphics.UserInterface IsRollingProportional ? getProportionalDuration(VisibleCount, value) : RollingDuration; - transformCount(IsRollingContinuous ? VisibleCount : prevCount, value); + transformCount(visibleCount, prevPrevCount, prevCount, value); } } } @@ -183,6 +185,19 @@ namespace osu.Game.Graphics.UserInterface Transforms.RemoveAll(t => t.GetType() == type); } + /// + /// Called when the count is updated to add a transformer that changes the value of the visible count (i.e. + /// implement the rollover animation). + /// + /// Count value currently visible to user. + /// Count value before previous modification. + /// Count value before modification. + /// Expected count value after modification. + protected virtual void transformCount(T visibleValue, T prevValue, T currentValue, T newValue) + { + transformCount(IsRollingContinuous ? visibleValue : currentValue, newValue); + } + /// /// Called when the count is updated to add a transformer that changes the value of the visible count (i.e. /// implement the rollover animation). diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index 36afcea79c..8632535728 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -75,18 +75,23 @@ namespace osu.Game.Graphics.UserInterface popOutSpriteText.TextSize = this.TextSize; } - protected override void transformCount(ulong currentValue, ulong newValue) + protected override void transformCount(ulong visibleValue, ulong prevValue, ulong currentValue, ulong newValue) { // Animate rollover only when going backwards if (newValue > currentValue) { updateTransforms(typeof(TransformULongCounter)); removeTransforms(typeof(TransformULongCounter)); + + // If was decreasing, stops roll before increasing + if (currentValue < prevValue) + VisibleCount = currentValue; + VisibleCount = newValue; } - // Also, ignore rollback if already rollbacking - else if (currentValue != 0) - transformCount(new TransformULongCounter(Clock), currentValue, newValue); + // Also, animate only if was not rollbacking already + else if (currentValue > prevValue) + transformCount(new TransformULongCounter(Clock), visibleValue, newValue); } protected override ulong getProportionalDuration(ulong currentValue, ulong newValue)