2016-10-09 00:11:01 +00:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2016-10-12 07:11:40 +00:00
|
|
|
|
using osu.Framework;
|
2016-10-09 00:11:01 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Skeleton for a numeric counter with a simple roll-up animation.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">Type of the actual counter.</typeparam>
|
|
|
|
|
public abstract class NumericRollingCounter<T> : RollingCounter<T>
|
|
|
|
|
{
|
|
|
|
|
protected SpriteText countSpriteText;
|
|
|
|
|
|
|
|
|
|
protected float textSize = 20.0f;
|
|
|
|
|
public float TextSize
|
|
|
|
|
{
|
|
|
|
|
get { return textSize; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
textSize = value;
|
|
|
|
|
updateTextSize();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-12 19:33:04 +00:00
|
|
|
|
protected NumericRollingCounter() : base()
|
2016-10-09 00:11:01 +00:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
countSpriteText = new SpriteText
|
|
|
|
|
{
|
|
|
|
|
TextSize = this.TextSize,
|
|
|
|
|
Anchor = this.Anchor,
|
|
|
|
|
Origin = this.Origin,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-12 19:33:04 +00:00
|
|
|
|
public override void Load(BaseGame game)
|
|
|
|
|
{
|
|
|
|
|
base.Load(game);
|
|
|
|
|
countSpriteText.Text = formatCount(count);
|
|
|
|
|
countSpriteText.Anchor = this.Anchor;
|
|
|
|
|
countSpriteText.Origin = this.Origin;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-09 00:11:01 +00:00
|
|
|
|
protected override void transformVisibleCount(T currentValue, T newValue)
|
|
|
|
|
{
|
2016-10-12 19:38:48 +00:00
|
|
|
|
countSpriteText.Text = formatCount(newValue);
|
2016-10-09 00:11:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void updateTextSize()
|
|
|
|
|
{
|
2016-10-12 19:38:48 +00:00
|
|
|
|
countSpriteText.TextSize = TextSize;
|
2016-10-09 00:11:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|