2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-12-14 18:51:27 +08:00
|
|
|
|
using osu.Framework.Extensions;
|
2019-06-30 09:20:42 +08: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 15:12:57 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2019-06-30 09:20:42 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-12-14 18:51:27 +08:00
|
|
|
|
namespace osu.Game.Online.Leaderboards
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-30 09:20:42 +08:00
|
|
|
|
public class DrawableRank : CompositeDrawable
|
2019-06-18 01:04:09 +08:00
|
|
|
|
{
|
2019-06-18 03:33:27 +08:00
|
|
|
|
private readonly ScoreRank rank;
|
2019-06-18 01:04:09 +08:00
|
|
|
|
|
2019-06-18 03:33:27 +08:00
|
|
|
|
public DrawableRank(ScoreRank rank)
|
|
|
|
|
{
|
|
|
|
|
this.rank = rank;
|
2019-06-30 09:20:42 +08:00
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
FillMode = FillMode.Fit;
|
|
|
|
|
FillAspectRatio = 2;
|
|
|
|
|
|
2020-03-17 15:25:41 +08:00
|
|
|
|
var rankColour = OsuColour.ForRank(rank);
|
2019-06-30 09:20:42 +08: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 10:47:52 +08:00
|
|
|
|
new Box
|
2019-06-30 09:20:42 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-06-30 10:47:52 +08:00
|
|
|
|
Colour = rankColour,
|
2019-06-30 09:20:42 +08:00
|
|
|
|
},
|
2019-06-30 10:47:52 +08:00
|
|
|
|
new Triangles
|
2019-06-30 09:20:42 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-06-30 10:47:52 +08:00
|
|
|
|
ColourDark = rankColour.Darken(0.1f),
|
|
|
|
|
ColourLight = rankColour.Lighten(0.1f),
|
|
|
|
|
Velocity = 0.25f,
|
2019-06-30 09:20:42 +08:00
|
|
|
|
},
|
2019-06-30 10:47:52 +08:00
|
|
|
|
new OsuSpriteText
|
2019-06-30 09:20:42 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-06-30 13:05:45 +08:00
|
|
|
|
Spacing = new Vector2(-3, 0),
|
2019-06-30 09:20:42 +08:00
|
|
|
|
Padding = new MarginPadding { Top = 5 },
|
2019-06-30 10:47:52 +08:00
|
|
|
|
Colour = getRankNameColour(),
|
2020-03-04 10:21:37 +08:00
|
|
|
|
Font = OsuFont.Numeric.With(size: 25),
|
2020-03-17 15:25:51 +08:00
|
|
|
|
Text = GetRankName(rank),
|
2019-06-30 13:05:45 +08:00
|
|
|
|
ShadowColour = Color4.Black.Opacity(0.3f),
|
|
|
|
|
ShadowOffset = new Vector2(0, 0.08f),
|
|
|
|
|
Shadow = true,
|
2019-06-30 09:20:42 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-06-18 03:33:27 +08:00
|
|
|
|
}
|
2019-06-18 01:04:09 +08:00
|
|
|
|
|
2020-03-17 15:25:51 +08:00
|
|
|
|
public static string GetRankName(ScoreRank rank) => rank.GetDescription().TrimEnd('+');
|
2019-06-30 09:20:42 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the grade text colour.
|
|
|
|
|
/// </summary>
|
2019-06-30 10:47:52 +08:00
|
|
|
|
private ColourInfo getRankNameColour()
|
2019-06-30 09:20:42 +08:00
|
|
|
|
{
|
|
|
|
|
switch (rank)
|
|
|
|
|
{
|
2019-04-22 08:57:33 +08:00
|
|
|
|
case ScoreRank.XH:
|
2019-06-30 09:20:42 +08:00
|
|
|
|
case ScoreRank.SH:
|
2020-03-11 09:18:41 +08:00
|
|
|
|
return ColourInfo.GradientVertical(Color4.White, Color4Extensions.FromHex("afdff0"));
|
2019-06-30 09:20:42 +08:00
|
|
|
|
|
|
|
|
|
case ScoreRank.X:
|
|
|
|
|
case ScoreRank.S:
|
2020-03-11 09:18:41 +08:00
|
|
|
|
return ColourInfo.GradientVertical(Color4Extensions.FromHex(@"ffe7a8"), Color4Extensions.FromHex(@"ffb800"));
|
2019-06-30 10:47:52 +08:00
|
|
|
|
|
|
|
|
|
case ScoreRank.A:
|
2020-03-11 09:18:41 +08:00
|
|
|
|
return Color4Extensions.FromHex(@"275227");
|
2019-06-30 10:47:52 +08:00
|
|
|
|
|
|
|
|
|
case ScoreRank.B:
|
2020-03-11 09:18:41 +08:00
|
|
|
|
return Color4Extensions.FromHex(@"553a2b");
|
2019-06-30 10:47:52 +08:00
|
|
|
|
|
|
|
|
|
case ScoreRank.C:
|
2020-03-11 09:18:41 +08:00
|
|
|
|
return Color4Extensions.FromHex(@"473625");
|
2019-06-30 09:20:42 +08:00
|
|
|
|
|
|
|
|
|
default:
|
2020-03-11 09:18:41 +08:00
|
|
|
|
return Color4Extensions.FromHex(@"512525");
|
2019-04-22 08:57:33 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|