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
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2018-12-14 18:51:27 +08:00
|
|
|
|
using osu.Framework.Extensions;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2018-11-28 15:12:57 +08:00
|
|
|
|
using osu.Game.Scoring;
|
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
|
|
|
|
{
|
|
|
|
|
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]
|
2018-08-31 06:04:40 +08:00
|
|
|
|
private void load(TextureStore textures)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
this.textures = textures;
|
2018-08-31 06:04:40 +08:00
|
|
|
|
updateTexture();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 06:04:40 +08:00
|
|
|
|
private void updateTexture()
|
|
|
|
|
{
|
|
|
|
|
rankSprite.Texture = textures.Get($@"Grades/{Rank.GetDescription()}");
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public void UpdateRank(ScoreRank newRank)
|
|
|
|
|
{
|
|
|
|
|
Rank = newRank;
|
2018-07-09 16:09:17 +08:00
|
|
|
|
|
2018-07-13 18:53:29 +08:00
|
|
|
|
if (LoadState >= LoadState.Ready)
|
2018-08-31 06:04:40 +08:00
|
|
|
|
updateTexture();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|