1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 10:22:56 +08:00
osu-lazer/osu.Game/Skinning/Components/DefaultTextSkinComponent.cs
2022-12-03 23:38:50 +03:00

35 lines
1.1 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.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Graphics;
namespace osu.Game.Skinning.Components
{
/// <summary>
/// Skin element that contains text and have ability to control its font.
/// </summary>
public abstract partial class DefaultTextSkinComponent : Container, ISkinnableDrawable
{
public bool UsesFixedAnchor { get; set; }
[SettingSource("Font", "Font to use.")]
public Bindable<Typeface> Font { get; } = new Bindable<Typeface>(Typeface.Torus);
protected abstract void SetFont(FontUsage font);
protected override void LoadComplete()
{
base.LoadComplete();
Font.BindValueChanged(e =>
{
FontUsage f = OsuFont.GetFont(e.NewValue, weight: e.NewValue == Typeface.Venera ? FontWeight.Bold : FontWeight.Regular);
SetFont(f);
}, true);
}
}
}