mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 18:27:26 +08:00
Merge pull request #10555 from peppy/fix-score-display-zero-padding
Fix incorrect zero padding for classic scoring mode
This commit is contained in:
commit
b5cadd6a2c
@ -56,8 +56,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
displayedCount = value;
|
displayedCount = value;
|
||||||
if (displayedCountSpriteText != null)
|
UpdateDisplay();
|
||||||
displayedCountSpriteText.Text = FormatCount(value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,10 +72,17 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
displayedCountSpriteText = CreateSpriteText();
|
displayedCountSpriteText = CreateSpriteText();
|
||||||
displayedCountSpriteText.Text = FormatCount(DisplayedCount);
|
|
||||||
|
UpdateDisplay();
|
||||||
Child = displayedCountSpriteText;
|
Child = displayedCountSpriteText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void UpdateDisplay()
|
||||||
|
{
|
||||||
|
if (displayedCountSpriteText != null)
|
||||||
|
displayedCountSpriteText.Text = FormatCount(DisplayedCount);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
@ -17,20 +18,19 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseCommaSeparator { get; }
|
public bool UseCommaSeparator { get; }
|
||||||
|
|
||||||
/// <summary>
|
public Bindable<int> RequiredDisplayDigits { get; } = new Bindable<int>();
|
||||||
/// How many leading zeroes the counter has.
|
|
||||||
/// </summary>
|
|
||||||
public uint LeadingZeroes { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Displays score.
|
/// Displays score.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
||||||
/// <param name="useCommaSeparator">Whether comma separators should be displayed.</param>
|
/// <param name="useCommaSeparator">Whether comma separators should be displayed.</param>
|
||||||
protected ScoreCounter(uint leading = 0, bool useCommaSeparator = false)
|
protected ScoreCounter(int leading = 0, bool useCommaSeparator = false)
|
||||||
{
|
{
|
||||||
UseCommaSeparator = useCommaSeparator;
|
UseCommaSeparator = useCommaSeparator;
|
||||||
LeadingZeroes = leading;
|
|
||||||
|
RequiredDisplayDigits.Value = leading;
|
||||||
|
RequiredDisplayDigits.BindValueChanged(_ => UpdateDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override double GetProportionalDuration(double currentValue, double newValue)
|
protected override double GetProportionalDuration(double currentValue, double newValue)
|
||||||
@ -40,7 +40,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override string FormatCount(double count)
|
protected override string FormatCount(double count)
|
||||||
{
|
{
|
||||||
string format = new string('0', (int)LeadingZeroes);
|
string format = new string('0', RequiredDisplayDigits.Value);
|
||||||
|
|
||||||
if (UseCommaSeparator)
|
if (UseCommaSeparator)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
new SettingsEnumDropdown<ScoringMode>
|
new SettingsEnumDropdown<ScoringMode>
|
||||||
{
|
{
|
||||||
LabelText = "Score display mode",
|
LabelText = "Score display mode",
|
||||||
Current = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode)
|
Current = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode),
|
||||||
|
Keywords = new[] { "scoring" }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,5 +15,11 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
/// The current score to be displayed.
|
/// The current score to be displayed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Bindable<double> Current { get; }
|
Bindable<double> Current { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of digits required to display most sane scores.
|
||||||
|
/// This may be exceeded in very rare cases, but is useful to pad or space the display to avoid it jumping around.
|
||||||
|
/// </summary>
|
||||||
|
Bindable<int> RequiredDisplayDigits { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HUD
|
||||||
@ -10,12 +14,38 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
public Bindable<double> Current { get; } = new Bindable<double>();
|
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||||
|
|
||||||
|
private Bindable<ScoringMode> scoreDisplayMode;
|
||||||
|
|
||||||
|
public Bindable<int> RequiredDisplayDigits { get; } = new Bindable<int>();
|
||||||
|
|
||||||
public SkinnableScoreCounter()
|
public SkinnableScoreCounter()
|
||||||
: base(new HUDSkinComponent(HUDSkinComponents.ScoreCounter), _ => new DefaultScoreCounter())
|
: base(new HUDSkinComponent(HUDSkinComponents.ScoreCounter), _ => new DefaultScoreCounter())
|
||||||
{
|
{
|
||||||
CentreComponent = false;
|
CentreComponent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
scoreDisplayMode = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode);
|
||||||
|
scoreDisplayMode.BindValueChanged(scoreMode =>
|
||||||
|
{
|
||||||
|
switch (scoreMode.NewValue)
|
||||||
|
{
|
||||||
|
case ScoringMode.Standardised:
|
||||||
|
RequiredDisplayDigits.Value = 6;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ScoringMode.Classic:
|
||||||
|
RequiredDisplayDigits.Value = 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(scoreMode));
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
private IScoreCounter skinnedCounter;
|
private IScoreCounter skinnedCounter;
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||||
@ -23,7 +53,9 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin, allowFallback);
|
||||||
|
|
||||||
skinnedCounter = Drawable as IScoreCounter;
|
skinnedCounter = Drawable as IScoreCounter;
|
||||||
|
|
||||||
skinnedCounter?.Current.BindTo(Current);
|
skinnedCounter?.Current.BindTo(Current);
|
||||||
|
skinnedCounter?.RequiredDisplayDigits.BindTo(RequiredDisplayDigits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user