1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Merge pull request #27417 from bdach/fix-wireframe

Fix wireframe misalignment in argon accuracy counter
This commit is contained in:
Salman Ahmed 2024-02-29 02:26:59 +03:00 committed by GitHub
commit 274ec633db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 9 deletions

View File

@ -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 }
},
}

View File

@ -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()

View File

@ -25,7 +25,6 @@ namespace osu.Game.Screens.Play.HUD
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; }
@ -36,6 +35,18 @@ namespace osu.Game.Screens.Play.HUD
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;
@ -69,8 +80,6 @@ namespace osu.Game.Screens.Play.HUD
}
}
};
RequiredDisplayDigits.BindValueChanged(digits => wireframesPart.Text = new string('#', digits.NewValue));
}
private string textLookup(char c)

View File

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