mirror of
https://github.com/ppy/osu.git
synced 2025-02-28 06:52:55 +08: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;
|
AutoSizeAxes = Axes.X;
|
||||||
RelativeSizeAxes = Axes.Y;
|
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[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Text = new OsuSpriteText
|
Text = new OsuSpriteText
|
||||||
@ -161,12 +181,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Margin = new MarginPadding { Top = 5, Bottom = 5 },
|
Margin = new MarginPadding { Top = 5, Bottom = 5 },
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Text = value switch{
|
Text = text,
|
||||||
IHasDescription desc => desc?.Description,
|
|
||||||
Enum e => e.GetLocalisableDescription(),
|
|
||||||
LocalisableString l => l,
|
|
||||||
var other => other.ToString()
|
|
||||||
},
|
|
||||||
Font = OsuFont.GetFont(size: 14)
|
Font = OsuFont.GetFont(size: 14)
|
||||||
},
|
},
|
||||||
Bar = new Box
|
Bar = new Box
|
||||||
|
Loading…
Reference in New Issue
Block a user