diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 3cfd220beb..f1f9e449fd 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -112,6 +112,7 @@ namespace osu.Desktop.Tests { score.Count = 0; standardCombo.Count = 0; + taikoCombo.Count = 0; maniaCombo.Count = 0; catchCombo.Count = 0; numerator = denominator = 0; diff --git a/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs b/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs index 1fe70b4dd8..dc87e65eec 100644 --- a/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs +++ b/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs @@ -26,34 +26,37 @@ namespace osu.Game.GameModes.Play.Catch return $@"{count:#,0}"; } + private void animateFade() + { + Show(); + Delay(FadeOutDelay); + FadeOut(FadeOutDuration); + DelayReset(); + } + protected override void OnCountChange(ulong currentValue, ulong newValue) { if (newValue != 0) - this.Show(); + animateFade(); base.OnCountChange(currentValue, newValue); } protected override void OnCountRolling(ulong currentValue, ulong newValue) { - PopOutSpriteText.Colour = CountSpriteText.Colour; - this.FadeOut(FadeOutDuration); + if (!IsRolling) + { + PopOutSpriteText.Colour = DisplayedCountSpriteText.Colour; + FadeOut(FadeOutDuration); + } base.OnCountRolling(currentValue, newValue); } protected override void OnCountIncrement(ulong currentValue, ulong newValue) { - this.Show(); + animateFade(); base.OnCountIncrement(currentValue, newValue); } - protected override void transformPopOutSmall(ulong newValue) - { - base.transformPopOutSmall(newValue); - CountSpriteText.Delay(FadeOutDelay); - CountSpriteText.FadeOut(FadeOutDuration); - CountSpriteText.DelayReset(); - } - /// /// Increaces counter and tints pop-out before animation. /// diff --git a/osu.Game/GameModes/Play/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index 1da5a920cc..f0ab9107c8 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -32,13 +32,7 @@ namespace osu.Game.GameModes.Play protected virtual float PopOutInitialAlpha => 0.75f; /// - /// If true, the roll-down duration will be proportional to the counter. - /// - protected virtual bool IsRollingProportional => true; - - /// - /// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each - /// element; else duration in milliseconds for the counter roll-up animation in total. + /// Duration in milliseconds for the counter roll-up animation for each element. /// protected virtual double RollingDuration => 20; @@ -47,25 +41,23 @@ namespace osu.Game.GameModes.Play /// protected EasingTypes RollingEasing => EasingTypes.None; - private ulong prevVisibleCount; - private ulong visibleCount; + private ulong prevDisplayedCount; + private ulong displayedCount; /// /// Value shown at the current moment. /// - public virtual ulong VisibleCount + public virtual ulong DisplayedCount { get { - return visibleCount; + return displayedCount; } protected set { - if (visibleCount.Equals(value)) + if (displayedCount.Equals(value)) return; - prevVisibleCount = visibleCount; - visibleCount = value; - transformVisibleCount(prevVisibleCount, visibleCount, IsRolling); + updateDisplayedCount(displayedCount, value, IsRolling); } } @@ -83,21 +75,11 @@ namespace osu.Game.GameModes.Play } set { - setCount(value); + updateCount(value); } } - private void setCount(ulong value, bool rolling = false) - { - prevCount = count; - count = value; - if (IsLoaded) - { - transformCount(VisibleCount, prevCount, value, rolling); - } - } - - protected SpriteText CountSpriteText; + protected SpriteText DisplayedCountSpriteText; private float textSize = 20.0f; public float TextSize @@ -106,7 +88,7 @@ namespace osu.Game.GameModes.Play set { textSize = value; - CountSpriteText.TextSize = TextSize; + DisplayedCountSpriteText.TextSize = TextSize; PopOutSpriteText.TextSize = TextSize; } } @@ -118,7 +100,7 @@ namespace osu.Game.GameModes.Play { Children = new Drawable[] { - CountSpriteText = new SpriteText + DisplayedCountSpriteText = new SpriteText { Anchor = this.Anchor, Origin = this.Origin, @@ -135,19 +117,19 @@ namespace osu.Game.GameModes.Play { base.Load(game); - CountSpriteText.Text = FormatCount(Count); - CountSpriteText.Anchor = this.Anchor; - CountSpriteText.Origin = this.Origin; + DisplayedCountSpriteText.Text = FormatCount(Count); + DisplayedCountSpriteText.Anchor = this.Anchor; + DisplayedCountSpriteText.Origin = this.Origin; StopRolling(); } /// - /// Stops rollover animation, forcing the visible count to be the actual count. + /// Stops rollover animation, forcing the displayed count to be the actual count. /// public void StopRolling() { - setCount(Count); + updateCount(Count); } /// @@ -156,7 +138,7 @@ namespace osu.Game.GameModes.Play /// Target value. public virtual void Roll(ulong newValue = 0) { - setCount(newValue, true); + updateCount(newValue, true); } /// @@ -164,13 +146,7 @@ namespace osu.Game.GameModes.Play /// public virtual void ResetCount() { - Count = default(ulong); - } - - protected double GetProportionalDuration(ulong currentValue, ulong newValue) - { - double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue; - return difference * RollingDuration; + updateCount(0); } protected virtual string FormatCount(ulong count) @@ -178,76 +154,78 @@ namespace osu.Game.GameModes.Play return count.ToString(); } - protected abstract void OnVisibleCountRolling(ulong currentValue, ulong newValue); - protected abstract void OnVisibleCountIncrement(ulong newValue); - protected abstract void OnVisibleCountChange(ulong newValue); - - private void transformVisibleCount(ulong currentValue, ulong newValue, bool rolling) - { - if (rolling) - OnVisibleCountRolling(currentValue, newValue); - else if (currentValue + 1 == newValue) - OnVisibleCountIncrement(newValue); - else - OnVisibleCountChange(newValue); - } + protected abstract void OnDisplayedCountRolling(ulong currentValue, ulong newValue); + protected abstract void OnDisplayedCountIncrement(ulong newValue); + protected abstract void OnDisplayedCountChange(ulong newValue); protected virtual void OnCountRolling(ulong currentValue, ulong newValue) { - IsRolling = true; - transformRoll(new TransformCombo(Clock), currentValue, newValue); + transformRoll(new TransformComboRoll(Clock), currentValue, newValue); } protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) { - VisibleCount = currentValue; - VisibleCount = newValue; + DisplayedCount = newValue; } protected virtual void OnCountChange(ulong currentValue, ulong newValue) { - VisibleCount = currentValue; - VisibleCount = newValue; + DisplayedCount = newValue; } - private void transformCount( - ulong visibleValue, - ulong currentValue, - ulong newValue, - bool rolling) + private double getProportionalDuration(ulong currentValue, ulong newValue) { + double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue; + return difference * RollingDuration; + } + + private void updateDisplayedCount(ulong currentValue, ulong newValue, bool rolling) + { + prevDisplayedCount = currentValue; + displayedCount = newValue; + if (rolling) + OnDisplayedCountRolling(currentValue, newValue); + else if (currentValue + 1 == newValue) + OnDisplayedCountIncrement(newValue); + else + OnDisplayedCountChange(newValue); + } + + private void updateCount(ulong value, bool rolling = false) + { + prevCount = count; + count = value; if (!rolling) { - Flush(false, typeof(TransformCombo)); + Flush(false, typeof(TransformComboRoll)); IsRolling = false; + DisplayedCount = prevCount; - if (currentValue + 1 == newValue) - OnCountIncrement(currentValue, newValue); + if (prevCount + 1 == count) + OnCountIncrement(prevCount, count); else - OnCountChange(currentValue, newValue); + OnCountChange(prevCount, count); } else - OnCountRolling(visibleCount, newValue); + { + OnCountRolling(displayedCount, count); + IsRolling = true; + } } - private void transformRoll(TransformCombo transform, ulong currentValue, ulong newValue) + private void transformRoll(TransformComboRoll transform, ulong currentValue, ulong newValue) { - Flush(false, typeof(TransformCombo)); + Flush(false, typeof(TransformComboRoll)); if (Clock == null) return; if (RollingDuration == 0) { - VisibleCount = Count; + DisplayedCount = Count; return; } - double rollingTotalDuration = - IsRollingProportional - ? GetProportionalDuration(currentValue, newValue) - : RollingDuration; - transform.StartTime = Time; - transform.EndTime = Time + rollingTotalDuration; + transform.EndTime = Time + getProportionalDuration(currentValue, newValue); transform.StartValue = currentValue; transform.EndValue = newValue; transform.Easing = RollingEasing; @@ -255,7 +233,7 @@ namespace osu.Game.GameModes.Play Transforms.Add(transform); } - protected class TransformCombo : Transform + protected class TransformComboRoll : Transform { public override ulong CurrentValue { @@ -272,10 +250,10 @@ namespace osu.Game.GameModes.Play public override void Apply(Drawable d) { base.Apply(d); - (d as ComboCounter).VisibleCount = CurrentValue; + (d as ComboCounter).DisplayedCount = CurrentValue; } - public TransformCombo(IClock clock) + public TransformComboRoll(IClock clock) : base(clock) { } diff --git a/osu.Game/GameModes/Play/ComboResultCounter.cs b/osu.Game/GameModes/Play/ComboResultCounter.cs index c01edc180d..90e40e3077 100644 --- a/osu.Game/GameModes/Play/ComboResultCounter.cs +++ b/osu.Game/GameModes/Play/ComboResultCounter.cs @@ -51,7 +51,7 @@ namespace osu.Game.GameModes.Play.UserInterface public override void Apply(Drawable d) { base.Apply(d); - (d as ComboResultCounter).VisibleCount = CurrentValue; + (d as ComboResultCounter).DisplayedCount = CurrentValue; } public TransformComboResult(IClock clock) diff --git a/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs b/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs index ee5d7da8b9..86349115e9 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs @@ -54,8 +54,8 @@ namespace osu.Game.GameModes.Play.Mania protected override void transformAnimate(ulong newValue) { base.transformAnimate(newValue); - CountSpriteText.FadeColour(TintColour, 0); - CountSpriteText.FadeColour(OriginalColour, AnimationDuration, AnimationEasing); + DisplayedCountSpriteText.FadeColour(TintColour, 0); + DisplayedCountSpriteText.FadeColour(OriginalColour, AnimationDuration, AnimationEasing); } } } diff --git a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs index 2c28cde552..946d672655 100644 --- a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs +++ b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs @@ -25,11 +25,11 @@ namespace osu.Game.GameModes.Play.Osu { get { - return CountSpriteText.Position; + return DisplayedCountSpriteText.Position; } set { - CountSpriteText.Position = value; + DisplayedCountSpriteText.Position = value; } } @@ -58,7 +58,7 @@ namespace osu.Game.GameModes.Play.Osu PopOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); PopOutSpriteText.FadeOut(PopOutDuration, PopOutEasing); - PopOutSpriteText.MoveTo(CountSpriteText.Position, PopOutDuration, PopOutEasing); + PopOutSpriteText.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing); } protected virtual void transformPopOutRolling(ulong newValue) @@ -69,15 +69,15 @@ namespace osu.Game.GameModes.Play.Osu protected virtual void transformNoPopOut(ulong newValue) { - CountSpriteText.Text = FormatCount(newValue); - CountSpriteText.ScaleTo(1); + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(1); } protected virtual void transformPopOutSmall(ulong newValue) { - CountSpriteText.Text = FormatCount(newValue); - CountSpriteText.ScaleTo(PopOutSmallScale); - CountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); + DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); } protected virtual void scheduledPopOutSmall(uint id) @@ -86,7 +86,7 @@ namespace osu.Game.GameModes.Play.Osu if (id != ScheduledPopOutCurrentId) return; - VisibleCount++; + DisplayedCount++; } protected override void OnCountRolling(ulong currentValue, ulong newValue) @@ -97,10 +97,10 @@ namespace osu.Game.GameModes.Play.Osu protected override void OnCountIncrement(ulong currentValue, ulong newValue) { - if (VisibleCount != currentValue) - VisibleCount++; + while (DisplayedCount != currentValue) + DisplayedCount++; - CountSpriteText.Show(); + DisplayedCountSpriteText.Show(); transformPopOut(newValue); @@ -118,12 +118,12 @@ namespace osu.Game.GameModes.Play.Osu base.OnCountChange(currentValue, newValue); } - protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue) + protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) { if (newValue == 0) - CountSpriteText.FadeOut(PopOutDuration); + DisplayedCountSpriteText.FadeOut(PopOutDuration); else - CountSpriteText.Show(); + DisplayedCountSpriteText.Show(); if (CanPopOutWhileRolling) transformPopOutRolling(newValue); @@ -131,16 +131,16 @@ namespace osu.Game.GameModes.Play.Osu transformNoPopOut(newValue); } - protected override void OnVisibleCountChange(ulong newValue) + protected override void OnDisplayedCountChange(ulong newValue) { - CountSpriteText.FadeTo(newValue == 0 ? 0 : 1); + DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); transformNoPopOut(newValue); } - protected override void OnVisibleCountIncrement(ulong newValue) + protected override void OnDisplayedCountIncrement(ulong newValue) { - CountSpriteText.Show(); + DisplayedCountSpriteText.Show(); transformPopOutSmall(newValue); } diff --git a/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs b/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs index 8614762f95..97f050b3e1 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs @@ -23,43 +23,43 @@ namespace osu.Game.GameModes.Play.Taiko public TaikoComboCounter() { - CountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre; - CountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre; + DisplayedCountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre; + DisplayedCountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre; } protected virtual void transformAnimate(ulong newValue) { - CountSpriteText.Text = FormatCount(newValue); - CountSpriteText.ScaleTo(new Vector2(1, ScaleFactor)); - CountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing); + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(new Vector2(1, ScaleFactor)); + DisplayedCountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing); } protected virtual void transformNotAnimate(ulong newValue) { - CountSpriteText.Text = FormatCount(newValue); - CountSpriteText.ScaleTo(1); + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(1); } - protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue) + protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) { if (newValue == 0) - CountSpriteText.FadeOut(AnimationDuration); + DisplayedCountSpriteText.FadeOut(AnimationDuration); else - CountSpriteText.Show(); + DisplayedCountSpriteText.Show(); transformNotAnimate(newValue); } - protected override void OnVisibleCountChange(ulong newValue) + protected override void OnDisplayedCountChange(ulong newValue) { - CountSpriteText.FadeTo(newValue == 0 ? 0 : 1); + DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); transformNotAnimate(newValue); } - protected override void OnVisibleCountIncrement(ulong newValue) + protected override void OnDisplayedCountIncrement(ulong newValue) { - CountSpriteText.Show(); + DisplayedCountSpriteText.Show(); transformAnimate(newValue); } diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 844afaa00e..fe2a5024eb 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -50,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface public override void Apply(Drawable d) { base.Apply(d); - (d as PercentageCounter).VisibleCount = CurrentValue; + (d as PercentageCounter).DisplayedCount = CurrentValue; } public TransformAccuracy(IClock clock) diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 968b5abfa8..8a0e03ad24 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface /// protected virtual Type TransformType => typeof(Transform); - protected SpriteText CountSpriteText; + protected SpriteText DisplayedCountSpriteText; /// /// If true, the roll-up duration will be proportional to change in value. @@ -43,24 +43,24 @@ namespace osu.Game.Graphics.UserInterface /// public virtual EasingTypes RollingEasing => EasingTypes.None; - private T prevVisibleCount; - private T visibleCount; + private T prevDisplayedCount; + private T displayedCount; /// /// Value shown at the current moment. /// - public virtual T VisibleCount + public virtual T DisplayedCount { get { - return visibleCount; + return displayedCount; } protected set { - if (visibleCount.Equals(value)) + if (displayedCount.Equals(value)) return; - visibleCount = value; - CountSpriteText.Text = FormatCount(value); + displayedCount = value; + DisplayedCountSpriteText.Text = FormatCount(value); } } @@ -82,7 +82,7 @@ namespace osu.Game.Graphics.UserInterface count = value; if (IsLoaded) { - TransformCount(visibleCount, count); + TransformCount(displayedCount, count); } } } @@ -95,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface set { textSize = value; - CountSpriteText.TextSize = value; + DisplayedCountSpriteText.TextSize = value; } } @@ -111,7 +111,7 @@ namespace osu.Game.Graphics.UserInterface Children = new Drawable[] { - CountSpriteText = new SpriteText + DisplayedCountSpriteText = new SpriteText { Anchor = this.Anchor, Origin = this.Origin, @@ -125,11 +125,11 @@ namespace osu.Game.Graphics.UserInterface Flush(false, TransformType); - VisibleCount = Count; + DisplayedCount = Count; - CountSpriteText.Text = FormatCount(count); - CountSpriteText.Anchor = this.Anchor; - CountSpriteText.Origin = this.Origin; + DisplayedCountSpriteText.Text = FormatCount(count); + DisplayedCountSpriteText.Anchor = this.Anchor; + DisplayedCountSpriteText.Origin = this.Origin; } /// @@ -143,12 +143,12 @@ namespace osu.Game.Graphics.UserInterface } /// - /// Stops rollover animation, forcing the visible count to be the actual count. + /// Stops rollover animation, forcing the displayed count to be the actual count. /// public virtual void StopRolling() { Flush(false, TransformType); - VisibleCount = Count; + DisplayedCount = Count; } /// @@ -212,7 +212,7 @@ namespace osu.Game.Graphics.UserInterface if (RollingDuration == 0) { - VisibleCount = Count; + DisplayedCount = Count; return; } diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index a47aca738e..b565107f55 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface /// How many leading zeroes the counter will have. public ScoreCounter(uint leading = 0) { - CountSpriteText.FixedWidth = true; + DisplayedCountSpriteText.FixedWidth = true; LeadingZeroes = leading; } @@ -66,7 +66,7 @@ namespace osu.Game.Graphics.UserInterface public override void Apply(Drawable d) { base.Apply(d); - (d as ScoreCounter).VisibleCount = CurrentValue; + (d as ScoreCounter).DisplayedCount = CurrentValue; } public TransformScore(IClock clock) diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index e6874d7b9b..732c882540 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -84,10 +84,10 @@ namespace osu.Game.Graphics.UserInterface /// /// Shows a float count as stars. Used as star difficulty display. /// - /// Maximum amount of stars to display. - public StarCounter(int stars = 10) + /// Maximum amount of stars to display. + public StarCounter(int maxstars = 10) { - MaxStars = Math.Max(stars, 0); + MaxStars = Math.Max(maxstars, 0); Children = new Drawable[] {