From 11e0429fd3f037186fe47df46f680078babb33a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adonais=20Romero=20Gonz=C3=A1lez?= Date: Wed, 12 Oct 2016 14:38:48 -0500 Subject: [PATCH] Children creation off-load to ctors --- .../UserInterface/NumericRollingCounter.cs | 8 +--- .../UserInterface/StandardComboCounter.cs | 48 ++++++++++--------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs b/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs index 1710ce9515..aa9aee3919 100644 --- a/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs @@ -55,16 +55,12 @@ namespace osu.Game.Graphics.UserInterface protected override void transformVisibleCount(T currentValue, T newValue) { - if (countSpriteText != null) - { - countSpriteText.Text = formatCount(newValue); - } + countSpriteText.Text = formatCount(newValue); } protected virtual void updateTextSize() { - if (countSpriteText != null) - countSpriteText.TextSize = TextSize; + countSpriteText.TextSize = TextSize; } } } diff --git a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs index 676e3672d2..f4f36f1e21 100644 --- a/osu.Game/Graphics/UserInterface/StandardComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/StandardComboCounter.cs @@ -29,28 +29,33 @@ namespace osu.Game.Graphics.UserInterface public StandardComboCounter() : base() { IsRollingContinuous = false; + + countSpriteText.Alpha = 0; + + popOutSpriteText = new SpriteText + { + Origin = this.Origin, + Anchor = this.Anchor, + TextSize = this.TextSize, + Alpha = 0, + }; } public override void Load(BaseGame game) { base.Load(game); - countSpriteText.Alpha = 0; - Add(popOutSpriteText = new SpriteText - { - Text = formatCount(Count), - Origin = this.Origin, - Anchor = this.Anchor, - TextSize = this.TextSize, - Alpha = 0, - }); + popOutSpriteText.Origin = this.Origin; + popOutSpriteText.Anchor = this.Anchor; + + Add(popOutSpriteText); } protected override void updateTextSize() { base.updateTextSize(); - if (popOutSpriteText != null) - popOutSpriteText.TextSize = this.TextSize; + + popOutSpriteText.TextSize = this.TextSize; } @@ -91,19 +96,16 @@ namespace osu.Game.Graphics.UserInterface protected override void transformVisibleCount(ulong currentValue, ulong newValue) { - if (countSpriteText != null && popOutSpriteText != null) + countSpriteText.Text = popOutSpriteText.Text = formatCount(newValue); + if (newValue == 0) { - countSpriteText.Text = popOutSpriteText.Text = formatCount(newValue); - if (newValue == 0) - { - countSpriteText.FadeOut(PopOutDuration); - } - else - { - countSpriteText.Show(); - if (newValue > currentValue || CanPopOutWhenBackwards) - transformPopOut(); - } + countSpriteText.FadeOut(PopOutDuration); + } + else + { + countSpriteText.Show(); + if (newValue > currentValue || CanPopOutWhenBackwards) + transformPopOut(); } } }