2016-10-07 15:24:46 +08:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-07 15:05:02 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
|
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2016-10-08 05:14:35 +08:00
|
|
|
|
/// A simple rolling counter that accepts unsigned long values.
|
2016-10-07 15:05:02 +08:00
|
|
|
|
/// </summary>
|
2016-10-09 08:11:01 +08:00
|
|
|
|
public class ULongCounter : NumericRollingCounter<ulong>
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
2016-10-08 05:59:52 +08:00
|
|
|
|
protected override Type transformType => typeof(TransformULongCounter);
|
2016-10-07 15:05:02 +08:00
|
|
|
|
|
|
|
|
|
public override void ResetCount()
|
|
|
|
|
{
|
|
|
|
|
SetCountWithoutRolling(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string formatCount(ulong count)
|
|
|
|
|
{
|
|
|
|
|
return count.ToString("#,0");
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 05:59:52 +08:00
|
|
|
|
protected class TransformULongCounter : Transform<ulong>
|
2016-10-07 15:05:02 +08:00
|
|
|
|
{
|
|
|
|
|
public override ulong CurrentValue
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
double time = Time;
|
|
|
|
|
if (time < StartTime) return StartValue;
|
|
|
|
|
if (time >= EndTime) return EndValue;
|
|
|
|
|
|
|
|
|
|
return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Apply(Drawable d)
|
|
|
|
|
{
|
|
|
|
|
base.Apply(d);
|
|
|
|
|
(d as ULongCounter).VisibleCount = CurrentValue;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 05:59:52 +08:00
|
|
|
|
public TransformULongCounter(IClock clock)
|
2016-10-07 15:05:02 +08:00
|
|
|
|
: base(clock)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|