2019-01-24 08:43:03 +00: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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-12-14 10:51:27 +00:00
|
|
|
|
using osu.Framework.Extensions;
|
2019-06-30 01:20:42 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-11-28 07:12:57 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2019-06-30 01:20:42 +00:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-12-14 10:51:27 +00:00
|
|
|
|
namespace osu.Game.Online.Leaderboards
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-30 01:20:42 +00:00
|
|
|
|
public class DrawableRank : CompositeDrawable
|
2019-06-17 17:04:09 +00:00
|
|
|
|
{
|
2019-06-17 19:33:27 +00:00
|
|
|
|
private readonly ScoreRank rank;
|
2019-06-17 17:04:09 +00:00
|
|
|
|
|
2019-06-17 19:33:27 +00:00
|
|
|
|
public DrawableRank(ScoreRank rank)
|
|
|
|
|
{
|
|
|
|
|
this.rank = rank;
|
2019-06-30 01:20:42 +00:00
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
FillMode = FillMode.Fit;
|
|
|
|
|
FillAspectRatio = 2;
|
|
|
|
|
|
2019-06-30 02:47:52 +00:00
|
|
|
|
var rankColour = getRankColour();
|
2019-06-30 01:20:42 +00:00
|
|
|
|
InternalChild = new DrawSizePreservingFillContainer
|
|
|
|
|
{
|
|
|
|
|
TargetDrawSize = new Vector2(64, 32),
|
|
|
|
|
Strategy = DrawSizePreservationStrategy.Minimum,
|
|
|
|
|
Child = new CircularContainer
|
|
|
|
|
{
|
|
|
|
|
Masking = true,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-06-30 02:47:52 +00:00
|
|
|
|
new Box
|
2019-06-30 01:20:42 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-06-30 02:47:52 +00:00
|
|
|
|
Colour = rankColour,
|
2019-06-30 01:20:42 +00:00
|
|
|
|
},
|
2019-06-30 02:47:52 +00:00
|
|
|
|
new Triangles
|
2019-06-30 01:20:42 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-06-30 02:47:52 +00:00
|
|
|
|
ColourDark = rankColour.Darken(0.1f),
|
|
|
|
|
ColourLight = rankColour.Lighten(0.1f),
|
|
|
|
|
Velocity = 0.25f,
|
2019-06-30 01:20:42 +00:00
|
|
|
|
},
|
2019-06-30 02:47:52 +00:00
|
|
|
|
new OsuSpriteText
|
2019-06-30 01:20:42 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-06-30 05:05:45 +00:00
|
|
|
|
Spacing = new Vector2(-3, 0),
|
2019-06-30 01:20:42 +00:00
|
|
|
|
Padding = new MarginPadding { Top = 5 },
|
2019-06-30 02:47:52 +00:00
|
|
|
|
Colour = getRankNameColour(),
|
2019-06-30 01:20:42 +00:00
|
|
|
|
Font = OsuFont.GetFont(Typeface.Venera, 25),
|
|
|
|
|
Text = getRankName(),
|
2019-06-30 05:05:45 +00:00
|
|
|
|
ShadowColour = Color4.Black.Opacity(0.3f),
|
|
|
|
|
ShadowOffset = new Vector2(0, 0.08f),
|
|
|
|
|
Shadow = true,
|
2019-06-30 01:20:42 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-06-17 19:33:27 +00:00
|
|
|
|
}
|
2019-06-17 17:04:09 +00:00
|
|
|
|
|
2019-06-30 01:20:42 +00:00
|
|
|
|
private string getRankName() => rank.GetDescription().TrimEnd('+');
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the grade background colour.
|
|
|
|
|
/// </summary>
|
2019-06-30 02:47:52 +00:00
|
|
|
|
private Color4 getRankColour()
|
2019-06-17 04:34:35 +00:00
|
|
|
|
{
|
2019-06-17 17:04:09 +00:00
|
|
|
|
switch (rank)
|
2019-04-22 00:57:33 +00:00
|
|
|
|
{
|
2019-06-30 01:20:42 +00:00
|
|
|
|
case ScoreRank.XH:
|
|
|
|
|
case ScoreRank.X:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return OsuColour.FromHex(@"ce1c9d");
|
2019-05-07 06:09:03 +00:00
|
|
|
|
|
2019-04-22 00:57:33 +00:00
|
|
|
|
case ScoreRank.SH:
|
2019-06-30 01:20:42 +00:00
|
|
|
|
case ScoreRank.S:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return OsuColour.FromHex(@"00a8b5");
|
2019-06-30 01:20:42 +00:00
|
|
|
|
|
|
|
|
|
case ScoreRank.A:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return OsuColour.FromHex(@"7cce14");
|
2019-06-30 01:20:42 +00:00
|
|
|
|
|
|
|
|
|
case ScoreRank.B:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return OsuColour.FromHex(@"e3b130");
|
2019-05-07 06:09:03 +00:00
|
|
|
|
|
2019-06-30 01:20:42 +00:00
|
|
|
|
case ScoreRank.C:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return OsuColour.FromHex(@"f18252");
|
2019-06-30 01:20:42 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return OsuColour.FromHex(@"e95353");
|
2019-06-30 01:20:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the grade text colour.
|
|
|
|
|
/// </summary>
|
2019-06-30 02:47:52 +00:00
|
|
|
|
private ColourInfo getRankNameColour()
|
2019-06-30 01:20:42 +00:00
|
|
|
|
{
|
|
|
|
|
switch (rank)
|
|
|
|
|
{
|
2019-04-22 00:57:33 +00:00
|
|
|
|
case ScoreRank.XH:
|
2019-06-30 01:20:42 +00:00
|
|
|
|
case ScoreRank.SH:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return ColourInfo.GradientVertical(Color4.White, OsuColour.FromHex("afdff0"));
|
2019-06-30 01:20:42 +00:00
|
|
|
|
|
|
|
|
|
case ScoreRank.X:
|
|
|
|
|
case ScoreRank.S:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return ColourInfo.GradientVertical(OsuColour.FromHex(@"ffe7a8"), OsuColour.FromHex(@"ffb800"));
|
|
|
|
|
|
|
|
|
|
case ScoreRank.A:
|
|
|
|
|
return OsuColour.FromHex(@"275227");
|
|
|
|
|
|
|
|
|
|
case ScoreRank.B:
|
|
|
|
|
return OsuColour.FromHex(@"553a2b");
|
|
|
|
|
|
|
|
|
|
case ScoreRank.C:
|
|
|
|
|
return OsuColour.FromHex(@"473625");
|
2019-06-30 01:20:42 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2019-06-30 02:47:52 +00:00
|
|
|
|
return OsuColour.FromHex(@"512525");
|
2019-04-22 00:57:33 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|