From ce994a7a733eacd1bd5b1c30aacda217b071e8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 28 Feb 2024 13:31:06 +0100 Subject: [PATCH 1/2] Fix wireframe misalignment in argon accuracy counter - Closes https://github.com/ppy/osu/issues/27385. - Supersedes / closes https://github.com/ppy/osu/pull/27392. --- osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs | 6 +++--- osu.Game/Screens/Play/HUD/ArgonComboCounter.cs | 5 ++++- .../Screens/Play/HUD/ArgonCounterTextComponent.cs | 15 ++++++++++++--- osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs | 6 ++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs b/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs index ca00ab12c7..4cc04e1485 100644 --- a/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs @@ -75,21 +75,21 @@ namespace osu.Game.Screens.Play.HUD AutoSizeAxes = Axes.Both, Child = wholePart = new ArgonCounterTextComponent(Anchor.TopRight, BeatmapsetsStrings.ShowScoreboardHeadersAccuracy.ToUpper()) { - RequiredDisplayDigits = { Value = 3 }, WireframeOpacity = { BindTarget = WireframeOpacity }, + WireframeTemplate = @"###", ShowLabel = { BindTarget = ShowLabel }, } }, fractionPart = new ArgonCounterTextComponent(Anchor.TopLeft) { - RequiredDisplayDigits = { Value = 2 }, WireframeOpacity = { BindTarget = WireframeOpacity }, + WireframeTemplate = @".##", Scale = new Vector2(0.5f), }, percentText = new ArgonCounterTextComponent(Anchor.TopLeft) { Text = @"%", - RequiredDisplayDigits = { Value = 1 }, + WireframeTemplate = @"#", WireframeOpacity = { BindTarget = WireframeOpacity } }, } diff --git a/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs b/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs index 369c753cb0..3f187650b2 100644 --- a/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs @@ -68,7 +68,10 @@ namespace osu.Game.Screens.Play.HUD private void updateWireframe() { - text.RequiredDisplayDigits.Value = getDigitsRequiredForDisplayCount(); + int digitsRequiredForDisplayCount = getDigitsRequiredForDisplayCount(); + + if (digitsRequiredForDisplayCount != text.WireframeTemplate.Length) + text.WireframeTemplate = new string('#', digitsRequiredForDisplayCount); } private int getDigitsRequiredForDisplayCount() diff --git a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs index f8c82feddd..efb4d2108e 100644 --- a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs +++ b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs @@ -25,7 +25,6 @@ namespace osu.Game.Screens.Play.HUD private readonly OsuSpriteText labelText; public IBindable WireframeOpacity { get; } = new BindableFloat(); - public Bindable RequiredDisplayDigits { get; } = new BindableInt(); public Bindable ShowLabel { get; } = new BindableBool(); public Container NumberContainer { get; private set; } @@ -36,6 +35,18 @@ namespace osu.Game.Screens.Play.HUD set => textPart.Text = value; } + /// + /// The template for the wireframe displayed behind the . + /// Any character other than a dot is interpreted to mean a full segmented display "wireframe". + /// + public string WireframeTemplate + { + get => wireframeTemplate; + set => wireframesPart.Text = wireframeTemplate = value; + } + + private string wireframeTemplate = string.Empty; + public ArgonCounterTextComponent(Anchor anchor, LocalisableString? label = null) { Anchor = anchor; @@ -69,8 +80,6 @@ namespace osu.Game.Screens.Play.HUD } } }; - - RequiredDisplayDigits.BindValueChanged(digits => wireframesPart.Text = new string('#', digits.NewValue)); } private string textLookup(char c) diff --git a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs index 44b9fb3123..7e0dd161dc 100644 --- a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs @@ -58,8 +58,10 @@ namespace osu.Game.Screens.Play.HUD private void updateWireframe() { - scoreText.RequiredDisplayDigits.Value = - Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount()); + int digitsRequiredForDisplayCount = Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount()); + + if (digitsRequiredForDisplayCount != scoreText.WireframeTemplate.Length) + scoreText.WireframeTemplate = new string('#', Math.Max(RequiredDisplayDigits.Value, digitsRequiredForDisplayCount)); } private int getDigitsRequiredForDisplayCount() From c3a7e998497b136e5ca97b6729de4661cc28c2d5 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 01:01:55 +0300 Subject: [PATCH 2/2] Remove unnecessary max operation --- osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs index 7e0dd161dc..a14ab3cbcd 100644 --- a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Play.HUD int digitsRequiredForDisplayCount = Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount()); if (digitsRequiredForDisplayCount != scoreText.WireframeTemplate.Length) - scoreText.WireframeTemplate = new string('#', Math.Max(RequiredDisplayDigits.Value, digitsRequiredForDisplayCount)); + scoreText.WireframeTemplate = new string('#', digitsRequiredForDisplayCount); } private int getDigitsRequiredForDisplayCount()