mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Tidying code and restricting methods
This commit is contained in:
parent
84dcb63ad2
commit
862dc1d7c7
@ -112,6 +112,7 @@ namespace osu.Desktop.Tests
|
|||||||
{
|
{
|
||||||
score.Count = 0;
|
score.Count = 0;
|
||||||
standardCombo.Count = 0;
|
standardCombo.Count = 0;
|
||||||
|
taikoCombo.Count = 0;
|
||||||
maniaCombo.Count = 0;
|
maniaCombo.Count = 0;
|
||||||
catchCombo.Count = 0;
|
catchCombo.Count = 0;
|
||||||
numerator = denominator = 0;
|
numerator = denominator = 0;
|
||||||
|
@ -26,34 +26,37 @@ namespace osu.Game.GameModes.Play.Catch
|
|||||||
return $@"{count:#,0}";
|
return $@"{count:#,0}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void animateFade()
|
||||||
|
{
|
||||||
|
Show();
|
||||||
|
Delay(FadeOutDelay);
|
||||||
|
FadeOut(FadeOutDuration);
|
||||||
|
DelayReset();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnCountChange(ulong currentValue, ulong newValue)
|
protected override void OnCountChange(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
if (newValue != 0)
|
if (newValue != 0)
|
||||||
this.Show();
|
animateFade();
|
||||||
base.OnCountChange(currentValue, newValue);
|
base.OnCountChange(currentValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnCountRolling(ulong currentValue, ulong newValue)
|
protected override void OnCountRolling(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
PopOutSpriteText.Colour = CountSpriteText.Colour;
|
if (!IsRolling)
|
||||||
this.FadeOut(FadeOutDuration);
|
{
|
||||||
|
PopOutSpriteText.Colour = DisplayedCountSpriteText.Colour;
|
||||||
|
FadeOut(FadeOutDuration);
|
||||||
|
}
|
||||||
base.OnCountRolling(currentValue, newValue);
|
base.OnCountRolling(currentValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnCountIncrement(ulong currentValue, ulong newValue)
|
protected override void OnCountIncrement(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
this.Show();
|
animateFade();
|
||||||
base.OnCountIncrement(currentValue, newValue);
|
base.OnCountIncrement(currentValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void transformPopOutSmall(ulong newValue)
|
|
||||||
{
|
|
||||||
base.transformPopOutSmall(newValue);
|
|
||||||
CountSpriteText.Delay(FadeOutDelay);
|
|
||||||
CountSpriteText.FadeOut(FadeOutDuration);
|
|
||||||
CountSpriteText.DelayReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Increaces counter and tints pop-out before animation.
|
/// Increaces counter and tints pop-out before animation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -32,13 +32,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
protected virtual float PopOutInitialAlpha => 0.75f;
|
protected virtual float PopOutInitialAlpha => 0.75f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, the roll-down duration will be proportional to the counter.
|
/// Duration in milliseconds for the counter roll-up animation for each element.
|
||||||
/// </summary>
|
|
||||||
protected virtual bool IsRollingProportional => true;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If IsRollingProportional = false, duration in milliseconds for the counter roll-up animation for each
|
|
||||||
/// element; else duration in milliseconds for the counter roll-up animation in total.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual double RollingDuration => 20;
|
protected virtual double RollingDuration => 20;
|
||||||
|
|
||||||
@ -47,25 +41,23 @@ namespace osu.Game.GameModes.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected EasingTypes RollingEasing => EasingTypes.None;
|
protected EasingTypes RollingEasing => EasingTypes.None;
|
||||||
|
|
||||||
private ulong prevVisibleCount;
|
private ulong prevDisplayedCount;
|
||||||
private ulong visibleCount;
|
private ulong displayedCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value shown at the current moment.
|
/// Value shown at the current moment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual ulong VisibleCount
|
public virtual ulong DisplayedCount
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return visibleCount;
|
return displayedCount;
|
||||||
}
|
}
|
||||||
protected set
|
protected set
|
||||||
{
|
{
|
||||||
if (visibleCount.Equals(value))
|
if (displayedCount.Equals(value))
|
||||||
return;
|
return;
|
||||||
prevVisibleCount = visibleCount;
|
updateDisplayedCount(displayedCount, value, IsRolling);
|
||||||
visibleCount = value;
|
|
||||||
transformVisibleCount(prevVisibleCount, visibleCount, IsRolling);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,21 +75,11 @@ namespace osu.Game.GameModes.Play
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
setCount(value);
|
updateCount(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCount(ulong value, bool rolling = false)
|
protected SpriteText DisplayedCountSpriteText;
|
||||||
{
|
|
||||||
prevCount = count;
|
|
||||||
count = value;
|
|
||||||
if (IsLoaded)
|
|
||||||
{
|
|
||||||
transformCount(VisibleCount, prevCount, value, rolling);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SpriteText CountSpriteText;
|
|
||||||
|
|
||||||
private float textSize = 20.0f;
|
private float textSize = 20.0f;
|
||||||
public float TextSize
|
public float TextSize
|
||||||
@ -106,7 +88,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
textSize = value;
|
textSize = value;
|
||||||
CountSpriteText.TextSize = TextSize;
|
DisplayedCountSpriteText.TextSize = TextSize;
|
||||||
PopOutSpriteText.TextSize = TextSize;
|
PopOutSpriteText.TextSize = TextSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +100,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
CountSpriteText = new SpriteText
|
DisplayedCountSpriteText = new SpriteText
|
||||||
{
|
{
|
||||||
Anchor = this.Anchor,
|
Anchor = this.Anchor,
|
||||||
Origin = this.Origin,
|
Origin = this.Origin,
|
||||||
@ -135,19 +117,19 @@ namespace osu.Game.GameModes.Play
|
|||||||
{
|
{
|
||||||
base.Load(game);
|
base.Load(game);
|
||||||
|
|
||||||
CountSpriteText.Text = FormatCount(Count);
|
DisplayedCountSpriteText.Text = FormatCount(Count);
|
||||||
CountSpriteText.Anchor = this.Anchor;
|
DisplayedCountSpriteText.Anchor = this.Anchor;
|
||||||
CountSpriteText.Origin = this.Origin;
|
DisplayedCountSpriteText.Origin = this.Origin;
|
||||||
|
|
||||||
StopRolling();
|
StopRolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops rollover animation, forcing the visible count to be the actual count.
|
/// Stops rollover animation, forcing the displayed count to be the actual count.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void StopRolling()
|
public void StopRolling()
|
||||||
{
|
{
|
||||||
setCount(Count);
|
updateCount(Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -156,7 +138,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
/// <param name="newValue">Target value.</param>
|
/// <param name="newValue">Target value.</param>
|
||||||
public virtual void Roll(ulong newValue = 0)
|
public virtual void Roll(ulong newValue = 0)
|
||||||
{
|
{
|
||||||
setCount(newValue, true);
|
updateCount(newValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -164,13 +146,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void ResetCount()
|
public virtual void ResetCount()
|
||||||
{
|
{
|
||||||
Count = default(ulong);
|
updateCount(0);
|
||||||
}
|
|
||||||
|
|
||||||
protected double GetProportionalDuration(ulong currentValue, ulong newValue)
|
|
||||||
{
|
|
||||||
double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
|
|
||||||
return difference * RollingDuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string FormatCount(ulong count)
|
protected virtual string FormatCount(ulong count)
|
||||||
@ -178,76 +154,78 @@ namespace osu.Game.GameModes.Play
|
|||||||
return count.ToString();
|
return count.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void OnVisibleCountRolling(ulong currentValue, ulong newValue);
|
protected abstract void OnDisplayedCountRolling(ulong currentValue, ulong newValue);
|
||||||
protected abstract void OnVisibleCountIncrement(ulong newValue);
|
protected abstract void OnDisplayedCountIncrement(ulong newValue);
|
||||||
protected abstract void OnVisibleCountChange(ulong newValue);
|
protected abstract void OnDisplayedCountChange(ulong newValue);
|
||||||
|
|
||||||
private void transformVisibleCount(ulong currentValue, ulong newValue, bool rolling)
|
|
||||||
{
|
|
||||||
if (rolling)
|
|
||||||
OnVisibleCountRolling(currentValue, newValue);
|
|
||||||
else if (currentValue + 1 == newValue)
|
|
||||||
OnVisibleCountIncrement(newValue);
|
|
||||||
else
|
|
||||||
OnVisibleCountChange(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnCountRolling(ulong currentValue, ulong newValue)
|
protected virtual void OnCountRolling(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
IsRolling = true;
|
transformRoll(new TransformComboRoll(Clock), currentValue, newValue);
|
||||||
transformRoll(new TransformCombo(Clock), currentValue, newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) {
|
protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) {
|
||||||
VisibleCount = currentValue;
|
DisplayedCount = newValue;
|
||||||
VisibleCount = newValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnCountChange(ulong currentValue, ulong newValue) {
|
protected virtual void OnCountChange(ulong currentValue, ulong newValue) {
|
||||||
VisibleCount = currentValue;
|
DisplayedCount = newValue;
|
||||||
VisibleCount = newValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformCount(
|
private double getProportionalDuration(ulong currentValue, ulong newValue)
|
||||||
ulong visibleValue,
|
|
||||||
ulong currentValue,
|
|
||||||
ulong newValue,
|
|
||||||
bool rolling)
|
|
||||||
{
|
{
|
||||||
|
double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
|
||||||
|
return difference * RollingDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDisplayedCount(ulong currentValue, ulong newValue, bool rolling)
|
||||||
|
{
|
||||||
|
prevDisplayedCount = currentValue;
|
||||||
|
displayedCount = newValue;
|
||||||
|
if (rolling)
|
||||||
|
OnDisplayedCountRolling(currentValue, newValue);
|
||||||
|
else if (currentValue + 1 == newValue)
|
||||||
|
OnDisplayedCountIncrement(newValue);
|
||||||
|
else
|
||||||
|
OnDisplayedCountChange(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCount(ulong value, bool rolling = false)
|
||||||
|
{
|
||||||
|
prevCount = count;
|
||||||
|
count = value;
|
||||||
if (!rolling)
|
if (!rolling)
|
||||||
{
|
{
|
||||||
Flush(false, typeof(TransformCombo));
|
Flush(false, typeof(TransformComboRoll));
|
||||||
IsRolling = false;
|
IsRolling = false;
|
||||||
|
DisplayedCount = prevCount;
|
||||||
|
|
||||||
if (currentValue + 1 == newValue)
|
if (prevCount + 1 == count)
|
||||||
OnCountIncrement(currentValue, newValue);
|
OnCountIncrement(prevCount, count);
|
||||||
else
|
else
|
||||||
OnCountChange(currentValue, newValue);
|
OnCountChange(prevCount, count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
OnCountRolling(visibleCount, newValue);
|
{
|
||||||
|
OnCountRolling(displayedCount, count);
|
||||||
|
IsRolling = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformRoll(TransformCombo transform, ulong currentValue, ulong newValue)
|
private void transformRoll(TransformComboRoll transform, ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
Flush(false, typeof(TransformCombo));
|
Flush(false, typeof(TransformComboRoll));
|
||||||
|
|
||||||
if (Clock == null)
|
if (Clock == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (RollingDuration == 0)
|
if (RollingDuration == 0)
|
||||||
{
|
{
|
||||||
VisibleCount = Count;
|
DisplayedCount = Count;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rollingTotalDuration =
|
|
||||||
IsRollingProportional
|
|
||||||
? GetProportionalDuration(currentValue, newValue)
|
|
||||||
: RollingDuration;
|
|
||||||
|
|
||||||
transform.StartTime = Time;
|
transform.StartTime = Time;
|
||||||
transform.EndTime = Time + rollingTotalDuration;
|
transform.EndTime = Time + getProportionalDuration(currentValue, newValue);
|
||||||
transform.StartValue = currentValue;
|
transform.StartValue = currentValue;
|
||||||
transform.EndValue = newValue;
|
transform.EndValue = newValue;
|
||||||
transform.Easing = RollingEasing;
|
transform.Easing = RollingEasing;
|
||||||
@ -255,7 +233,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
Transforms.Add(transform);
|
Transforms.Add(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class TransformCombo : Transform<ulong>
|
protected class TransformComboRoll : Transform<ulong>
|
||||||
{
|
{
|
||||||
public override ulong CurrentValue
|
public override ulong CurrentValue
|
||||||
{
|
{
|
||||||
@ -272,10 +250,10 @@ namespace osu.Game.GameModes.Play
|
|||||||
public override void Apply(Drawable d)
|
public override void Apply(Drawable d)
|
||||||
{
|
{
|
||||||
base.Apply(d);
|
base.Apply(d);
|
||||||
(d as ComboCounter).VisibleCount = CurrentValue;
|
(d as ComboCounter).DisplayedCount = CurrentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransformCombo(IClock clock)
|
public TransformComboRoll(IClock clock)
|
||||||
: base(clock)
|
: base(clock)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.GameModes.Play.UserInterface
|
|||||||
public override void Apply(Drawable d)
|
public override void Apply(Drawable d)
|
||||||
{
|
{
|
||||||
base.Apply(d);
|
base.Apply(d);
|
||||||
(d as ComboResultCounter).VisibleCount = CurrentValue;
|
(d as ComboResultCounter).DisplayedCount = CurrentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransformComboResult(IClock clock)
|
public TransformComboResult(IClock clock)
|
||||||
|
@ -54,8 +54,8 @@ namespace osu.Game.GameModes.Play.Mania
|
|||||||
protected override void transformAnimate(ulong newValue)
|
protected override void transformAnimate(ulong newValue)
|
||||||
{
|
{
|
||||||
base.transformAnimate(newValue);
|
base.transformAnimate(newValue);
|
||||||
CountSpriteText.FadeColour(TintColour, 0);
|
DisplayedCountSpriteText.FadeColour(TintColour, 0);
|
||||||
CountSpriteText.FadeColour(OriginalColour, AnimationDuration, AnimationEasing);
|
DisplayedCountSpriteText.FadeColour(OriginalColour, AnimationDuration, AnimationEasing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@ namespace osu.Game.GameModes.Play.Osu
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return CountSpriteText.Position;
|
return DisplayedCountSpriteText.Position;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
CountSpriteText.Position = value;
|
DisplayedCountSpriteText.Position = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ 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(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void transformPopOutRolling(ulong newValue)
|
protected virtual void transformPopOutRolling(ulong newValue)
|
||||||
@ -69,15 +69,15 @@ namespace osu.Game.GameModes.Play.Osu
|
|||||||
|
|
||||||
protected virtual void transformNoPopOut(ulong newValue)
|
protected virtual void transformNoPopOut(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.Text = FormatCount(newValue);
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||||
CountSpriteText.ScaleTo(1);
|
DisplayedCountSpriteText.ScaleTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void transformPopOutSmall(ulong newValue)
|
protected virtual void transformPopOutSmall(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.Text = FormatCount(newValue);
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||||
CountSpriteText.ScaleTo(PopOutSmallScale);
|
DisplayedCountSpriteText.ScaleTo(PopOutSmallScale);
|
||||||
CountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void scheduledPopOutSmall(uint id)
|
protected virtual void scheduledPopOutSmall(uint id)
|
||||||
@ -86,7 +86,7 @@ namespace osu.Game.GameModes.Play.Osu
|
|||||||
if (id != ScheduledPopOutCurrentId)
|
if (id != ScheduledPopOutCurrentId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VisibleCount++;
|
DisplayedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnCountRolling(ulong currentValue, ulong newValue)
|
protected override void OnCountRolling(ulong currentValue, ulong newValue)
|
||||||
@ -97,10 +97,10 @@ namespace osu.Game.GameModes.Play.Osu
|
|||||||
|
|
||||||
protected override void OnCountIncrement(ulong currentValue, ulong newValue)
|
protected override void OnCountIncrement(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
if (VisibleCount != currentValue)
|
while (DisplayedCount != currentValue)
|
||||||
VisibleCount++;
|
DisplayedCount++;
|
||||||
|
|
||||||
CountSpriteText.Show();
|
DisplayedCountSpriteText.Show();
|
||||||
|
|
||||||
transformPopOut(newValue);
|
transformPopOut(newValue);
|
||||||
|
|
||||||
@ -118,12 +118,12 @@ namespace osu.Game.GameModes.Play.Osu
|
|||||||
base.OnCountChange(currentValue, newValue);
|
base.OnCountChange(currentValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue)
|
protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
if (newValue == 0)
|
if (newValue == 0)
|
||||||
CountSpriteText.FadeOut(PopOutDuration);
|
DisplayedCountSpriteText.FadeOut(PopOutDuration);
|
||||||
else
|
else
|
||||||
CountSpriteText.Show();
|
DisplayedCountSpriteText.Show();
|
||||||
|
|
||||||
if (CanPopOutWhileRolling)
|
if (CanPopOutWhileRolling)
|
||||||
transformPopOutRolling(newValue);
|
transformPopOutRolling(newValue);
|
||||||
@ -131,16 +131,16 @@ namespace osu.Game.GameModes.Play.Osu
|
|||||||
transformNoPopOut(newValue);
|
transformNoPopOut(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnVisibleCountChange(ulong newValue)
|
protected override void OnDisplayedCountChange(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
||||||
|
|
||||||
transformNoPopOut(newValue);
|
transformNoPopOut(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnVisibleCountIncrement(ulong newValue)
|
protected override void OnDisplayedCountIncrement(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.Show();
|
DisplayedCountSpriteText.Show();
|
||||||
|
|
||||||
transformPopOutSmall(newValue);
|
transformPopOutSmall(newValue);
|
||||||
}
|
}
|
||||||
|
@ -23,43 +23,43 @@ namespace osu.Game.GameModes.Play.Taiko
|
|||||||
|
|
||||||
public TaikoComboCounter()
|
public TaikoComboCounter()
|
||||||
{
|
{
|
||||||
CountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre;
|
DisplayedCountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre;
|
||||||
CountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre;
|
DisplayedCountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void transformAnimate(ulong newValue)
|
protected virtual void transformAnimate(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.Text = FormatCount(newValue);
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||||
CountSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
|
DisplayedCountSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
|
||||||
CountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing);
|
DisplayedCountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void transformNotAnimate(ulong newValue)
|
protected virtual void transformNotAnimate(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.Text = FormatCount(newValue);
|
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||||
CountSpriteText.ScaleTo(1);
|
DisplayedCountSpriteText.ScaleTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnVisibleCountRolling(ulong currentValue, ulong newValue)
|
protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue)
|
||||||
{
|
{
|
||||||
if (newValue == 0)
|
if (newValue == 0)
|
||||||
CountSpriteText.FadeOut(AnimationDuration);
|
DisplayedCountSpriteText.FadeOut(AnimationDuration);
|
||||||
else
|
else
|
||||||
CountSpriteText.Show();
|
DisplayedCountSpriteText.Show();
|
||||||
|
|
||||||
transformNotAnimate(newValue);
|
transformNotAnimate(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnVisibleCountChange(ulong newValue)
|
protected override void OnDisplayedCountChange(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
||||||
|
|
||||||
transformNotAnimate(newValue);
|
transformNotAnimate(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnVisibleCountIncrement(ulong newValue)
|
protected override void OnDisplayedCountIncrement(ulong newValue)
|
||||||
{
|
{
|
||||||
CountSpriteText.Show();
|
DisplayedCountSpriteText.Show();
|
||||||
|
|
||||||
transformAnimate(newValue);
|
transformAnimate(newValue);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
public override void Apply(Drawable d)
|
public override void Apply(Drawable d)
|
||||||
{
|
{
|
||||||
base.Apply(d);
|
base.Apply(d);
|
||||||
(d as PercentageCounter).VisibleCount = CurrentValue;
|
(d as PercentageCounter).DisplayedCount = CurrentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransformAccuracy(IClock clock)
|
public TransformAccuracy(IClock clock)
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected virtual Type TransformType => typeof(Transform<T>);
|
protected virtual Type TransformType => typeof(Transform<T>);
|
||||||
|
|
||||||
protected SpriteText CountSpriteText;
|
protected SpriteText DisplayedCountSpriteText;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true, the roll-up duration will be proportional to change in value.
|
/// If true, the roll-up duration will be proportional to change in value.
|
||||||
@ -43,24 +43,24 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual EasingTypes RollingEasing => EasingTypes.None;
|
public virtual EasingTypes RollingEasing => EasingTypes.None;
|
||||||
|
|
||||||
private T prevVisibleCount;
|
private T prevDisplayedCount;
|
||||||
private T visibleCount;
|
private T displayedCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value shown at the current moment.
|
/// Value shown at the current moment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual T VisibleCount
|
public virtual T DisplayedCount
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return visibleCount;
|
return displayedCount;
|
||||||
}
|
}
|
||||||
protected set
|
protected set
|
||||||
{
|
{
|
||||||
if (visibleCount.Equals(value))
|
if (displayedCount.Equals(value))
|
||||||
return;
|
return;
|
||||||
visibleCount = value;
|
displayedCount = value;
|
||||||
CountSpriteText.Text = FormatCount(value);
|
DisplayedCountSpriteText.Text = FormatCount(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
count = value;
|
count = value;
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
{
|
{
|
||||||
TransformCount(visibleCount, count);
|
TransformCount(displayedCount, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
textSize = value;
|
textSize = value;
|
||||||
CountSpriteText.TextSize = value;
|
DisplayedCountSpriteText.TextSize = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
CountSpriteText = new SpriteText
|
DisplayedCountSpriteText = new SpriteText
|
||||||
{
|
{
|
||||||
Anchor = this.Anchor,
|
Anchor = this.Anchor,
|
||||||
Origin = this.Origin,
|
Origin = this.Origin,
|
||||||
@ -125,11 +125,11 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
Flush(false, TransformType);
|
Flush(false, TransformType);
|
||||||
|
|
||||||
VisibleCount = Count;
|
DisplayedCount = Count;
|
||||||
|
|
||||||
CountSpriteText.Text = FormatCount(count);
|
DisplayedCountSpriteText.Text = FormatCount(count);
|
||||||
CountSpriteText.Anchor = this.Anchor;
|
DisplayedCountSpriteText.Anchor = this.Anchor;
|
||||||
CountSpriteText.Origin = this.Origin;
|
DisplayedCountSpriteText.Origin = this.Origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -143,12 +143,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops rollover animation, forcing the visible count to be the actual count.
|
/// Stops rollover animation, forcing the displayed count to be the actual count.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void StopRolling()
|
public virtual void StopRolling()
|
||||||
{
|
{
|
||||||
Flush(false, TransformType);
|
Flush(false, TransformType);
|
||||||
VisibleCount = Count;
|
DisplayedCount = Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -212,7 +212,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
if (RollingDuration == 0)
|
if (RollingDuration == 0)
|
||||||
{
|
{
|
||||||
VisibleCount = Count;
|
DisplayedCount = Count;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
||||||
public ScoreCounter(uint leading = 0)
|
public ScoreCounter(uint leading = 0)
|
||||||
{
|
{
|
||||||
CountSpriteText.FixedWidth = true;
|
DisplayedCountSpriteText.FixedWidth = true;
|
||||||
LeadingZeroes = leading;
|
LeadingZeroes = leading;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
public override void Apply(Drawable d)
|
public override void Apply(Drawable d)
|
||||||
{
|
{
|
||||||
base.Apply(d);
|
base.Apply(d);
|
||||||
(d as ScoreCounter).VisibleCount = CurrentValue;
|
(d as ScoreCounter).DisplayedCount = CurrentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransformScore(IClock clock)
|
public TransformScore(IClock clock)
|
||||||
|
@ -84,10 +84,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows a float count as stars. Used as star difficulty display.
|
/// Shows a float count as stars. Used as star difficulty display.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stars">Maximum amount of stars to display.</param>
|
/// <param name="maxstars">Maximum amount of stars to display.</param>
|
||||||
public StarCounter(int stars = 10)
|
public StarCounter(int maxstars = 10)
|
||||||
{
|
{
|
||||||
MaxStars = Math.Max(stars, 0);
|
MaxStars = Math.Max(maxstars, 0);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user