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