1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 03:22:59 +08:00

Make counters work again

This commit is contained in:
Adonais Romero González 2016-10-12 14:33:04 -05:00
parent 8dadc2b215
commit 798e7241d8
4 changed files with 19 additions and 11 deletions

View File

@ -32,15 +32,12 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
public override void Load(BaseGame game) protected NumericRollingCounter() : base()
{ {
base.Load(game);
Children = new Drawable[] Children = new Drawable[]
{ {
countSpriteText = new SpriteText countSpriteText = new SpriteText
{ {
Text = formatCount(Count),
TextSize = this.TextSize, TextSize = this.TextSize,
Anchor = this.Anchor, Anchor = this.Anchor,
Origin = this.Origin, Origin = this.Origin,
@ -48,6 +45,14 @@ namespace osu.Game.Graphics.UserInterface
}; };
} }
public override void Load(BaseGame game)
{
base.Load(game);
countSpriteText.Text = formatCount(count);
countSpriteText.Anchor = this.Anchor;
countSpriteText.Origin = this.Origin;
}
protected override void transformVisibleCount(T currentValue, T newValue) protected override void transformVisibleCount(T currentValue, T newValue)
{ {
if (countSpriteText != null) if (countSpriteText != null)

View File

@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface
/// In order to show a value, you must implement a way to display it, i.e., as a numeric counter or a bar. /// In order to show a value, you must implement a way to display it, i.e., as a numeric counter or a bar.
/// </remarks> /// </remarks>
/// <typeparam name="T">Type of the actual counter.</typeparam> /// <typeparam name="T">Type of the actual counter.</typeparam>
public abstract class RollingCounter<T> : Container public abstract class RollingCounter<T> : AutoSizeContainer
{ {
/// <summary> /// <summary>
/// Type of the Transform to use. /// Type of the Transform to use.
@ -91,7 +91,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
prevCount = count; prevCount = count;
count = value; count = value;
if (Clock != null) if (IsLoaded)
{ {
RollingTotalDuration = RollingTotalDuration =
IsRollingProportional IsRollingProportional
@ -102,7 +102,7 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
protected RollingCounter() protected RollingCounter() : base()
{ {
Debug.Assert( Debug.Assert(
transformType.IsSubclassOf(typeof(Transform<T>)) || transformType == typeof(Transform<T>), transformType.IsSubclassOf(typeof(Transform<T>)) || transformType == typeof(Transform<T>),
@ -113,7 +113,9 @@ namespace osu.Game.Graphics.UserInterface
public override void Load(BaseGame game) public override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
removeTransforms(transformType); removeTransforms(transformType);
if (Count == null) if (Count == null)
ResetCount(); ResetCount();
VisibleCount = Count; VisibleCount = Count;

View File

@ -17,11 +17,14 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
public uint LeadingZeroes = 0; public uint LeadingZeroes = 0;
public ScoreCounter() : base()
{
countSpriteText.FixedWidth = true;
}
public override void Load(BaseGame game) public override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
countSpriteText.FixedWidth = true;
} }
protected override string formatCount(ulong count) protected override string formatCount(ulong count)

View File

@ -128,8 +128,6 @@ namespace osu.Game.Graphics.UserInterface
protected void transformStarAlpha(int i, TransformAlpha transform, bool isIncrement, double startTime) protected void transformStarAlpha(int i, TransformAlpha transform, bool isIncrement, double startTime)
{ {
transform.StartTime = startTime; transform.StartTime = startTime;
//if (!isIncrement)
//transform.StartTime += StarAnimationDuration - FadeDuration;
transform.EndTime = transform.StartTime + FadeDuration; transform.EndTime = transform.StartTime + FadeDuration;
transform.StartValue = stars[i].Alpha; transform.StartValue = stars[i].Alpha;
transform.EndValue = i < Count ? 1.0f : MinStarAlpha; transform.EndValue = i < Count ? 1.0f : MinStarAlpha;