1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Improvements in transformCount handling

This commit is contained in:
Adonais Romero González 2016-10-12 21:33:55 -05:00
parent bf832ebe71
commit 55420d4356
4 changed files with 57 additions and 8 deletions

View File

@ -43,17 +43,23 @@ namespace osu.Game.Graphics.UserInterface
SetCountWithoutRolling(0);
}
protected override void transformCount(ulong currentValue, ulong newValue)
protected override void transformCount(ulong visibleValue, ulong prevValue, ulong currentValue, ulong newValue)
{
// Animate rollover only when going backwards
if (newValue > currentValue)
{
updateTransforms(typeof(TransformULongCounter));
removeTransforms(typeof(TransformULongCounter));
// If was decreasing, stops roll before increasing
if (currentValue < prevValue)
VisibleCount = currentValue;
VisibleCount = newValue;
}
else if (currentValue != 0)
transformCount(new TransformULongCounter(Clock), currentValue, newValue);
// Also, animate only if was not rollbacking already
else if (currentValue > prevValue)
transformCount(new TransformULongCounter(Clock), visibleValue, newValue);
}
protected override ulong getProportionalDuration(ulong currentValue, ulong newValue)

View File

@ -25,6 +25,29 @@ namespace osu.Game.Graphics.UserInterface
return count.ToString("#,0");
}
protected override void transformCount(ulong visibleValue, ulong prevValue, ulong currentValue, ulong newValue)
{
// Animate rollover only when going backwards
if (newValue > currentValue)
{
updateTransforms(typeof(TransformULongCounter));
removeTransforms(typeof(TransformULongCounter));
// If was decreasing, stops roll before increasing
if (currentValue < prevValue)
VisibleCount = currentValue;
VisibleCount = newValue;
}
// Also, animate only if was not rollbacking already
else if (currentValue > prevValue)
{
// Backwards pop-up animation has no tint colour
popOutSpriteText.Colour = countSpriteText.Colour;
transformCount(new TransformULongCounter(Clock), visibleValue, newValue);
}
}
protected override void transformCount(ulong currentValue, ulong newValue)
{
// Animate rollover only when going backwards

View File

@ -75,6 +75,7 @@ namespace osu.Game.Graphics.UserInterface
}
}
protected T prevPrevCount;
protected T prevCount;
protected T count;
@ -89,6 +90,7 @@ namespace osu.Game.Graphics.UserInterface
}
set
{
prevPrevCount = prevCount;
prevCount = count;
count = value;
if (IsLoaded)
@ -97,7 +99,7 @@ namespace osu.Game.Graphics.UserInterface
IsRollingProportional
? getProportionalDuration(VisibleCount, value)
: RollingDuration;
transformCount(IsRollingContinuous ? VisibleCount : prevCount, value);
transformCount(visibleCount, prevPrevCount, prevCount, value);
}
}
}
@ -183,6 +185,19 @@ namespace osu.Game.Graphics.UserInterface
Transforms.RemoveAll(t => t.GetType() == type);
}
/// <summary>
/// Called when the count is updated to add a transformer that changes the value of the visible count (i.e.
/// implement the rollover animation).
/// </summary>
/// <param name="visibleValue">Count value currently visible to user.</param>
/// <param name="currentValue">Count value before previous modification.</param>
/// <param name="currentValue">Count value before modification.</param>
/// <param name="newValue">Expected count value after modification.</param>
protected virtual void transformCount(T visibleValue, T prevValue, T currentValue, T newValue)
{
transformCount(IsRollingContinuous ? visibleValue : currentValue, newValue);
}
/// <summary>
/// Called when the count is updated to add a transformer that changes the value of the visible count (i.e.
/// implement the rollover animation).

View File

@ -75,18 +75,23 @@ namespace osu.Game.Graphics.UserInterface
popOutSpriteText.TextSize = this.TextSize;
}
protected override void transformCount(ulong currentValue, ulong newValue)
protected override void transformCount(ulong visibleValue, ulong prevValue, ulong currentValue, ulong newValue)
{
// Animate rollover only when going backwards
if (newValue > currentValue)
{
updateTransforms(typeof(TransformULongCounter));
removeTransforms(typeof(TransformULongCounter));
// If was decreasing, stops roll before increasing
if (currentValue < prevValue)
VisibleCount = currentValue;
VisibleCount = newValue;
}
// Also, ignore rollback if already rollbacking
else if (currentValue != 0)
transformCount(new TransformULongCounter(Clock), currentValue, newValue);
// Also, animate only if was not rollbacking already
else if (currentValue > prevValue)
transformCount(new TransformULongCounter(Clock), visibleValue, newValue);
}
protected override ulong getProportionalDuration(ulong currentValue, ulong newValue)