osu/osu.Game/Online/Leaderboards/DrawableRank.cs

47 lines
1.1 KiB
C#
Raw Normal View History

// 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;
using osu.Framework.Extensions;
2018-04-13 09:19:50 +00:00
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
2018-11-28 07:12:57 +00:00
using osu.Game.Scoring;
using System;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Online.Leaderboards
2018-04-13 09:19:50 +00:00
{
public class DrawableRank : Sprite
{
2019-06-17 19:33:27 +00:00
private readonly ScoreRank rank;
2019-06-17 19:33:27 +00:00
public DrawableRank(ScoreRank rank)
{
this.rank = rank;
}
[BackgroundDependencyLoader(true)]
private void load(TextureStore ts)
2018-04-13 09:19:50 +00:00
{
if (ts == null)
throw new ArgumentNullException(nameof(ts));
2018-04-13 09:19:50 +00:00
Texture = ts.Get($@"Grades/{getTextureName()}");
}
2019-05-07 06:09:03 +00:00
private string getTextureName()
{
switch (rank)
2019-04-22 00:57:33 +00:00
{
default:
return rank.GetDescription();
2019-05-07 06:09:03 +00:00
2019-04-22 00:57:33 +00:00
case ScoreRank.SH:
return "SPlus";
2019-05-07 06:09:03 +00:00
2019-04-22 00:57:33 +00:00
case ScoreRank.XH:
return "SSPlus";
2019-04-22 00:57:33 +00:00
}
2018-04-13 09:19:50 +00:00
}
}
}