diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs
index eedb0bf5b5..0587ccea63 100644
--- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs
+++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs
@@ -87,6 +87,14 @@ namespace osu.Desktop.Tests
};
Add(pc);
+ StarCounter tc = new StarCounter
+ {
+ Origin = Anchor.BottomLeft,
+ Anchor = Anchor.BottomLeft,
+ Position = new Vector2(20, 160),
+ };
+ Add(tc);
+
AddButton(@"Reset all", delegate
{
uc.Count = 0;
@@ -119,6 +127,11 @@ namespace osu.Desktop.Tests
pc.Denominator++;
});
+ AddButton(@"Alter stars", delegate
+ {
+ tc.Count = RNG.NextSingle() * tc.MaxStars;
+ });
+
AddButton(@"Stop counters", delegate
{
uc.StopRolling();
@@ -126,6 +139,7 @@ namespace osu.Desktop.Tests
cc.StopRolling();
ac.StopRolling();
pc.StopRolling();
+ tc.StopRolling();
});
}
}
diff --git a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs
index d00eda80b2..d13cd20107 100644
--- a/osu.Game/Graphics/UserInterface/AccuracyCounter.cs
+++ b/osu.Game/Graphics/UserInterface/AccuracyCounter.cs
@@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface
///
/// Used as an accuracy counter. Represented visually as a percentage, internally as a fraction.
///
- public class AccuracyCounter : RollingCounter
+ public class AccuracyCounter : NumericRollingCounter
{
protected override Type transformType => typeof(TransformAccuracy);
diff --git a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs
index c361f96644..4a343737f1 100644
--- a/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs
+++ b/osu.Game/Graphics/UserInterface/AlternativeComboCounter.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface
{
public Color4 OriginalColour;
public Color4 TintColour = Color4.OrangeRed;
- public int TintDuration = 500;
+ public int TintDuration = 250;
public float ScaleFactor = 2;
public EasingTypes TintEasing = EasingTypes.None;
public bool CanAnimateWhenBackwards = false;
diff --git a/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs b/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs
new file mode 100644
index 0000000000..22f14838f6
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/NumericRollingCounter.cs
@@ -0,0 +1,64 @@
+//Copyright (c) 2007-2016 ppy Pty Ltd .
+//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Sprites;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ ///
+ /// Skeleton for a numeric counter with a simple roll-up animation.
+ ///
+ /// Type of the actual counter.
+ public abstract class NumericRollingCounter : RollingCounter
+ {
+ protected SpriteText countSpriteText;
+
+ protected float textSize = 20.0f;
+ public float TextSize
+ {
+ get { return textSize; }
+ set
+ {
+ textSize = value;
+ updateTextSize();
+ }
+ }
+
+ public override void Load()
+ {
+
+ base.Load();
+ Children = new Drawable[]
+ {
+ countSpriteText = new SpriteText
+ {
+ Text = formatCount(Count),
+ TextSize = this.TextSize,
+ Anchor = this.Anchor,
+ Origin = this.Origin,
+ },
+ };
+ }
+
+ protected override void transformVisibleCount(T currentValue, T newValue)
+ {
+ if (countSpriteText != null)
+ {
+ countSpriteText.Text = formatCount(newValue);
+ }
+ }
+
+ protected virtual void updateTextSize()
+ {
+ if (countSpriteText != null)
+ countSpriteText.TextSize = TextSize;
+ }
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs
index 44a160c83e..54d269079d 100644
--- a/osu.Game/Graphics/UserInterface/RollingCounter.cs
+++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs
@@ -1,9 +1,5 @@
-//Copyright (c) 2007-2016 ppy Pty Ltd .
-//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
-
-using osu.Framework.Graphics;
+using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using System;
using System.Collections.Generic;
@@ -15,8 +11,12 @@ using System.Threading.Tasks;
namespace osu.Game.Graphics.UserInterface
{
///
- /// Skeleton for a counter with a simple roll-up animation.
+ /// Skeleton for a counter which value rolls-up in a lapse of time.
///
+ ///
+ /// This class only abstracts the basics to roll-up a value in a lapse of time by using Transforms.
+ /// In order to show a value, you must implement a way to display it, i.e., as a numeric counter or a bar.
+ ///
/// Type of the actual counter.
public abstract class RollingCounter : Container
{
@@ -28,20 +28,8 @@ namespace osu.Game.Graphics.UserInterface
///
protected virtual Type transformType => typeof(Transform);
- protected SpriteText countSpriteText;
protected ulong RollingTotalDuration = 0;
- protected float textSize = 20.0f;
- public float TextSize
- {
- get { return textSize; }
- set
- {
- textSize = value;
- updateTextSize();
- }
- }
-
///
/// If true, each time the Count is updated, it will roll over from the current visible value.
/// Else, it will roll up from the current count value.
@@ -121,16 +109,6 @@ namespace osu.Game.Graphics.UserInterface
if (Count == null)
ResetCount();
VisibleCount = Count;
- Children = new Drawable[]
- {
- countSpriteText = new SpriteText
- {
- Text = formatCount(Count),
- TextSize = this.TextSize,
- Anchor = this.Anchor,
- Origin = this.Origin,
- },
- };
}
///
@@ -250,18 +228,6 @@ namespace osu.Game.Graphics.UserInterface
///
/// Visible count value before modification.
/// Expected visible count value after modification-
- protected virtual void transformVisibleCount(T currentValue, T newValue)
- {
- if (countSpriteText != null)
- {
- countSpriteText.Text = formatCount(newValue);
- }
- }
-
- protected virtual void updateTextSize()
- {
- if (countSpriteText != null)
- countSpriteText.TextSize = TextSize;
- }
+ protected abstract void transformVisibleCount(T currentValue, T newValue);
}
}
diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs
new file mode 100644
index 0000000000..a322a5ec36
--- /dev/null
+++ b/osu.Game/Graphics/UserInterface/StarCounter.cs
@@ -0,0 +1,119 @@
+//Copyright (c) 2007-2016 ppy Pty Ltd .
+//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Transformations;
+using osu.Framework.MathUtils;
+using osu.Framework.Timing;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace osu.Game.Graphics.UserInterface
+{
+ ///
+ /// Shows a float count as stars. Used as star difficulty display.
+ ///
+ public class StarCounter : RollingCounter
+ {
+ protected override Type transformType => typeof(TransformStar);
+
+ protected float MinStarSize = 0.001f;
+
+ protected FlowContainer starContainer;
+ protected List stars = new List();
+
+ public int MaxStars = 10;
+
+ public StarCounter() : base()
+ {
+ RollingDuration = 5000;
+ }
+
+ public override void ResetCount()
+ {
+ Count = 0;
+ StopRolling();
+ }
+
+ public override void Load()
+ {
+ base.Load();
+
+ Children = new Drawable[]
+ {
+ starContainer = new FlowContainer
+ {
+ Direction = FlowDirection.HorizontalOnly,
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ }
+ };
+
+ for (int i = 0; i < MaxStars; i++)
+ {
+ TextAwesome star = new TextAwesome
+ {
+ Icon = FontAwesome.star,
+ Origin = Anchor.Centre,
+ TextSize = 20,
+ };
+ stars.Add(star);
+ starContainer.Add(star);
+ }
+
+ // HACK: To mantain container height constant
+ starContainer.Add(new TextAwesome
+ {
+ Icon = FontAwesome.star,
+ Origin = Anchor.Centre,
+ TextSize = 20,
+ Alpha = 0.002f,
+ });
+
+ ResetCount();
+ }
+
+ protected override void transformVisibleCount(float currentValue, float newValue)
+ {
+ for (int i = 0; i < MaxStars; i++)
+ {
+ if (newValue < i)
+ stars[i].ScaleTo(MinStarSize);
+ else if (newValue > (i + 1))
+ stars[i].ScaleTo(1f);
+ else
+ stars[i].ScaleTo(Interpolation.ValueAt(newValue, MinStarSize, 1f, i, i + 1, EasingTypes.None));
+ }
+ }
+
+ protected class TransformStar : Transform
+ {
+ public override float CurrentValue
+ {
+ get
+ {
+ double time = Time;
+ if (time < StartTime) return StartValue;
+ if (time >= EndTime) return EndValue;
+
+ return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
+ }
+ }
+
+ public override void Apply(Drawable d)
+ {
+ base.Apply(d);
+ (d as StarCounter).VisibleCount = CurrentValue;
+ }
+
+ public TransformStar(IClock clock)
+ : base(clock)
+ {
+ }
+ }
+ }
+}
diff --git a/osu.Game/Graphics/UserInterface/ULongCounter.cs b/osu.Game/Graphics/UserInterface/ULongCounter.cs
index ef61cf7879..35df8f5cc8 100644
--- a/osu.Game/Graphics/UserInterface/ULongCounter.cs
+++ b/osu.Game/Graphics/UserInterface/ULongCounter.cs
@@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface
///
/// A simple rolling counter that accepts unsigned long values.
///
- public class ULongCounter : RollingCounter
+ public class ULongCounter : NumericRollingCounter
{
protected override Type transformType => typeof(TransformULongCounter);
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index ae45d04592..127548c519 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -102,15 +102,17 @@
+
-
+
+