mirror of
https://github.com/ppy/osu
synced 2025-01-05 21:59:46 +00:00
use switch statement
Co-authored-by: bdach <dach.bartlomiej@gmail.com>
This commit is contained in:
parent
5b4a1ef70a
commit
ca1080dfb5
@ -154,6 +154,26 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
LocalisableString text;
|
||||
switch (value)
|
||||
{
|
||||
case IHasDescription hasDescription:
|
||||
text = hasDescription.GetDescription();
|
||||
break;
|
||||
|
||||
case Enum e:
|
||||
text = e.GetLocalisableDescription();
|
||||
break;
|
||||
|
||||
case LocalisableString l:
|
||||
text = l;
|
||||
break;
|
||||
|
||||
default:
|
||||
text = value.ToString();
|
||||
break;
|
||||
};
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Text = new OsuSpriteText
|
||||
@ -161,12 +181,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Margin = new MarginPadding { Top = 5, Bottom = 5 },
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Text = value switch{
|
||||
IHasDescription desc => desc?.Description,
|
||||
Enum e => e.GetLocalisableDescription(),
|
||||
LocalisableString l => l,
|
||||
var other => other.ToString()
|
||||
},
|
||||
Text = text,
|
||||
Font = OsuFont.GetFont(size: 14)
|
||||
},
|
||||
Bar = new Box
|
||||
|
Loading…
Reference in New Issue
Block a user