Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wireframe misalignment in argon accuracy counter #27417

Merged
merged 3 commits into from Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs
Expand Up @@ -75,21 +75,21 @@ public ArgonAccuracyTextComponent()
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 }
},
}
Expand Down
5 changes: 4 additions & 1 deletion osu.Game/Screens/Play/HUD/ArgonComboCounter.cs
Expand Up @@ -68,7 +68,10 @@ public override int DisplayedCount

private void updateWireframe()
{
text.RequiredDisplayDigits.Value = getDigitsRequiredForDisplayCount();
int digitsRequiredForDisplayCount = getDigitsRequiredForDisplayCount();

if (digitsRequiredForDisplayCount != text.WireframeTemplate.Length)
text.WireframeTemplate = new string('#', digitsRequiredForDisplayCount);
}

private int getDigitsRequiredForDisplayCount()
Expand Down
15 changes: 12 additions & 3 deletions osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs
Expand Up @@ -25,7 +25,6 @@ public partial class ArgonCounterTextComponent : CompositeDrawable, IHasText
private readonly OsuSpriteText labelText;

public IBindable<float> WireframeOpacity { get; } = new BindableFloat();
public Bindable<int> RequiredDisplayDigits { get; } = new BindableInt();
public Bindable<bool> ShowLabel { get; } = new BindableBool();

public Container NumberContainer { get; private set; }
Expand All @@ -36,6 +35,18 @@ public LocalisableString Text
set => textPart.Text = value;
}

/// <summary>
/// The template for the wireframe displayed behind the <see cref="Text"/>.
/// Any character other than a dot is interpreted to mean a full segmented display "wireframe".
/// </summary>
public string WireframeTemplate
{
get => wireframeTemplate;
set => wireframesPart.Text = wireframeTemplate = value;
}

private string wireframeTemplate = string.Empty;

public ArgonCounterTextComponent(Anchor anchor, LocalisableString? label = null)
{
Anchor = anchor;
Expand Down Expand Up @@ -69,8 +80,6 @@ public ArgonCounterTextComponent(Anchor anchor, LocalisableString? label = null)
}
}
};

RequiredDisplayDigits.BindValueChanged(digits => wireframesPart.Text = new string('#', digits.NewValue));
}

private string textLookup(char c)
Expand Down
6 changes: 4 additions & 2 deletions osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs
Expand Up @@ -58,8 +58,10 @@ public override long DisplayedCount

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('#', digitsRequiredForDisplayCount);
}

private int getDigitsRequiredForDisplayCount()
Expand Down