mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
Improved code
This commit is contained in:
@ -2,6 +2,10 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Timing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,8 +14,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class ScoreCounter : ULongCounter
|
||||
public class ScoreCounter : RollingCounter<ulong>
|
||||
{
|
||||
protected override Type transformType => typeof(TransformScore);
|
||||
|
||||
/// <summary>
|
||||
/// How many leading zeroes the counter has.
|
||||
/// </summary>
|
||||
@ -36,9 +42,40 @@ namespace osu.Game.Graphics.UserInterface
|
||||
base.Load(game);
|
||||
}
|
||||
|
||||
protected override ulong getProportionalDuration(ulong currentValue, ulong newValue)
|
||||
{
|
||||
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||
}
|
||||
|
||||
protected override string formatCount(ulong count)
|
||||
{
|
||||
return count.ToString("D" + LeadingZeroes);
|
||||
}
|
||||
|
||||
protected class TransformScore : Transform<ulong>
|
||||
{
|
||||
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 ScoreCounter).VisibleCount = CurrentValue;
|
||||
}
|
||||
|
||||
public TransformScore(IClock clock)
|
||||
: base(clock)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user