1
0
mirror of https://github.com/ppy/osu.git synced 2024-10-01 05:17:24 +08:00
osu-lazer/osu.Game/Screens/Ranking/Expanded/Statistics/AccuracyStatistic.cs

62 lines
2.0 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 osu.Game.Utils;
using osuTK;
namespace osu.Game.Screens.Ranking.Expanded.Statistics
{
2020-03-17 16:34:16 +08:00
/// <summary>
/// A <see cref="StatisticDisplay"/> to display the player's accuracy.
/// </summary>
2020-03-17 16:25:24 +08:00
public class AccuracyStatistic : StatisticDisplay
{
private readonly double accuracy;
private RollingCounter<double> counter;
2020-03-17 16:34:16 +08:00
/// <summary>
/// Creates a new <see cref="AccuracyStatistic"/>.
/// </summary>
/// <param name="accuracy">The accuracy to display.</param>
2020-03-17 16:25:24 +08:00
public AccuracyStatistic(double accuracy)
: base("accuracy")
{
this.accuracy = accuracy;
}
public override void Appear()
{
base.Appear();
counter.Current.Value = accuracy;
}
protected override Drawable CreateContent() => counter = new Counter();
private class Counter : RollingCounter<double>
{
protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION;
protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING;
protected override string FormatCount(double count) => count.FormatAccuracy();
public override void Increment(double amount)
=> Current.Value += amount;
protected override OsuSpriteText CreateSpriteText()
{
var spriteText = base.CreateSpriteText();
spriteText.Font = OsuFont.Torus.With(size: 20, fixedWidth: true);
spriteText.Spacing = new Vector2(-2, 0);
return spriteText;
}
2020-03-17 16:25:24 +08:00
}
}
}