2019-01-24 16:43:03 +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.
|
2018-09-27 15:27:11 +08:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-02-22 16:14:00 +08:00
|
|
|
using osu.Framework.Localisation;
|
2018-09-27 15:27:11 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
2019-07-19 17:38:24 +08:00
|
|
|
public class SkinnableSpriteText : SkinnableDrawable, IHasText
|
2018-09-27 15:27:11 +08:00
|
|
|
{
|
2019-12-06 13:40:45 +08:00
|
|
|
public SkinnableSpriteText(ISkinComponent component, Func<ISkinComponent, SpriteText> defaultImplementation, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
2019-08-30 13:39:02 +08:00
|
|
|
: base(component, defaultImplementation, allowFallback, confineMode)
|
2018-09-27 15:27:11 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
|
|
|
{
|
|
|
|
base.SkinChanged(skin, allowFallback);
|
|
|
|
|
|
|
|
if (Drawable is IHasText textDrawable)
|
|
|
|
textDrawable.Text = Text;
|
|
|
|
}
|
|
|
|
|
2021-02-22 16:14:00 +08:00
|
|
|
private LocalisableString text;
|
2018-09-27 15:27:11 +08:00
|
|
|
|
2021-02-22 16:14:00 +08:00
|
|
|
public LocalisableString Text
|
2018-09-27 15:27:11 +08:00
|
|
|
{
|
|
|
|
get => text;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (text == value)
|
|
|
|
return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2018-09-27 15:27:11 +08:00
|
|
|
text = value;
|
|
|
|
|
|
|
|
if (Drawable is IHasText textDrawable)
|
|
|
|
textDrawable.Text = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|