mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:32:55 +08:00
Extract StatisticCounter to a separate class and use it instead.
This commit is contained in:
parent
44471b4596
commit
6bfff43634
@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Ranking.Expanded.Accuracy;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
@ -19,7 +18,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
private readonly int count;
|
||||
private readonly int? maxCount;
|
||||
|
||||
protected RollingCounter<int> Counter { get; private set; }
|
||||
private RollingCounter<int> counter;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CounterStatistic"/>.
|
||||
@ -37,7 +36,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
public override void Appear()
|
||||
{
|
||||
base.Appear();
|
||||
Counter.Current.Value = count;
|
||||
counter.Current.Value = count;
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent()
|
||||
@ -46,7 +45,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Child = Counter = new StatisticCounter
|
||||
Child = counter = new StatisticCounter
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
@ -67,18 +66,5 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private class StatisticCounter : 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 =>
|
||||
{
|
||||
s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true);
|
||||
s.Spacing = new Vector2(-2, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,13 @@ using System;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
{
|
||||
public class PerformanceStatistic : CounterStatistic
|
||||
public class PerformanceStatistic : StatisticDisplay
|
||||
{
|
||||
private readonly ScoreInfo score;
|
||||
|
||||
@ -17,8 +19,10 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
|
||||
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
private RollingCounter<int> counter;
|
||||
|
||||
public PerformanceStatistic(ScoreInfo score)
|
||||
: base("PP", 0)
|
||||
: base("PP")
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
@ -46,7 +50,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
public override void Appear()
|
||||
{
|
||||
base.Appear();
|
||||
Counter.Current.BindTo(performance);
|
||||
counter.Current.BindTo(performance);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
@ -54,5 +58,11 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
cancellationTokenSource?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => counter = new StatisticCounter
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
// 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;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Ranking.Expanded.Accuracy;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
{
|
||||
public class StatisticCounter : 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 =>
|
||||
{
|
||||
s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true);
|
||||
s.Spacing = new Vector2(-2, 0);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user