1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Fix overlay header tab item not working with localisable string

This commit is contained in:
Joseph Madamba 2022-06-21 18:31:09 -07:00
parent cf0f32f928
commit 50728f3fbc

View File

@ -8,10 +8,12 @@ using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
@ -108,17 +110,25 @@ namespace osu.Game.Overlays
public OverlayHeaderTabItem(T value)
: base(value)
{
if (!(Value is Enum enumValue))
Text.Text = Value.ToString().ToLower();
else
switch (Value)
{
var localisableDescription = enumValue.GetLocalisableDescription();
string nonLocalisableDescription = enumValue.GetDescription();
case LocalisableString localisableString:
Text.Text = localisableString.ToLower();
break;
// If localisable == non-localisable, then we must have a basic string, so .ToLower() is used.
Text.Text = localisableDescription.Equals(nonLocalisableDescription)
? nonLocalisableDescription.ToLower()
: localisableDescription;
case Enum enumValue:
var localisableDescription = enumValue.GetLocalisableDescription();
string nonLocalisableDescription = enumValue.GetDescription();
// If localisable == non-localisable, then we must have a basic string, so .ToLower() is used.
Text.Text = localisableDescription.Equals(nonLocalisableDescription)
? nonLocalisableDescription.ToLower()
: localisableDescription;
break;
default:
Text.Text = Value.ToString().ToLower();
break;
}
Text.Font = OsuFont.GetFont(size: 14);