1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 08:42:56 +08:00
osu-lazer/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs

55 lines
1.7 KiB
C#
Raw Normal View History

2020-03-17 16:25:24 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
2020-03-17 16:25:24 +08:00
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Ranking.Expanded.Accuracy;
using osuTK;
namespace osu.Game.Screens.Ranking.Expanded.Statistics
{
2020-03-17 16:34:16 +08:00
/// <summary>
/// A <see cref="StatisticDisplay"/> to display general numeric values.
/// </summary>
2020-03-17 16:25:24 +08:00
public class CounterStatistic : StatisticDisplay
{
private readonly int count;
private RollingCounter<int> counter;
2020-03-17 16:34:16 +08:00
/// <summary>
/// Creates a new <see cref="CounterStatistic"/>.
/// </summary>
/// <param name="header">The name of the statistic.</param>
/// <param name="count">The value to display.</param>
2020-03-17 16:25:24 +08:00
public CounterStatistic(string header, int count)
: base(header)
{
this.count = count;
}
public override void Appear()
{
base.Appear();
counter.Current.Value = count;
}
protected override Drawable CreateContent() => counter = new Counter();
private class Counter : RollingCounter<int>
{
protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION;
protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING;
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
2020-03-17 16:25:24 +08:00
{
s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true);
s.Spacing = new Vector2(-2, 0);
});
2020-03-17 16:25:24 +08:00
}
}
}