2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-03-14 21:58:28 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2017-03-15 12:55:29 +08:00
|
|
|
|
using osu.Framework.Extensions;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2017-03-14 21:58:28 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select.Leaderboards
|
|
|
|
|
{
|
|
|
|
|
public class DrawableRank : Container
|
|
|
|
|
{
|
2017-03-27 21:22:34 +08:00
|
|
|
|
private readonly Sprite rankSprite;
|
2017-11-11 11:54:52 +08:00
|
|
|
|
private TextureStore textures;
|
2017-03-14 21:58:28 +08:00
|
|
|
|
|
2017-03-22 07:32:28 +08:00
|
|
|
|
public ScoreRank Rank { get; private set; }
|
2017-03-14 21:58:28 +08:00
|
|
|
|
|
|
|
|
|
public DrawableRank(ScoreRank rank)
|
|
|
|
|
{
|
2017-03-22 07:32:28 +08:00
|
|
|
|
Rank = rank;
|
2017-03-14 21:58:28 +08:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-03-29 11:21:02 +08:00
|
|
|
|
rankSprite = new Sprite
|
|
|
|
|
{
|
2017-06-28 17:24:23 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-03-29 11:21:02 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
FillMode = FillMode.Fit
|
|
|
|
|
},
|
2017-03-14 21:58:28 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2017-11-11 11:54:52 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
|
{
|
|
|
|
|
this.textures = textures;
|
|
|
|
|
updateTexture();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateTexture() => rankSprite.Texture = textures.Get($@"Grades/{Rank.GetDescription()}");
|
|
|
|
|
|
|
|
|
|
public void UpdateRank(ScoreRank newRank)
|
|
|
|
|
{
|
|
|
|
|
Rank = newRank;
|
|
|
|
|
updateTexture();
|
|
|
|
|
}
|
2017-03-14 21:58:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|