mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Misc. fixes and improvements
This commit is contained in:
parent
a671765a4f
commit
72c4dc344e
@ -93,23 +93,24 @@ namespace osu.Desktop.Tests
|
||||
};
|
||||
Add(accuracyCombo);
|
||||
|
||||
SpriteText starsLabel = new SpriteText
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Position = new Vector2(20, 190),
|
||||
Text = @"- unset -",
|
||||
};
|
||||
Add(starsLabel);
|
||||
|
||||
StarCounter stars = new StarCounter
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Position = new Vector2(20, 160),
|
||||
Count = 5,
|
||||
};
|
||||
Add(stars);
|
||||
|
||||
SpriteText starsLabel = new SpriteText
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Position = new Vector2(20, 190),
|
||||
Text = stars.Count.ToString("0.00"),
|
||||
};
|
||||
Add(starsLabel);
|
||||
|
||||
AddButton(@"Reset all", delegate
|
||||
{
|
||||
score.Count = 0;
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
protected SpriteText PopOutSpriteText;
|
||||
|
||||
protected virtual ulong PopOutDuration => 150;
|
||||
protected virtual double PopOutDuration => 150;
|
||||
protected virtual float PopOutScale => 2.0f;
|
||||
protected virtual EasingTypes PopOutEasing => EasingTypes.None;
|
||||
protected virtual float PopOutInitialAlpha => 0.75f;
|
||||
@ -41,7 +41,6 @@ namespace osu.Game.GameModes.Play
|
||||
/// </summary>
|
||||
protected EasingTypes RollingEasing => EasingTypes.None;
|
||||
|
||||
private ulong prevDisplayedCount;
|
||||
private ulong displayedCount;
|
||||
|
||||
/// <summary>
|
||||
@ -102,8 +101,6 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
DisplayedCountSpriteText = new SpriteText
|
||||
{
|
||||
Anchor = this.Anchor,
|
||||
Origin = this.Origin,
|
||||
Alpha = 0,
|
||||
},
|
||||
PopOutSpriteText = new SpriteText
|
||||
@ -132,11 +129,19 @@ namespace osu.Game.GameModes.Play
|
||||
updateCount(Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Animates roll-back to 0.
|
||||
/// </summary>
|
||||
public void Roll()
|
||||
{
|
||||
Roll(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Animates roll-up/roll-back to an specific value.
|
||||
/// </summary>
|
||||
/// <param name="newValue">Target value.</param>
|
||||
public virtual void Roll(ulong newValue = 0)
|
||||
public virtual void Roll(ulong newValue)
|
||||
{
|
||||
updateCount(newValue, true);
|
||||
}
|
||||
@ -173,13 +178,12 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
private double getProportionalDuration(ulong currentValue, ulong newValue)
|
||||
{
|
||||
double difference = currentValue > newValue ? currentValue - newValue : currentValue - newValue;
|
||||
double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||
return difference * RollingDuration;
|
||||
}
|
||||
|
||||
private void updateDisplayedCount(ulong currentValue, ulong newValue, bool rolling)
|
||||
{
|
||||
prevDisplayedCount = currentValue;
|
||||
displayedCount = newValue;
|
||||
if (rolling)
|
||||
OnDisplayedCountRolling(currentValue, newValue);
|
||||
@ -218,7 +222,7 @@ namespace osu.Game.GameModes.Play
|
||||
if (Clock == null)
|
||||
return;
|
||||
|
||||
if (RollingDuration == 0)
|
||||
if (RollingDuration < 1)
|
||||
{
|
||||
DisplayedCount = Count;
|
||||
return;
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.GameModes.Play.Mania
|
||||
|
||||
protected Color4 PopOutColor => Color4.Red;
|
||||
protected override float PopOutInitialAlpha => 1.0f;
|
||||
protected override ulong PopOutDuration => 300;
|
||||
protected override double PopOutDuration => 300;
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
return $@"{count}x";
|
||||
}
|
||||
|
||||
protected virtual void transformPopOut(ulong newValue)
|
||||
protected virtual void TransformPopOut(ulong newValue)
|
||||
{
|
||||
PopOutSpriteText.Text = FormatCount(newValue);
|
||||
|
||||
@ -61,26 +61,26 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
PopOutSpriteText.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing);
|
||||
}
|
||||
|
||||
protected virtual void transformPopOutRolling(ulong newValue)
|
||||
protected virtual void TransformPopOutRolling(ulong newValue)
|
||||
{
|
||||
transformPopOut(newValue);
|
||||
transformPopOutSmall(newValue);
|
||||
TransformPopOut(newValue);
|
||||
TransformPopOutSmall(newValue);
|
||||
}
|
||||
|
||||
protected virtual void transformNoPopOut(ulong newValue)
|
||||
protected virtual void TransformNoPopOut(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||
DisplayedCountSpriteText.ScaleTo(1);
|
||||
}
|
||||
|
||||
protected virtual void transformPopOutSmall(ulong newValue)
|
||||
protected virtual void TransformPopOutSmall(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||
DisplayedCountSpriteText.ScaleTo(PopOutSmallScale);
|
||||
DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||
}
|
||||
|
||||
protected virtual void scheduledPopOutSmall(uint id)
|
||||
protected virtual void ScheduledPopOutSmall(uint id)
|
||||
{
|
||||
// Too late; scheduled task invalidated
|
||||
if (id != ScheduledPopOutCurrentId)
|
||||
@ -104,12 +104,12 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
|
||||
DisplayedCountSpriteText.Show();
|
||||
|
||||
transformPopOut(newValue);
|
||||
TransformPopOut(newValue);
|
||||
|
||||
uint newTaskId = ScheduledPopOutCurrentId;
|
||||
Scheduler.AddDelayed(delegate
|
||||
{
|
||||
scheduledPopOutSmall(newTaskId);
|
||||
ScheduledPopOutSmall(newTaskId);
|
||||
}, PopOutDuration);
|
||||
}
|
||||
|
||||
@ -127,23 +127,23 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
DisplayedCountSpriteText.Show();
|
||||
|
||||
if (CanPopOutWhileRolling)
|
||||
transformPopOutRolling(newValue);
|
||||
TransformPopOutRolling(newValue);
|
||||
else
|
||||
transformNoPopOut(newValue);
|
||||
TransformNoPopOut(newValue);
|
||||
}
|
||||
|
||||
protected override void OnDisplayedCountChange(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
||||
|
||||
transformNoPopOut(newValue);
|
||||
TransformNoPopOut(newValue);
|
||||
}
|
||||
|
||||
protected override void OnDisplayedCountIncrement(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.Show();
|
||||
|
||||
transformPopOutSmall(newValue);
|
||||
TransformPopOutSmall(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ namespace osu.Game.GameModes.Play.Taiko
|
||||
DisplayedCountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre;
|
||||
}
|
||||
|
||||
protected virtual void transformAnimate(ulong newValue)
|
||||
protected virtual void TransformAnimate(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||
DisplayedCountSpriteText.ScaleTo(new Vector2(1, ScaleFactor));
|
||||
DisplayedCountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing);
|
||||
}
|
||||
|
||||
protected virtual void transformNotAnimate(ulong newValue)
|
||||
protected virtual void TransformNotAnimate(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
||||
DisplayedCountSpriteText.ScaleTo(1);
|
||||
@ -47,21 +47,21 @@ namespace osu.Game.GameModes.Play.Taiko
|
||||
else
|
||||
DisplayedCountSpriteText.Show();
|
||||
|
||||
transformNotAnimate(newValue);
|
||||
TransformNotAnimate(newValue);
|
||||
}
|
||||
|
||||
protected override void OnDisplayedCountChange(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1);
|
||||
|
||||
transformNotAnimate(newValue);
|
||||
TransformNotAnimate(newValue);
|
||||
}
|
||||
|
||||
protected override void OnDisplayedCountIncrement(ulong newValue)
|
||||
{
|
||||
DisplayedCountSpriteText.Show();
|
||||
|
||||
transformAnimate(newValue);
|
||||
TransformAnimate(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public virtual EasingTypes RollingEasing => EasingTypes.None;
|
||||
|
||||
private T prevDisplayedCount;
|
||||
private T displayedCount;
|
||||
|
||||
/// <summary>
|
||||
@ -104,18 +103,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
protected RollingCounter()
|
||||
{
|
||||
Debug.Assert(
|
||||
TransformType.IsSubclassOf(typeof(Transform<T>)) || TransformType == typeof(Transform<T>),
|
||||
@"transformType should be a subclass of Transform<T>."
|
||||
);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
DisplayedCountSpriteText = new SpriteText
|
||||
{
|
||||
Anchor = this.Anchor,
|
||||
Origin = this.Origin,
|
||||
},
|
||||
DisplayedCountSpriteText = new SpriteText(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -195,6 +185,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected virtual void TransformCount(T currentValue, T newValue)
|
||||
{
|
||||
object[] parameters = { Clock };
|
||||
|
||||
Debug.Assert(
|
||||
TransformType.IsSubclassOf(typeof(Transform<T>)) || TransformType == typeof(Transform<T>),
|
||||
@"transformType should be a subclass of Transform<T>."
|
||||
);
|
||||
|
||||
TransformCount((Transform<T>)Activator.CreateInstance(TransformType, parameters), currentValue, newValue);
|
||||
}
|
||||
|
||||
@ -210,7 +206,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
if (Clock == null)
|
||||
return;
|
||||
|
||||
if (RollingDuration == 0)
|
||||
if (RollingDuration < 1)
|
||||
{
|
||||
DisplayedCount = Count;
|
||||
return;
|
||||
|
@ -17,8 +17,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class StarCounter : AutoSizeContainer
|
||||
{
|
||||
private Container starContainer;
|
||||
private List<TextAwesome> stars = new List<TextAwesome>();
|
||||
private readonly Container starContainer;
|
||||
private readonly List<TextAwesome> stars = new List<TextAwesome>();
|
||||
|
||||
private double transformStartTime = 0;
|
||||
|
||||
@ -81,11 +81,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a float count as stars (up to 10). Used as star difficulty display.
|
||||
/// </summary>
|
||||
public StarCounter() : this(10) {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a float count as stars. Used as star difficulty display.
|
||||
/// </summary>
|
||||
/// <param name="maxstars">Maximum amount of stars to display.</param>
|
||||
public StarCounter(int maxstars = 10)
|
||||
public StarCounter(int maxstars)
|
||||
{
|
||||
MaxStars = Math.Max(maxstars, 0);
|
||||
|
||||
@ -114,6 +120,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.Centre,
|
||||
TextSize = StarSize,
|
||||
Scale = new Vector2(minStarScale),
|
||||
Alpha = minStarAlpha,
|
||||
Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0),
|
||||
};
|
||||
|
||||
@ -122,8 +130,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
starContainer.Add(star);
|
||||
}
|
||||
|
||||
// Used to recreate initial state.
|
||||
StopAnimation();
|
||||
// Animate initial state from zero.
|
||||
transformCount(0, Count);
|
||||
}
|
||||
|
||||
public void ResetCount()
|
||||
|
Loading…
Reference in New Issue
Block a user