1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

Hide attribute if the maximum is 0

This commit is contained in:
Henry Lin 2022-02-02 11:02:01 +08:00
parent b06128ffa5
commit b4fd1ecba2

View File

@ -137,8 +137,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
{
float percentage = (float)(attribute.Value / perfectAttribute.Value);
if (float.IsNaN(percentage))
percentage = 0;
string text = percentage.ToLocalisableString("0%").ToString();
return null;
return new GridContainer
{
@ -181,7 +180,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Font = OsuFont.GetFont(weight: FontWeight.SemiBold),
Text = text,
Text = percentage.ToLocalisableString("0%"),
Colour = textColour
}
}
@ -199,9 +198,12 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
foreach (PerformanceDisplayAttribute attr in displayAttributes)
{
Content.Add(attr.PropertyName == nameof(PerformanceAttributes.Total)
var attributeItem = attr.PropertyName == nameof(PerformanceAttributes.Total)
? createItemForTotal(attr, perfectDisplayAttributes.First(a => a.PropertyName == attr.PropertyName))
: createItemForAttribute(attr, perfectDisplayAttributes.First(a => a.PropertyName == attr.PropertyName)));
: createItemForAttribute(attr, perfectDisplayAttributes.First(a => a.PropertyName == attr.PropertyName));
if (attributeItem != null)
Content.Add(attributeItem);
}
}