2022-11-02 03:54:52 +08:00
|
|
|
// 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 JetBrains.Annotations;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
2022-12-04 03:44:54 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-11-02 03:54:52 +08:00
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2023-02-03 14:34:57 +08:00
|
|
|
using osu.Game.Localisation.SkinComponents;
|
2022-11-02 03:54:52 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Skinning.Components
|
|
|
|
{
|
|
|
|
[UsedImplicitly]
|
2023-01-26 15:04:56 +08:00
|
|
|
public partial class TextElement : FontAdjustableSkinComponent
|
2022-11-02 03:54:52 +08:00
|
|
|
{
|
2023-02-03 15:02:16 +08:00
|
|
|
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.TextElementText), nameof(SkinnableComponentStrings.TextElementTextDescription))]
|
2022-11-02 03:54:52 +08:00
|
|
|
public Bindable<string> Text { get; } = new Bindable<string>("Circles!");
|
|
|
|
|
2022-12-04 03:44:54 +08:00
|
|
|
private readonly OsuSpriteText text;
|
|
|
|
|
2022-11-02 03:54:52 +08:00
|
|
|
public TextElement()
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
text = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Font = OsuFont.Default.With(size: 40)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
text.Current.BindTo(Text);
|
|
|
|
}
|
2022-12-04 03:44:54 +08:00
|
|
|
|
|
|
|
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
|
2024-08-06 17:06:08 +08:00
|
|
|
|
|
|
|
protected override void SetFontColour(Colour4 fontColour) => text.Colour = fontColour;
|
2022-11-02 03:54:52 +08:00
|
|
|
}
|
|
|
|
}
|