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
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2018-12-14 10:51:27 +00:00
|
|
|
|
using osu.Framework.Extensions;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2018-11-28 07:12:57 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2019-06-17 04:34:35 +00:00
|
|
|
|
using System;
|
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-17 04:34:35 +00:00
|
|
|
|
public class DrawableRank : ModelBackedDrawable<ScoreRank>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
private TextureStore textures;
|
|
|
|
|
|
2019-06-17 04:34:35 +00:00
|
|
|
|
public ScoreRank Rank
|
|
|
|
|
{
|
|
|
|
|
get => Model;
|
|
|
|
|
set => Model = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ScoreRank rank;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public DrawableRank(ScoreRank rank)
|
|
|
|
|
{
|
2019-06-17 04:34:35 +00:00
|
|
|
|
this.rank = rank;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-06-17 04:34:35 +00:00
|
|
|
|
private void load(TextureStore ts)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-17 04:34:35 +00:00
|
|
|
|
textures = ts ?? throw new ArgumentNullException(nameof(ts));
|
|
|
|
|
Rank = rank;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-17 04:34:35 +00:00
|
|
|
|
protected override Drawable CreateDrawable(ScoreRank rank)
|
2018-08-30 22:04:40 +00:00
|
|
|
|
{
|
2019-06-17 04:34:35 +00:00
|
|
|
|
return new Sprite
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
Texture = textures.Get($"Grades/{getTextureName()}"),
|
|
|
|
|
};
|
|
|
|
|
}
|
2019-05-07 06:09:03 +00:00
|
|
|
|
|
2019-06-17 04:34:35 +00:00
|
|
|
|
private string getTextureName()
|
|
|
|
|
{
|
2019-04-22 00:57:33 +00:00
|
|
|
|
switch (Rank)
|
|
|
|
|
{
|
|
|
|
|
default:
|
2019-06-17 04:34:35 +00:00
|
|
|
|
return Rank.GetDescription();
|
2019-05-07 06:09:03 +00:00
|
|
|
|
|
2019-04-22 00:57:33 +00:00
|
|
|
|
case ScoreRank.SH:
|
2019-06-17 04:34:35 +00:00
|
|
|
|
return "SPlus";
|
2019-05-07 06:09:03 +00:00
|
|
|
|
|
2019-04-22 00:57:33 +00:00
|
|
|
|
case ScoreRank.XH:
|
2019-06-17 04:34:35 +00:00
|
|
|
|
return "SSPlus";
|
2019-04-22 00:57:33 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|