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