1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 07:27:25 +08:00

Separate glowing sprite text into it's own class

This commit is contained in:
iiSaLMaN 2019-07-21 12:14:55 +03:00
parent 38d39be678
commit ed0ef90613
2 changed files with 122 additions and 45 deletions

View File

@ -0,0 +1,110 @@
// 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.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Graphics.Sprites
{
public class GlowingSpriteText : Container
{
private readonly BufferedContainer blurContainer;
private readonly OsuSpriteText spriteText, glowingText;
private string text = string.Empty;
public string Text
{
get => text;
set
{
text = value;
spriteText.Text = text;
glowingText.Text = text;
}
}
private FontUsage font = OsuFont.Default.With(fixedWidth: true);
public FontUsage Font
{
get => font;
set
{
font = value.With(fixedWidth: true);
spriteText.Font = font;
glowingText.Font = font;
}
}
private Vector2 textSize;
public Vector2 TextSize
{
get => textSize;
set
{
textSize = value;
spriteText.Size = textSize;
glowingText.Size = textSize;
}
}
public ColourInfo TextColour
{
get => spriteText.Colour;
set => spriteText.Colour = value;
}
public ColourInfo GlowColour
{
get => glowingText.Colour;
set => glowingText.Colour = value;
}
public GlowingSpriteText()
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
blurContainer = new BufferedContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
BlurSigma = new Vector2(4),
CacheDrawnFrameBuffer = true,
RelativeSizeAxes = Axes.Both,
Blending = BlendingMode.Additive,
Size = new Vector2(3f),
Children = new[]
{
glowingText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = font,
Text = text,
Shadow = false,
},
},
},
spriteText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = font,
Text = text,
Shadow = false,
},
};
}
}
}

View File

@ -187,7 +187,13 @@ namespace osu.Game.Online.Leaderboards
Spacing = new Vector2(5f, 0f),
Children = new Drawable[]
{
scoreLabel = new GlowingSpriteText(score.TotalScore.ToString(@"N0"), OsuFont.Numeric.With(size: 23), Color4.White, OsuColour.FromHex(@"83ccfa")),
scoreLabel = new GlowingSpriteText
{
TextColour = Color4.White,
GlowColour = OsuColour.FromHex(@"83ccfa"),
Text = score.TotalScore.ToString(@"N0"),
Font = OsuFont.Numeric.With(size: 23),
},
RankContainer = new Container
{
Size = new Vector2(40f, 20f),
@ -275,49 +281,6 @@ namespace osu.Game.Online.Leaderboards
base.OnHoverLost(e);
}
private class GlowingSpriteText : Container
{
public GlowingSpriteText(string text, FontUsage font, Color4 textColour, Color4 glowColour)
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new BufferedContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
BlurSigma = new Vector2(4),
CacheDrawnFrameBuffer = true,
RelativeSizeAxes = Axes.Both,
Blending = BlendingMode.Additive,
Size = new Vector2(3f),
Children = new[]
{
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = font.With(fixedWidth: true),
Text = text,
Colour = glowColour,
Shadow = false,
},
},
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = font.With(fixedWidth: true),
Text = text,
Colour = textColour,
Shadow = false,
},
};
}
}
private class ScoreComponentLabel : Container, IHasTooltip
{
private const float icon_size = 20;
@ -367,10 +330,14 @@ namespace osu.Game.Online.Leaderboards
},
},
},
new GlowingSpriteText(statistic.Value, OsuFont.GetFont(size: 17, weight: FontWeight.Bold), Color4.White, OsuColour.FromHex(@"83ccfa"))
new GlowingSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
TextColour = Color4.White,
GlowColour = OsuColour.FromHex(@"83ccfa"),
Text = statistic.Value,
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold),
},
},
};