mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
Split score counter class into two distinct classes to simplify usages
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
// 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 System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -17,23 +16,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public Bindable<int> RequiredDisplayDigits { get; } = new Bindable<int>();
|
||||
|
||||
private string formatString = string.Empty;
|
||||
private string formatString;
|
||||
|
||||
/// <summary>
|
||||
/// Displays score.
|
||||
/// </summary>
|
||||
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
||||
/// <param name="useCommaSeparator">Whether comma separators should be displayed.</param>
|
||||
protected ScoreCounter(int leading = 0, bool useCommaSeparator = false)
|
||||
protected ScoreCounter(int leading = 0)
|
||||
{
|
||||
if (useCommaSeparator)
|
||||
{
|
||||
if (leading > 0)
|
||||
throw new ArgumentException("Should not mix leading zeroes and comma separators as it doesn't make sense");
|
||||
|
||||
formatString = @"N0";
|
||||
}
|
||||
|
||||
RequiredDisplayDigits.Value = leading;
|
||||
RequiredDisplayDigits.BindValueChanged(displayDigitsChanged, true);
|
||||
}
|
||||
@ -44,10 +34,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
protected override double GetProportionalDuration(double currentValue, double newValue)
|
||||
{
|
||||
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||
}
|
||||
protected override double GetProportionalDuration(double currentValue, double newValue) =>
|
||||
currentValue > newValue ? currentValue - newValue : newValue - currentValue;
|
||||
|
||||
protected override LocalisableString FormatCount(double count) => ((long)count).ToLocalisableString(formatString);
|
||||
|
||||
|
Reference in New Issue
Block a user