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

Changed ComboCounter format...

...to improve value management.
This commit is contained in:
Adonais Romero González 2016-10-15 18:06:31 -05:00
parent 10b47859c3
commit 84dcb63ad2
5 changed files with 110 additions and 45 deletions

View File

@ -18,16 +18,40 @@ namespace osu.Game.GameModes.Play.Catch
{
protected override bool CanPopOutWhileRolling => true;
protected virtual double FadeOutDelay => 1000;
protected virtual double FadeOutDuration => 300;
protected override string FormatCount(ulong count)
{
return $@"{count:#,0}x";
return $@"{count:#,0}";
}
public override void Roll(ulong newValue = 0)
protected override void OnCountChange(ulong currentValue, ulong newValue)
{
if (newValue != 0)
this.Show();
base.OnCountChange(currentValue, newValue);
}
protected override void OnCountRolling(ulong currentValue, ulong newValue)
{
PopOutSpriteText.Colour = CountSpriteText.Colour;
this.FadeOut(FadeOutDuration);
base.OnCountRolling(currentValue, newValue);
}
base.Roll(newValue);
protected override void OnCountIncrement(ulong currentValue, ulong newValue)
{
this.Show();
base.OnCountIncrement(currentValue, newValue);
}
protected override void transformPopOutSmall(ulong newValue)
{
base.transformPopOutSmall(newValue);
CountSpriteText.Delay(FadeOutDelay);
CountSpriteText.FadeOut(FadeOutDuration);
CountSpriteText.DelayReset();
}
/// <summary>

View File

@ -19,9 +19,10 @@ namespace osu.Game.GameModes.Play
{
public abstract class ComboCounter : Container
{
protected Type transformType => typeof(TransformCombo);
protected bool IsRolling = false;
public bool IsRolling
{
get; protected set;
}
protected SpriteText PopOutSpriteText;
@ -134,6 +135,7 @@ namespace osu.Game.GameModes.Play
{
base.Load(game);
CountSpriteText.Text = FormatCount(Count);
CountSpriteText.Anchor = this.Anchor;
CountSpriteText.Origin = this.Origin;
@ -143,10 +145,9 @@ namespace osu.Game.GameModes.Play
/// <summary>
/// Stops rollover animation, forcing the visible count to be the actual count.
/// </summary>
public virtual void StopRolling()
public void StopRolling()
{
Flush(false, typeof(TransformCombo));
VisibleCount = Count;
setCount(Count);
}
/// <summary>
@ -177,18 +178,34 @@ namespace osu.Game.GameModes.Play
return count.ToString();
}
protected abstract void OnCountRolling(ulong currentValue, ulong newValue);
protected abstract void OnCountIncrement(ulong newValue);
protected abstract void OnCountChange(ulong newValue);
protected abstract void OnVisibleCountRolling(ulong currentValue, ulong newValue);
protected abstract void OnVisibleCountIncrement(ulong newValue);
protected abstract void OnVisibleCountChange(ulong newValue);
private void transformVisibleCount(ulong currentValue, ulong newValue, bool rolling)
{
if (rolling)
OnCountRolling(currentValue, newValue);
OnVisibleCountRolling(currentValue, newValue);
else if (currentValue + 1 == newValue)
OnCountIncrement(newValue);
OnVisibleCountIncrement(newValue);
else
OnCountChange(newValue);
OnVisibleCountChange(newValue);
}
protected virtual void OnCountRolling(ulong currentValue, ulong newValue)
{
IsRolling = true;
transformRoll(new TransformCombo(Clock), currentValue, newValue);
}
protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) {
VisibleCount = currentValue;
VisibleCount = newValue;
}
protected virtual void OnCountChange(ulong currentValue, ulong newValue) {
VisibleCount = currentValue;
VisibleCount = newValue;
}
private void transformCount(
@ -202,14 +219,13 @@ namespace osu.Game.GameModes.Play
Flush(false, typeof(TransformCombo));
IsRolling = false;
VisibleCount = currentValue;
VisibleCount = newValue;
if (currentValue + 1 == newValue)
OnCountIncrement(currentValue, newValue);
else
OnCountChange(currentValue, newValue);
}
else
{
IsRolling = true;
transformRoll(new TransformCombo(Clock), visibleValue, newValue);
}
OnCountRolling(visibleCount, newValue);
}
private void transformRoll(TransformCombo transform, ulong currentValue, ulong newValue)

View File

@ -35,11 +35,11 @@ namespace osu.Game.GameModes.Play.Mania
OriginalColour = Colour;
}
public override void Roll(ulong newValue = 0)
protected override void OnCountRolling(ulong currentValue, ulong newValue)
{
if (!IsRolling)
if (!IsRolling && newValue < currentValue)
{
PopOutSpriteText.Text = FormatCount(VisibleCount);
PopOutSpriteText.Text = FormatCount(currentValue);
PopOutSpriteText.FadeTo(PopOutInitialAlpha);
PopOutSpriteText.ScaleTo(1.0f);
@ -48,7 +48,7 @@ namespace osu.Game.GameModes.Play.Mania
PopOutSpriteText.ScaleTo(PopOutScale, PopOutDuration, PopOutEasing);
}
base.Roll(newValue);
base.OnCountRolling(currentValue, newValue);
}
protected override void transformAnimate(ulong newValue)

View File

@ -21,7 +21,6 @@ namespace osu.Game.GameModes.Play.Osu
protected virtual float PopOutSmallScale => 1.1f;
protected virtual bool CanPopOutWhileRolling => false;
public Vector2 InnerCountPosition
{
get
@ -46,13 +45,12 @@ namespace osu.Game.GameModes.Play.Osu
protected override string FormatCount(ulong count)
{
return $@"{count:#,0}x";
return $@"{count}x";
}
protected virtual void transformPopOut(ulong currentValue, ulong newValue)
protected virtual void transformPopOut(ulong newValue)
{
PopOutSpriteText.Text = FormatCount(newValue);
CountSpriteText.Text = FormatCount(currentValue);
PopOutSpriteText.ScaleTo(PopOutScale);
PopOutSpriteText.FadeTo(PopOutInitialAlpha);
@ -61,18 +59,16 @@ namespace osu.Game.GameModes.Play.Osu
PopOutSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
PopOutSpriteText.FadeOut(PopOutDuration, PopOutEasing);
PopOutSpriteText.MoveTo(CountSpriteText.Position, PopOutDuration, PopOutEasing);
}
ScheduledPopOutCurrentId++;
uint newTaskId = ScheduledPopOutCurrentId;
Scheduler.AddDelayed(delegate
{
scheduledPopOutSmall(newTaskId, newValue);
}, PopOutDuration);
protected virtual void transformPopOutRolling(ulong newValue)
{
transformPopOut(newValue);
transformPopOutSmall(newValue);
}
protected virtual void transformNoPopOut(ulong newValue)
{
ScheduledPopOutCurrentId++;
CountSpriteText.Text = FormatCount(newValue);
CountSpriteText.ScaleTo(1);
}
@ -84,16 +80,45 @@ namespace osu.Game.GameModes.Play.Osu
CountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
}
protected virtual void scheduledPopOutSmall(uint id, ulong newValue)
protected virtual void scheduledPopOutSmall(uint id)
{
// Too late; scheduled task invalidated
if (id != ScheduledPopOutCurrentId)
return;
transformPopOutSmall(newValue);
VisibleCount++;
}
protected override void OnCountRolling(ulong currentValue, ulong newValue)
{
ScheduledPopOutCurrentId++;
base.OnCountRolling(currentValue, newValue);
}
protected override void OnCountIncrement(ulong currentValue, ulong newValue)
{
if (VisibleCount != currentValue)
VisibleCount++;
CountSpriteText.Show();
transformPopOut(newValue);
ScheduledPopOutCurrentId++;
uint newTaskId = ScheduledPopOutCurrentId;
Scheduler.AddDelayed(delegate
{
scheduledPopOutSmall(newTaskId);
}, PopOutDuration);
}
protected override void OnCountChange(ulong currentValue, ulong newValue)
{
ScheduledPopOutCurrentId++;
base.OnCountChange(currentValue, newValue);
}
protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue)
{
if (newValue == 0)
CountSpriteText.FadeOut(PopOutDuration);
@ -101,23 +126,23 @@ namespace osu.Game.GameModes.Play.Osu
CountSpriteText.Show();
if (CanPopOutWhileRolling)
transformPopOut(currentValue, newValue);
transformPopOutRolling(newValue);
else
transformNoPopOut(newValue);
}
protected override void OnCountChange(ulong newValue)
protected override void OnVisibleCountChange(ulong newValue)
{
CountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
transformNoPopOut(newValue);
}
protected override void OnCountIncrement(ulong newValue)
protected override void OnVisibleCountIncrement(ulong newValue)
{
CountSpriteText.Show();
transformPopOut(newValue - 1, newValue);
transformPopOutSmall(newValue);
}
}
}

View File

@ -40,7 +40,7 @@ namespace osu.Game.GameModes.Play.Taiko
CountSpriteText.ScaleTo(1);
}
protected override void OnCountRolling(ulong currentValue, ulong newValue)
protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue)
{
if (newValue == 0)
CountSpriteText.FadeOut(AnimationDuration);
@ -50,14 +50,14 @@ namespace osu.Game.GameModes.Play.Taiko
transformNotAnimate(newValue);
}
protected override void OnCountChange(ulong newValue)
protected override void OnVisibleCountChange(ulong newValue)
{
CountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
transformNotAnimate(newValue);
}
protected override void OnCountIncrement(ulong newValue)
protected override void OnVisibleCountIncrement(ulong newValue)
{
CountSpriteText.Show();