mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Improvements in transformCount handling
This commit is contained in:
parent
bf832ebe71
commit
55420d4356
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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).
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user