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 override bool CanPopOutWhileRolling => true;
protected virtual double FadeOutDelay => 1000;
protected virtual double FadeOutDuration => 300;
protected override string FormatCount(ulong count) 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; 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> /// <summary>

View File

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

View File

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

View File

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