1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:43:04 +08:00

Use TransformTo in rolling counters

This commit is contained in:
Thomas Müller 2017-07-14 16:46:00 +03:00
parent a5d0bfb02f
commit c73a1ae058
2 changed files with 3 additions and 30 deletions

View File

@ -15,6 +15,7 @@ using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public abstract class RollingCounter<T> : Container, IHasAccentColour public abstract class RollingCounter<T> : Container, IHasAccentColour
where T : struct, IEquatable<T>
{ {
/// <summary> /// <summary>
/// The current value. /// The current value.
@ -193,27 +194,12 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
protected void TransformCount(Transform<T, Drawable> transform, T currentValue, T newValue) protected void TransformCount(Transform<T, Drawable> transform, T currentValue, T newValue)
{ {
Type type = transform.GetType();
Flush(false, type);
if (RollingDuration < 1)
{
DisplayedCount = Current;
return;
}
double rollingTotalDuration = double rollingTotalDuration =
IsRollingProportional IsRollingProportional
? GetProportionalDuration(currentValue, newValue) ? GetProportionalDuration(currentValue, newValue)
: RollingDuration; : RollingDuration;
transform.StartTime = TransformStartTime; TransformTo(newValue, rollingTotalDuration, RollingEasing, transform);
transform.EndTime = TransformStartTime + rollingTotalDuration;
transform.EndValue = newValue;
transform.Easing = RollingEasing;
Transforms.Add(transform);
} }
} }
} }

View File

@ -188,20 +188,7 @@ namespace osu.Game.Screens.Play.HUD
private void transformRoll(TransformComboRoll transform, int currentValue, int newValue) private void transformRoll(TransformComboRoll transform, int currentValue, int newValue)
{ {
Flush(false, typeof(TransformComboRoll)); TransformTo(newValue, getProportionalDuration(currentValue, newValue), RollingEasing, new TransformComboRoll());
if (RollingDuration < 1)
{
DisplayedCount = Current;
return;
}
transform.StartTime = Time.Current;
transform.EndTime = Time.Current + getProportionalDuration(currentValue, newValue);
transform.EndValue = newValue;
transform.Easing = RollingEasing;
Transforms.Add(transform);
} }
protected class TransformComboRoll : Transform<int, Drawable> protected class TransformComboRoll : Transform<int, Drawable>