Misc. fixes and improvements

This commit is contained in:
Adonais Romero González
2016-10-16 18:30:25 -05:00
parent a671765a4f
commit 72c4dc344e
7 changed files with 62 additions and 53 deletions

View File

@ -43,7 +43,6 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public virtual EasingTypes RollingEasing => EasingTypes.None;
private T prevDisplayedCount;
private T displayedCount;
/// <summary>
@ -104,18 +103,9 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
protected RollingCounter()
{
Debug.Assert(
TransformType.IsSubclassOf(typeof(Transform<T>)) || TransformType == typeof(Transform<T>),
@"transformType should be a subclass of Transform<T>."
);
Children = new Drawable[]
{
DisplayedCountSpriteText = new SpriteText
{
Anchor = this.Anchor,
Origin = this.Origin,
},
DisplayedCountSpriteText = new SpriteText(),
};
}
@ -195,6 +185,12 @@ namespace osu.Game.Graphics.UserInterface
protected virtual void TransformCount(T currentValue, T newValue)
{
object[] parameters = { Clock };
Debug.Assert(
TransformType.IsSubclassOf(typeof(Transform<T>)) || TransformType == typeof(Transform<T>),
@"transformType should be a subclass of Transform<T>."
);
TransformCount((Transform<T>)Activator.CreateInstance(TransformType, parameters), currentValue, newValue);
}
@ -210,7 +206,7 @@ namespace osu.Game.Graphics.UserInterface
if (Clock == null)
return;
if (RollingDuration == 0)
if (RollingDuration < 1)
{
DisplayedCount = Count;
return;

View File

@ -17,8 +17,8 @@ namespace osu.Game.Graphics.UserInterface
{
public class StarCounter : AutoSizeContainer
{
private Container starContainer;
private List<TextAwesome> stars = new List<TextAwesome>();
private readonly Container starContainer;
private readonly List<TextAwesome> stars = new List<TextAwesome>();
private double transformStartTime = 0;
@ -81,11 +81,17 @@ namespace osu.Game.Graphics.UserInterface
}
}
/// <summary>
/// Shows a float count as stars (up to 10). Used as star difficulty display.
/// </summary>
public StarCounter() : this(10) {
}
/// <summary>
/// Shows a float count as stars. Used as star difficulty display.
/// </summary>
/// <param name="maxstars">Maximum amount of stars to display.</param>
public StarCounter(int maxstars = 10)
public StarCounter(int maxstars)
{
MaxStars = Math.Max(maxstars, 0);
@ -114,6 +120,8 @@ namespace osu.Game.Graphics.UserInterface
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
TextSize = StarSize,
Scale = new Vector2(minStarScale),
Alpha = minStarAlpha,
Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0),
};
@ -122,8 +130,8 @@ namespace osu.Game.Graphics.UserInterface
starContainer.Add(star);
}
// Used to recreate initial state.
StopAnimation();
// Animate initial state from zero.
transformCount(0, Count);
}
public void ResetCount()