2019-07-21 17:14:55 +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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-08-28 20:34:34 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2019-07-21 17:14:55 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-02-22 16:14:00 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-07-21 17:14:55 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Sprites
|
|
|
|
|
{
|
2019-07-23 04:12:09 +08:00
|
|
|
|
public partial class GlowingSpriteText : Container, IHasText
|
2019-07-21 17:14:55 +08:00
|
|
|
|
{
|
2019-07-21 17:28:55 +08:00
|
|
|
|
private readonly OsuSpriteText spriteText, blurredText;
|
2019-07-21 17:14:55 +08:00
|
|
|
|
|
2021-02-22 16:14:00 +08:00
|
|
|
|
public LocalisableString Text
|
2019-07-21 17:14:55 +08:00
|
|
|
|
{
|
2019-07-23 04:12:09 +08:00
|
|
|
|
get => spriteText.Text;
|
|
|
|
|
set => blurredText.Text = spriteText.Text = value;
|
2019-07-21 17:14:55 +08:00
|
|
|
|
}
|
2019-07-23 04:16:54 +08:00
|
|
|
|
|
2019-07-21 17:14:55 +08:00
|
|
|
|
public FontUsage Font
|
|
|
|
|
{
|
2019-07-23 04:12:09 +08:00
|
|
|
|
get => spriteText.Font;
|
|
|
|
|
set => blurredText.Font = spriteText.Font = value.With(fixedWidth: true);
|
2019-07-21 17:14:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector2 TextSize
|
|
|
|
|
{
|
2019-07-23 04:12:09 +08:00
|
|
|
|
get => spriteText.Size;
|
|
|
|
|
set => blurredText.Size = spriteText.Size = value;
|
2019-07-21 17:14:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ColourInfo TextColour
|
|
|
|
|
{
|
|
|
|
|
get => spriteText.Colour;
|
|
|
|
|
set => spriteText.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ColourInfo GlowColour
|
|
|
|
|
{
|
2019-07-21 17:34:52 +08:00
|
|
|
|
get => blurredText.Colour;
|
|
|
|
|
set => blurredText.Colour = value;
|
2019-07-21 17:14:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-17 15:24:33 +08:00
|
|
|
|
public Vector2 Spacing
|
|
|
|
|
{
|
|
|
|
|
get => spriteText.Spacing;
|
|
|
|
|
set => spriteText.Spacing = blurredText.Spacing = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool UseFullGlyphHeight
|
|
|
|
|
{
|
|
|
|
|
get => spriteText.UseFullGlyphHeight;
|
|
|
|
|
set => spriteText.UseFullGlyphHeight = blurredText.UseFullGlyphHeight = value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-28 20:34:34 +08:00
|
|
|
|
public Bindable<string> Current
|
|
|
|
|
{
|
|
|
|
|
get => spriteText.Current;
|
|
|
|
|
set => spriteText.Current = value;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-21 17:14:55 +08:00
|
|
|
|
public GlowingSpriteText()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-11-05 14:54:27 +08:00
|
|
|
|
new BufferedContainer(cachedFrameBuffer: true)
|
2019-07-21 17:14:55 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
BlurSigma = new Vector2(4),
|
2019-09-05 13:41:02 +08:00
|
|
|
|
RedrawOnScale = false,
|
2019-07-21 17:14:55 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-08-21 12:29:50 +08:00
|
|
|
|
Blending = BlendingParameters.Additive,
|
2019-07-21 17:14:55 +08:00
|
|
|
|
Size = new Vector2(3f),
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2019-07-21 17:28:55 +08:00
|
|
|
|
blurredText = new OsuSpriteText
|
2019-07-21 17:14:55 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Shadow = false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
spriteText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Shadow = false,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|