osu/osu.Game/Skinning/Components/TextElement.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.4 KiB
C#
Raw Normal View History

// 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-03 19:44:54 +00:00
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Localisation.SkinComponents;
namespace osu.Game.Skinning.Components
{
[UsedImplicitly]
public partial class TextElement : FontAdjustableSkinComponent
{
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.TextElementText), nameof(SkinnableComponentStrings.TextElementTextDescription))]
public Bindable<string> Text { get; } = new Bindable<string>("Circles!");
2022-12-03 19:44:54 +00:00
private readonly OsuSpriteText text;
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-03 19:44:54 +00:00
protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40);
2024-09-20 14:50:17 +00:00
protected override void SetTextColour(Colour4 textColour) => text.Colour = textColour;
}
}