1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 04:52:56 +08:00
osu-lazer/osu.Game/Screens/Ranking/Expanded/Accuracy/RankText.cs

138 lines
4.6 KiB
C#
Raw Normal View History

2020-03-17 15:37:56 +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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2020-03-17 17:04:32 +08:00
using osu.Framework.Graphics.Shapes;
2020-03-17 15:37:56 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Leaderboards;
using osu.Game.Scoring;
using osuTK;
2020-03-17 17:04:32 +08:00
using osuTK.Graphics;
2020-03-17 15:37:56 +08:00
namespace osu.Game.Screens.Ranking.Expanded.Accuracy
{
/// <summary>
/// The text that appears in the middle of the <see cref="AccuracyCircle"/> displaying the user's rank.
/// </summary>
public class RankText : CompositeDrawable
{
private readonly ScoreRank rank;
2020-03-17 17:04:32 +08:00
private BufferedContainer flash;
private BufferedContainer superFlash;
private GlowingSpriteText rankText;
2020-03-17 15:37:56 +08:00
public RankText(ScoreRank rank)
{
this.rank = rank;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Alpha = 0;
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
2020-03-17 17:04:32 +08:00
InternalChildren = new Drawable[]
2020-03-17 15:37:56 +08:00
{
2020-03-17 17:04:32 +08:00
rankText = new GlowingSpriteText
2020-03-17 15:37:56 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2020-03-17 17:04:32 +08:00
GlowColour = OsuColour.ForRank(rank),
2020-03-17 15:37:56 +08:00
Spacing = new Vector2(-15, 0),
Text = DrawableRank.GetRankName(rank),
Font = OsuFont.Numeric.With(size: 76),
UseFullGlyphHeight = false
},
2020-03-17 17:04:32 +08:00
superFlash = new BufferedContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
BlurSigma = new Vector2(85),
Size = new Vector2(600),
CacheDrawnFrameBuffer = true,
Blending = BlendingParameters.Additive,
Alpha = 0,
Children = new[]
{
new Box
{
Colour = Color4.White,
Size = new Vector2(150),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
},
},
2020-03-17 15:37:56 +08:00
flash = new BufferedContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
BlurSigma = new Vector2(35),
BypassAutoSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
2020-03-17 17:04:32 +08:00
CacheDrawnFrameBuffer = true,
2020-03-17 15:37:56 +08:00
Blending = BlendingParameters.Additive,
2020-03-17 17:04:32 +08:00
Alpha = 0,
Size = new Vector2(2f), // increase buffer size to allow for scale
2020-03-17 15:37:56 +08:00
Scale = new Vector2(1.8f),
Children = new[]
{
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Spacing = new Vector2(-15, 0),
Text = DrawableRank.GetRankName(rank),
Font = OsuFont.Numeric.With(size: 76),
UseFullGlyphHeight = false,
Shadow = false
},
},
},
};
}
public void Appear()
{
2020-03-17 17:04:32 +08:00
this.FadeIn();
if (rank < ScoreRank.A)
{
this
.MoveToOffset(new Vector2(0, -20))
.MoveToOffset(new Vector2(0, 20), 200, Easing.OutBounce);
if (rank <= ScoreRank.D)
{
this.Delay(700)
.RotateTo(5, 150, Easing.In)
.MoveToOffset(new Vector2(0, 3), 150, Easing.In);
}
this.FadeInFromZero(200, Easing.OutQuint);
return;
}
flash.Colour = OsuColour.ForRank(rank);
flash.FadeIn().Then().FadeOut(1200, Easing.OutQuint);
2020-03-17 15:37:56 +08:00
2020-03-17 17:04:32 +08:00
if (rank >= ScoreRank.S)
rankText.ScaleTo(1.05f).ScaleTo(1, 3000, Easing.OutQuint);
if (rank >= ScoreRank.X)
{
flash.FadeIn().Then().FadeOut(3000);
superFlash.FadeIn().Then().FadeOut(800, Easing.OutQuint);
}
2020-03-17 15:37:56 +08:00
}
}
}