1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 21:03:21 +08:00

Children creation off-load to ctors

This commit is contained in:
Adonais Romero González 2016-10-12 14:38:48 -05:00
parent 798e7241d8
commit 11e0429fd3
2 changed files with 27 additions and 29 deletions

View File

@ -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;
}
}
}

View File

@ -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();
}
}
}