1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 03:52:55 +08:00
osu-lazer/osu.Game/Online/Leaderboards/DrawableRank.cs
2019-05-07 15:09:03 +09:00

75 lines
1.9 KiB
C#

// 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.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Scoring;
namespace osu.Game.Online.Leaderboards
{
public class DrawableRank : Container
{
private readonly Sprite rankSprite;
private TextureStore textures;
public ScoreRank Rank { get; private set; }
public DrawableRank(ScoreRank rank)
{
Rank = rank;
Children = new Drawable[]
{
rankSprite = new Sprite
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fit
},
};
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
this.textures = textures;
updateTexture();
}
private void updateTexture()
{
string textureName;
switch (Rank)
{
default:
textureName = Rank.GetDescription();
break;
case ScoreRank.SH:
textureName = "SPlus";
break;
case ScoreRank.XH:
textureName = "SSPlus";
break;
}
rankSprite.Texture = textures.Get($@"Grades/{textureName}");
}
public void UpdateRank(ScoreRank newRank)
{
Rank = newRank;
if (LoadState >= LoadState.Ready)
updateTexture();
}
}
}