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;
|
2021-07-24 04:37:08 +08:00
|
|
|
using osu.Framework.Localisation;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Game.Graphics;
|
2020-08-04 01:14:17 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-01-28 12:53:48 +08:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2020-03-17 16:25:24 +08:00
|
|
|
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>
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class AccuracyStatistic : StatisticDisplay
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
|
|
|
private readonly double accuracy;
|
|
|
|
|
2024-05-14 19:17:31 +08:00
|
|
|
private RollingCounter<double> counter = null!;
|
2020-03-17 16:25:24 +08:00
|
|
|
|
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)
|
2022-01-28 12:53:48 +08:00
|
|
|
: base(BeatmapsetsStrings.ShowScoreboardHeadersAccuracy)
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
|
|
|
this.accuracy = accuracy;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Appear()
|
|
|
|
{
|
|
|
|
base.Appear();
|
|
|
|
counter.Current.Value = accuracy;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Drawable CreateContent() => counter = new Counter();
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
private partial class Counter : RollingCounter<double>
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2024-01-17 17:18:53 +08:00
|
|
|
// FormatAccuracy doesn't round, which means if we use the OutPow10 easing the number will stick 0.01% short for some time.
|
|
|
|
// To avoid that let's use a shorter easing which looks roughly the same.
|
|
|
|
protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION / 2;
|
|
|
|
protected override Easing RollingEasing => Easing.OutQuad;
|
2020-03-17 16:25:24 +08:00
|
|
|
|
2021-07-24 04:37:08 +08:00
|
|
|
protected override LocalisableString FormatCount(double count) => count.FormatAccuracy();
|
2020-03-17 16:25:24 +08:00
|
|
|
|
2020-08-19 12:47:02 +08:00
|
|
|
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
|
2020-08-04 01:14:17 +08:00
|
|
|
{
|
2020-08-19 12:47:02 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|