From 9ccff6ec489c12e6b631a099d0f3317d609114c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Thu, 13 Oct 2016 19:50:06 -0500 Subject: [PATCH] Tidying up --- .../Tests/TestCaseScoreCounter.cs | 20 ++----------- .../Graphics/UserInterface/AccuracyCounter.cs | 19 +++++++++++-- .../UserInterface/AlternativeComboCounter.cs | 7 +---- .../UserInterface/CatchComboCounter.cs | 4 +-- .../Graphics/UserInterface/ComboCounter.cs | 28 ++++++------------- .../Graphics/UserInterface/RollingCounter.cs | 15 +++------- .../Graphics/UserInterface/ScoreCounter.cs | 5 +++- .../UserInterface/StandardComboCounter.cs | 2 +- .../Graphics/UserInterface/StarCounter.cs | 28 ++++++------------- 9 files changed, 49 insertions(+), 79 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 1e824cf33b..445e4aff78 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -30,8 +30,6 @@ namespace osu.Desktop.Tests Origin = Anchor.TopRight, Anchor = Anchor.TopRight, TextSize = 40, - RollingDuration = 1000, - RollingEasing = EasingTypes.Out, Count = 0, Position = new Vector2(20, 20), }; @@ -43,9 +41,6 @@ namespace osu.Desktop.Tests Anchor = Anchor.BottomLeft, Position = new Vector2(10, 10), InnerCountPosition = new Vector2(10, 10), - IsRollingProportional = true, - RollingDuration = 20, - PopOutDuration = 100, Count = 0, TextSize = 40, }; @@ -55,9 +50,6 @@ namespace osu.Desktop.Tests { Origin = Anchor.Centre, Anchor = Anchor.Centre, - IsRollingProportional = true, - RollingDuration = 20, - PopOutDuration = 100, Count = 0, TextSize = 40, }; @@ -68,9 +60,6 @@ namespace osu.Desktop.Tests Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Position = new Vector2(20, 80), - IsRollingProportional = true, - RollingDuration = 20, - ScaleFactor = 2, Count = 0, TextSize = 40, }; @@ -81,9 +70,6 @@ namespace osu.Desktop.Tests { Origin = Anchor.TopRight, Anchor = Anchor.TopRight, - RollingDuration = 500, - RollingEasing = EasingTypes.Out, - Count = 100.0f, Position = new Vector2(20, 60), }; Add(accuracyCombo); @@ -133,9 +119,9 @@ namespace osu.Desktop.Tests AddButton(@"miss...", delegate { - standardCombo.RollBack(); - alternativeCombo.RollBack(); - catchCombo.RollBack(); + standardCombo.Roll(); + alternativeCombo.Roll(); + catchCombo.Roll(); accuracyCombo.Denominator++; }); diff --git a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs index 32df57d1f0..0d7fcb39c0 100644 --- a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs +++ b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs @@ -1,6 +1,7 @@ //Copyright (c) 2007-2016 ppy Pty Ltd . //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Framework.Timing; @@ -47,6 +48,20 @@ namespace osu.Game.Graphics.UserInterface } } + public AccuracyCounter() + { + RollingDuration = 500; + RollingEasing = EasingTypes.Out; + } + + public override void Load(BaseGame game) + { + base.Load(game); + + updateCount(); + StopRolling(); + } + public void SetCount(long num, ulong den) { numerator = num; @@ -72,9 +87,9 @@ namespace osu.Game.Graphics.UserInterface return count.ToString("0.00") + "%"; } - protected override ulong getProportionalDuration(float currentValue, float newValue) + protected override double getProportionalDuration(float currentValue, float newValue) { - return (ulong)(Math.Abs(currentValue - newValue) * RollingDuration); + return Math.Abs(currentValue - newValue) * RollingDuration; } protected class TransformAccuracy : TransformFloat diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs index 27541c12a3..6e292cdd9d 100644 --- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs @@ -20,7 +20,7 @@ namespace osu.Game.Graphics.UserInterface { public Color4 OriginalColour; public Color4 TintColour = Color4.OrangeRed; - public int TintDuration = 250; + public int TintDuration = 300; public float ScaleFactor = 2; public EasingTypes TintEasing = EasingTypes.None; public bool CanAnimateWhenBackwards = false; @@ -32,11 +32,6 @@ namespace osu.Game.Graphics.UserInterface OriginalColour = Colour; } - public override void ResetCount() - { - SetCountWithoutRolling(0); - } - protected override ulong getProportionalDuration(ulong currentValue, ulong newValue) { ulong difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue; diff --git a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs index 8200ddaa04..b1231585cf 100644 --- a/osu.Game/Graphics/UserInterface/CatchComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/CatchComboCounter.cs @@ -25,11 +25,11 @@ namespace osu.Game.Graphics.UserInterface return count.ToString("#,0"); } - public override void RollBack(ulong newValue = 0) + public override void Roll(ulong newValue = 0) { popOutSpriteText.Colour = countSpriteText.Colour; - base.RollBack(newValue); + base.Roll(newValue); } /// diff --git a/osu.Game/Graphics/UserInterface/ComboCounter.cs b/osu.Game/Graphics/UserInterface/ComboCounter.cs index 07c957257c..c510f02808 100644 --- a/osu.Game/Graphics/UserInterface/ComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/ComboCounter.cs @@ -21,9 +21,9 @@ namespace osu.Game.Graphics.UserInterface { protected Type transformType => typeof(TransformCombo); - private bool rollbacking = false; + private bool rolling = false; - protected ulong rollingTotalDuration = 0; + protected ulong rollingTotalDuration; /// /// If true, the roll-down duration will be proportional to the counter. @@ -34,7 +34,7 @@ namespace osu.Game.Graphics.UserInterface /// 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. /// - public ulong RollingDuration = 0; + public ulong RollingDuration = 20; /// /// Easing for the counter rollover animation. @@ -131,16 +131,6 @@ namespace osu.Game.Graphics.UserInterface StopRolling(); } - /// - /// Sets count value, bypassing rollover animation. - /// - /// New count value. - public virtual void SetCountWithoutRolling(ulong count) - { - Count = count; - StopRolling(); - } - /// /// Stops rollover animation, forcing the visible count to be the actual count. /// @@ -151,14 +141,14 @@ namespace osu.Game.Graphics.UserInterface } /// - /// Animates roll-back to an specific value. + /// Animates roll-up/roll-back to an specific value. /// /// Target value. - public virtual void RollBack(ulong newValue = 0) + public virtual void Roll(ulong newValue = 0) { - rollbacking = true; + rolling = true; Count = newValue; - rollbacking = false; + rolling = false; } /// @@ -166,7 +156,7 @@ namespace osu.Game.Graphics.UserInterface /// public virtual void ResetCount() { - SetCountWithoutRolling(default(ulong)); + Count = default(ulong); } protected virtual ulong getProportionalDuration(ulong currentValue, ulong newValue) @@ -195,7 +185,7 @@ namespace osu.Game.Graphics.UserInterface protected virtual void transformCount(ulong visibleValue, ulong prevValue, ulong currentValue, ulong newValue) { - if (!rollbacking) + if (!rolling) { updateComboTransforms(); removeComboTransforms(); diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 4b7d115ceb..d5054c4d3d 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -25,12 +25,12 @@ namespace osu.Game.Graphics.UserInterface /// protected virtual Type transformType => typeof(Transform); - protected ulong rollingTotalDuration = 0; + protected double rollingTotalDuration = 0; protected SpriteText countSpriteText; /// - /// If true, the roll-up duration will be proportional to the counter. + /// If true, the roll-up duration will be proportional to change in value. /// public bool IsRollingProportional = false; @@ -38,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface /// 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. /// - public ulong RollingDuration = 0; + public double RollingDuration = 0; /// /// Easing for the counter rollover animation. @@ -176,7 +176,7 @@ namespace osu.Game.Graphics.UserInterface /// Current visible value. /// New final value. /// Calculated rollover duration in milliseconds. - protected virtual ulong getProportionalDuration(T currentValue, T newValue) + protected virtual double getProportionalDuration(T currentValue, T newValue) { return RollingDuration; } @@ -209,13 +209,6 @@ namespace osu.Game.Graphics.UserInterface /// /// Count value before modification. /// Expected count value after modification- - /// - /// Unless you need to set a custom animation according to the current or new value of the count, the - /// recommended approach is to call transformCount(CustomTransformer(Clock), currentValue, newValue), where - /// CustomTransformer is of type transformerType. - /// By using this approach, there is no need to check if the Clock is not null; this validation is done before - /// adding the transformer. - /// /// protected virtual void transformCount(T currentValue, T newValue) { diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index a22a403115..5617570243 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -35,6 +35,9 @@ namespace osu.Game.Graphics.UserInterface { countSpriteText.FixedWidth = true; LeadingZeroes = leading; + + RollingDuration = 1000; + RollingEasing = EasingTypes.Out; } public override void Load(BaseGame game) @@ -42,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface base.Load(game); } - protected override ulong getProportionalDuration(ulong currentValue, ulong newValue) + protected override double getProportionalDuration(ulong currentValue, ulong newValue) { return currentValue > newValue ? currentValue - newValue : newValue - currentValue; } diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index 3053542741..30f6bd4b3b 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -24,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface protected uint scheduledPopOutCurrentId = 0; - public ulong PopOutDuration = 0; + public ulong PopOutDuration = 150; public float PopOutBigScale = 2.0f; public float PopOutSmallScale = 1.1f; public EasingTypes PopOutEasing = EasingTypes.None; diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index fcf283d9c1..3592bbb140 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -167,27 +167,15 @@ namespace osu.Game.Graphics.UserInterface private void transformCount(float currentValue, float newValue) { - if (currentValue < newValue) + for (int i = 0; i < MaxStars; i++) { - for (int i = 0; i < MaxStars; i++) - { - stars[i].DelayReset(); - stars[i].ClearTransformations(); - if (i > currentValue) - stars[i].Delay((i - currentValue) * AnimationDelay); - transformStar(i, newValue); - } - } - else - { - for (int i = MaxStars - 1; i >= 0; i--) - { - stars[i].DelayReset(); - stars[i].ClearTransformations(); - if (i < (currentValue - 1)) - stars[i].Delay((currentValue - 1 - i) * AnimationDelay); - transformStar(i, newValue); - } + stars[i].DelayReset(); + stars[i].ClearTransformations(); + if (currentValue <= newValue) + stars[i].Delay(Math.Max(i - currentValue, 0) * AnimationDelay); + else + stars[i].Delay(Math.Max(currentValue - 1 - i, 0) * AnimationDelay); + transformStar(i, newValue); } transformStartTime = Time; }