1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 10:23:03 +08:00

Merge pull request #26573 from EVAST9919/leaderboard-glow-remove

Fix multiple issues with `GlowingSpriteText`
This commit is contained in:
Dean Herbert 2024-01-17 13:17:03 +09:00 committed by GitHub
commit 68fb1b8663
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 49 deletions

View File

@ -5,95 +5,90 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Utils;
using osuTK; using osuTK;
namespace osu.Game.Graphics.Sprites namespace osu.Game.Graphics.Sprites
{ {
public partial class GlowingSpriteText : Container, IHasText public partial class GlowingSpriteText : BufferedContainer, IHasText
{ {
private readonly OsuSpriteText spriteText, blurredText; private const float blur_sigma = 3f;
// Inflate draw quad to prevent glow from trimming at the edges.
// Padding won't suffice since it will affect text position in cases when it's not centered.
protected override Quad ComputeScreenSpaceDrawQuad() => base.ComputeScreenSpaceDrawQuad().AABBFloat.Inflate(Blur.KernelSize(blur_sigma));
private readonly OsuSpriteText text;
public LocalisableString Text public LocalisableString Text
{ {
get => spriteText.Text; get => text.Text;
set => blurredText.Text = spriteText.Text = value; set => text.Text = value;
} }
public FontUsage Font public FontUsage Font
{ {
get => spriteText.Font; get => text.Font;
set => blurredText.Font = spriteText.Font = value.With(fixedWidth: true); set => text.Font = value.With(fixedWidth: true);
} }
public Vector2 TextSize public Vector2 TextSize
{ {
get => spriteText.Size; get => text.Size;
set => blurredText.Size = spriteText.Size = value; set => text.Size = value;
} }
public ColourInfo TextColour public ColourInfo TextColour
{ {
get => spriteText.Colour; get => text.Colour;
set => spriteText.Colour = value; set => text.Colour = value;
} }
public ColourInfo GlowColour public ColourInfo GlowColour
{ {
get => blurredText.Colour; get => EffectColour;
set => blurredText.Colour = value; set
{
EffectColour = value;
BackgroundColour = value.MultiplyAlpha(0f);
}
} }
public Vector2 Spacing public Vector2 Spacing
{ {
get => spriteText.Spacing; get => text.Spacing;
set => spriteText.Spacing = blurredText.Spacing = value; set => text.Spacing = value;
} }
public bool UseFullGlyphHeight public bool UseFullGlyphHeight
{ {
get => spriteText.UseFullGlyphHeight; get => text.UseFullGlyphHeight;
set => spriteText.UseFullGlyphHeight = blurredText.UseFullGlyphHeight = value; set => text.UseFullGlyphHeight = value;
} }
public Bindable<string> Current public Bindable<string> Current
{ {
get => spriteText.Current; get => text.Current;
set => spriteText.Current = value; set => text.Current = value;
} }
public GlowingSpriteText() public GlowingSpriteText()
: base(cachedFrameBuffer: true)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
BlurSigma = new Vector2(blur_sigma);
Children = new Drawable[] RedrawOnScale = false;
{ DrawOriginal = true;
new BufferedContainer(cachedFrameBuffer: true) EffectBlending = BlendingParameters.Additive;
{ EffectPlacement = EffectPlacement.InFront;
Anchor = Anchor.Centre, Child = text = new OsuSpriteText
Origin = Anchor.Centre,
BlurSigma = new Vector2(4),
RedrawOnScale = false,
RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive,
Size = new Vector2(3f),
Children = new[]
{
blurredText = new OsuSpriteText
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Shadow = false, Shadow = false,
},
},
},
spriteText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Shadow = false,
},
}; };
} }
} }

View File

@ -358,14 +358,12 @@ namespace osu.Game.Online.Leaderboards
}, },
}, },
}, },
new GlowingSpriteText new OsuSpriteText
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
TextColour = Color4.White,
GlowColour = Color4Extensions.FromHex(@"83ccfa"),
Text = statistic.Value, Text = statistic.Value,
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold), Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold, fixedWidth: true)
}, },
}, },
}; };