osu/osu.Game/Graphics/Sprites/GlowingSpriteText.cs

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

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