From 84dcb63ad2d850f1c881a50a51e95282e5b9ac97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Sat, 15 Oct 2016 18:06:31 -0500 Subject: [PATCH] Changed ComboCounter format... ...to improve value management. --- .../GameModes/Play/Catch/CatchComboCounter.cs | 30 +++++++++- osu.Game/GameModes/Play/ComboCounter.cs | 52 ++++++++++------ .../GameModes/Play/Mania/ManiaComboCounter.cs | 8 +-- .../GameModes/Play/Osu/OsuComboCounter.cs | 59 +++++++++++++------ .../GameModes/Play/Taiko/TaikoComboCounter.cs | 6 +- 5 files changed, 110 insertions(+), 45 deletions(-) diff --git a/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs b/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs index cbd2c27add..1fe70b4dd8 100644 --- a/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs +++ b/osu.Game/GameModes/Play/Catch/CatchComboCounter.cs @@ -18,16 +18,40 @@ namespace osu.Game.GameModes.Play.Catch { protected override bool CanPopOutWhileRolling => true; + protected virtual double FadeOutDelay => 1000; + protected virtual double FadeOutDuration => 300; + protected override string FormatCount(ulong count) { - return $@"{count:#,0}x"; + return $@"{count:#,0}"; } - public override void Roll(ulong newValue = 0) + protected override void OnCountChange(ulong currentValue, ulong newValue) + { + if (newValue != 0) + this.Show(); + base.OnCountChange(currentValue, newValue); + } + + protected override void OnCountRolling(ulong currentValue, ulong newValue) { PopOutSpriteText.Colour = CountSpriteText.Colour; + this.FadeOut(FadeOutDuration); + base.OnCountRolling(currentValue, newValue); + } - base.Roll(newValue); + protected override void OnCountIncrement(ulong currentValue, ulong newValue) + { + this.Show(); + base.OnCountIncrement(currentValue, newValue); + } + + protected override void transformPopOutSmall(ulong newValue) + { + base.transformPopOutSmall(newValue); + CountSpriteText.Delay(FadeOutDelay); + CountSpriteText.FadeOut(FadeOutDuration); + CountSpriteText.DelayReset(); } /// diff --git a/osu.Game/GameModes/Play/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index 6cd166a300..1da5a920cc 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -19,9 +19,10 @@ namespace osu.Game.GameModes.Play { public abstract class ComboCounter : Container { - protected Type transformType => typeof(TransformCombo); - - protected bool IsRolling = false; + public bool IsRolling + { + get; protected set; + } protected SpriteText PopOutSpriteText; @@ -134,6 +135,7 @@ namespace osu.Game.GameModes.Play { base.Load(game); + CountSpriteText.Text = FormatCount(Count); CountSpriteText.Anchor = this.Anchor; CountSpriteText.Origin = this.Origin; @@ -143,10 +145,9 @@ namespace osu.Game.GameModes.Play /// /// Stops rollover animation, forcing the visible count to be the actual count. /// - public virtual void StopRolling() + public void StopRolling() { - Flush(false, typeof(TransformCombo)); - VisibleCount = Count; + setCount(Count); } /// @@ -177,18 +178,34 @@ namespace osu.Game.GameModes.Play return count.ToString(); } - protected abstract void OnCountRolling(ulong currentValue, ulong newValue); - protected abstract void OnCountIncrement(ulong newValue); - protected abstract void OnCountChange(ulong newValue); + 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) - OnCountRolling(currentValue, newValue); + OnVisibleCountRolling(currentValue, newValue); else if (currentValue + 1 == newValue) - OnCountIncrement(newValue); + OnVisibleCountIncrement(newValue); else - OnCountChange(newValue); + OnVisibleCountChange(newValue); + } + + protected virtual void OnCountRolling(ulong currentValue, ulong newValue) + { + IsRolling = true; + transformRoll(new TransformCombo(Clock), currentValue, newValue); + } + + protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) { + VisibleCount = currentValue; + VisibleCount = newValue; + } + + protected virtual void OnCountChange(ulong currentValue, ulong newValue) { + VisibleCount = currentValue; + VisibleCount = newValue; } private void transformCount( @@ -202,14 +219,13 @@ namespace osu.Game.GameModes.Play Flush(false, typeof(TransformCombo)); IsRolling = false; - VisibleCount = currentValue; - VisibleCount = newValue; + if (currentValue + 1 == newValue) + OnCountIncrement(currentValue, newValue); + else + OnCountChange(currentValue, newValue); } else - { - IsRolling = true; - transformRoll(new TransformCombo(Clock), visibleValue, newValue); - } + OnCountRolling(visibleCount, newValue); } private void transformRoll(TransformCombo transform, ulong currentValue, ulong newValue) diff --git a/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs b/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs index ba37e65647..ee5d7da8b9 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs @@ -35,11 +35,11 @@ namespace osu.Game.GameModes.Play.Mania OriginalColour = Colour; } - public override void Roll(ulong newValue = 0) + protected override void OnCountRolling(ulong currentValue, ulong newValue) { - if (!IsRolling) + if (!IsRolling && newValue < currentValue) { - PopOutSpriteText.Text = FormatCount(VisibleCount); + PopOutSpriteText.Text = FormatCount(currentValue); PopOutSpriteText.FadeTo(PopOutInitialAlpha); PopOutSpriteText.ScaleTo(1.0f); @@ -48,7 +48,7 @@ namespace osu.Game.GameModes.Play.Mania PopOutSpriteText.ScaleTo(PopOutScale, PopOutDuration, PopOutEasing); } - base.Roll(newValue); + base.OnCountRolling(currentValue, newValue); } protected override void transformAnimate(ulong newValue) diff --git a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs index 07b7fa7934..2c28cde552 100644 --- a/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs +++ b/osu.Game/GameModes/Play/Osu/OsuComboCounter.cs @@ -21,7 +21,6 @@ namespace osu.Game.GameModes.Play.Osu protected virtual float PopOutSmallScale => 1.1f; protected virtual bool CanPopOutWhileRolling => false; - public Vector2 InnerCountPosition { get @@ -46,13 +45,12 @@ namespace osu.Game.GameModes.Play.Osu protected override string FormatCount(ulong count) { - return $@"{count:#,0}x"; + return $@"{count}x"; } - protected virtual void transformPopOut(ulong currentValue, ulong newValue) + protected virtual void transformPopOut(ulong newValue) { PopOutSpriteText.Text = FormatCount(newValue); - CountSpriteText.Text = FormatCount(currentValue); PopOutSpriteText.ScaleTo(PopOutScale); PopOutSpriteText.FadeTo(PopOutInitialAlpha); @@ -61,18 +59,16 @@ namespace osu.Game.GameModes.Play.Osu PopOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); PopOutSpriteText.FadeOut(PopOutDuration, PopOutEasing); PopOutSpriteText.MoveTo(CountSpriteText.Position, PopOutDuration, PopOutEasing); + } - ScheduledPopOutCurrentId++; - uint newTaskId = ScheduledPopOutCurrentId; - Scheduler.AddDelayed(delegate - { - scheduledPopOutSmall(newTaskId, newValue); - }, PopOutDuration); + protected virtual void transformPopOutRolling(ulong newValue) + { + transformPopOut(newValue); + transformPopOutSmall(newValue); } protected virtual void transformNoPopOut(ulong newValue) { - ScheduledPopOutCurrentId++; CountSpriteText.Text = FormatCount(newValue); CountSpriteText.ScaleTo(1); } @@ -84,16 +80,45 @@ namespace osu.Game.GameModes.Play.Osu CountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); } - protected virtual void scheduledPopOutSmall(uint id, ulong newValue) + protected virtual void scheduledPopOutSmall(uint id) { // Too late; scheduled task invalidated if (id != ScheduledPopOutCurrentId) return; - transformPopOutSmall(newValue); + VisibleCount++; } protected override void OnCountRolling(ulong currentValue, ulong newValue) + { + ScheduledPopOutCurrentId++; + base.OnCountRolling(currentValue, newValue); + } + + protected override void OnCountIncrement(ulong currentValue, ulong newValue) + { + if (VisibleCount != currentValue) + VisibleCount++; + + CountSpriteText.Show(); + + transformPopOut(newValue); + + ScheduledPopOutCurrentId++; + uint newTaskId = ScheduledPopOutCurrentId; + Scheduler.AddDelayed(delegate + { + scheduledPopOutSmall(newTaskId); + }, PopOutDuration); + } + + protected override void OnCountChange(ulong currentValue, ulong newValue) + { + ScheduledPopOutCurrentId++; + base.OnCountChange(currentValue, newValue); + } + + protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue) { if (newValue == 0) CountSpriteText.FadeOut(PopOutDuration); @@ -101,23 +126,23 @@ namespace osu.Game.GameModes.Play.Osu CountSpriteText.Show(); if (CanPopOutWhileRolling) - transformPopOut(currentValue, newValue); + transformPopOutRolling(newValue); else transformNoPopOut(newValue); } - protected override void OnCountChange(ulong newValue) + protected override void OnVisibleCountChange(ulong newValue) { CountSpriteText.FadeTo(newValue == 0 ? 0 : 1); transformNoPopOut(newValue); } - protected override void OnCountIncrement(ulong newValue) + protected override void OnVisibleCountIncrement(ulong newValue) { CountSpriteText.Show(); - transformPopOut(newValue - 1, newValue); + transformPopOutSmall(newValue); } } } diff --git a/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs b/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs index 2e1923ceb5..8614762f95 100644 --- a/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs +++ b/osu.Game/GameModes/Play/Taiko/TaikoComboCounter.cs @@ -40,7 +40,7 @@ namespace osu.Game.GameModes.Play.Taiko CountSpriteText.ScaleTo(1); } - protected override void OnCountRolling(ulong currentValue, ulong newValue) + protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue) { if (newValue == 0) CountSpriteText.FadeOut(AnimationDuration); @@ -50,14 +50,14 @@ namespace osu.Game.GameModes.Play.Taiko transformNotAnimate(newValue); } - protected override void OnCountChange(ulong newValue) + protected override void OnVisibleCountChange(ulong newValue) { CountSpriteText.FadeTo(newValue == 0 ? 0 : 1); transformNotAnimate(newValue); } - protected override void OnCountIncrement(ulong newValue) + protected override void OnVisibleCountIncrement(ulong newValue) { CountSpriteText.Show();