mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
add tooltip to country flags
This commit is contained in:
@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
|
||||
@ -26,36 +27,30 @@ namespace osu.Game.Users
|
||||
public string FlagName;
|
||||
}
|
||||
|
||||
public class DrawableFlag : Container
|
||||
public class DrawableFlag : Container, IHasTooltip
|
||||
{
|
||||
private readonly Sprite sprite;
|
||||
private TextureStore textures;
|
||||
|
||||
private string flagName;
|
||||
public string FlagName
|
||||
private Country country;
|
||||
public Country Country
|
||||
{
|
||||
get { return flagName; }
|
||||
get { return country; }
|
||||
set
|
||||
{
|
||||
if (value == flagName) return;
|
||||
flagName = value;
|
||||
sprite.Texture = textures.Get($@"Flags/{flagName}");
|
||||
if (value == country)
|
||||
return;
|
||||
|
||||
country = value;
|
||||
sprite.Texture = getFlagTexture();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore ts)
|
||||
{
|
||||
if (ts == null)
|
||||
throw new ArgumentNullException(nameof(ts));
|
||||
public string TooltipText => country?.FullName;
|
||||
|
||||
textures = ts;
|
||||
sprite.Texture = textures.Get($@"Flags/{flagName}");
|
||||
}
|
||||
|
||||
public DrawableFlag(string name = null)
|
||||
public DrawableFlag(Country country = null)
|
||||
{
|
||||
flagName = name ?? @"__";
|
||||
this.country = country;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -65,5 +60,17 @@ namespace osu.Game.Users
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore ts)
|
||||
{
|
||||
if (ts == null)
|
||||
throw new ArgumentNullException(nameof(ts));
|
||||
|
||||
textures = ts;
|
||||
sprite.Texture = getFlagTexture();
|
||||
}
|
||||
|
||||
private Texture getFlagTexture() => textures.Get($@"Flags/{country?.FlagName ?? @"__"}");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user