1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 19:32:58 +08:00
osu-lazer/osu.Game/Users/Drawables/DrawableFlag.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation;
namespace osu.Game.Users.Drawables
{
public partial class DrawableFlag : Sprite, IHasTooltip
{
2022-07-18 13:40:34 +08:00
private readonly CountryCode countryCode;
public LocalisableString TooltipText => countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription();
2022-07-18 13:40:34 +08:00
public DrawableFlag(CountryCode countryCode)
2019-06-18 03:33:27 +08:00
{
2022-07-18 13:40:34 +08:00
this.countryCode = countryCode;
2019-06-18 03:33:27 +08:00
}
[BackgroundDependencyLoader]
private void load(TextureStore ts)
{
ArgumentNullException.ThrowIfNull(ts);
string textureName = countryCode == CountryCode.Unknown ? "__" : countryCode.ToString();
Texture = ts.Get($@"Flags/{textureName}") ?? ts.Get(@"Flags/__");
}
}
}