From d30bac3f49af02f2473e9c1a71aacbdb8f42dd4e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 8 Nov 2023 01:49:13 +0300 Subject: [PATCH] Move "required display digits" feature to reside in argon score counter --- .../Screens/Play/HUD/ArgonCounterTextComponent.cs | 7 +++---- osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs index fcad0f12d8..437a627cbc 100644 --- a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs +++ b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; -using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -25,7 +23,6 @@ namespace osu.Game.Screens.Play.HUD private readonly ArgonCounterSpriteText wireframesPart; private readonly ArgonCounterSpriteText textPart; - public IBindable RequiredDisplayDigits { get; } = new BindableInt(); public IBindable WireframeOpacity { get; } = new BindableFloat(); public LocalisableString Text @@ -33,7 +30,7 @@ namespace osu.Game.Screens.Play.HUD get => textPart.Text; set { - wireframesPart.Text = new string('#', Math.Max(value.ToString().Count(char.IsDigit), RequiredDisplayDigits.Value)); + wireframesPart.Text = FormatWireframes(value); textPart.Text = value; } } @@ -91,6 +88,8 @@ namespace osu.Game.Screens.Play.HUD }; } + protected virtual LocalisableString FormatWireframes(LocalisableString text) => text; + protected override void LoadComplete() { base.LoadComplete(); diff --git a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs index 636565f181..fef4199d31 100644 --- a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . 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; @@ -25,10 +26,22 @@ namespace osu.Game.Screens.Play.HUD protected override LocalisableString FormatCount(long count) => count.ToLocalisableString(); - protected override IHasText CreateText() => new ArgonCounterTextComponent(Anchor.TopRight) + protected override IHasText CreateText() => new ArgonScoreTextComponent(Anchor.TopRight) { RequiredDisplayDigits = { BindTarget = RequiredDisplayDigits }, WireframeOpacity = { BindTarget = WireframeOpacity }, }; + + private partial class ArgonScoreTextComponent : ArgonCounterTextComponent + { + public IBindable RequiredDisplayDigits { get; } = new BindableInt(); + + public ArgonScoreTextComponent(Anchor anchor, LocalisableString? label = null) + : base(anchor, label) + { + } + + protected override LocalisableString FormatWireframes(LocalisableString text) => new string('#', Math.Max(text.ToString().Length, RequiredDisplayDigits.Value)); + } } }