Files
Ez2Lazer/osu.Game/LAsEzExtensions/Extensions/SettingsButtonExtensions.cs

67 lines
2.3 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Settings;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.LAsEzExtensions.Extensions
{
/// <summary>
/// 让按钮支持同时显示两行文本的扩展方法
/// </summary>
public static class SettingsButtonExtensions
{
public static SettingsButton WithTwoLineText(this SettingsButton button, string topText, string bottomText, int fontSize = 14)
{
button.Child = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.AliceBlue,
Alpha = 0.1f
},
// 文本层
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 2),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new OsuSpriteText
{
Text = topText,
Font = OsuFont.GetFont(size: fontSize),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
new OsuSpriteText
{
Text = bottomText,
Font = OsuFont.GetFont(size: fontSize),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
}
}
}
}
};
return button;
}
}
}