mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:52:54 +08:00
add tooltip to country flags
This commit is contained in:
parent
be8c3d2e97
commit
f7fe083018
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
Font = @"Exo2.0-RegularItalic",
|
Font = @"Exo2.0-RegularItalic",
|
||||||
Margin = new MarginPadding { Left = side_margin }
|
Margin = new MarginPadding { Left = side_margin }
|
||||||
},
|
},
|
||||||
new DrawableFlag(score.User.Country?.FlagName)
|
new DrawableFlag(score.User.Country)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
score = value;
|
score = value;
|
||||||
|
|
||||||
avatar.User = username.User = score.User;
|
avatar.User = username.User = score.User;
|
||||||
flag.FlagName = score.User.Country?.FlagName;
|
flag.Country = score.User.Country;
|
||||||
date.Text = $@"achieved {score.Date:MMM d, yyyy}";
|
date.Text = $@"achieved {score.Date:MMM d, yyyy}";
|
||||||
rank.UpdateRank(score.Rank);
|
rank.UpdateRank(score.Rank);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Y = -48,
|
Y = -48,
|
||||||
},
|
},
|
||||||
countryFlag = new DrawableFlag(user.Country?.FlagName)
|
countryFlag = new DrawableFlag(user.Country)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
@ -333,7 +333,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
{
|
{
|
||||||
infoTextLeft.AddText("from ");
|
infoTextLeft.AddText("from ");
|
||||||
infoTextLeft.AddText(user.Country.FullName, boldItalic);
|
infoTextLeft.AddText(user.Country.FullName, boldItalic);
|
||||||
countryFlag.FlagName = user.Country.FlagName;
|
countryFlag.Country = user.Country;
|
||||||
}
|
}
|
||||||
infoTextLeft.NewParagraph();
|
infoTextLeft.NewParagraph();
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Screens.Multiplayer
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
host.Text = value.Username;
|
host.Text = value.Username;
|
||||||
flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName) { RelativeSizeAxes = Axes.Both } };
|
flagContainer.Children = new[] { new DrawableFlag(value.Country) { RelativeSizeAxes = Axes.Both } };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
Masking = true,
|
Masking = true,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DrawableFlag(Score.User?.Country?.FlagName)
|
new DrawableFlag(Score.User?.Country)
|
||||||
{
|
{
|
||||||
Width = 30,
|
Width = 30,
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
|
||||||
@ -26,36 +27,30 @@ namespace osu.Game.Users
|
|||||||
public string FlagName;
|
public string FlagName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DrawableFlag : Container
|
public class DrawableFlag : Container, IHasTooltip
|
||||||
{
|
{
|
||||||
private readonly Sprite sprite;
|
private readonly Sprite sprite;
|
||||||
private TextureStore textures;
|
private TextureStore textures;
|
||||||
|
|
||||||
private string flagName;
|
private Country country;
|
||||||
public string FlagName
|
public Country Country
|
||||||
{
|
{
|
||||||
get { return flagName; }
|
get { return country; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == flagName) return;
|
if (value == country)
|
||||||
flagName = value;
|
return;
|
||||||
sprite.Texture = textures.Get($@"Flags/{flagName}");
|
|
||||||
|
country = value;
|
||||||
|
sprite.Texture = getFlagTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
public string TooltipText => country?.FullName;
|
||||||
private void load(TextureStore ts)
|
|
||||||
|
public DrawableFlag(Country country = null)
|
||||||
{
|
{
|
||||||
if (ts == null)
|
this.country = country;
|
||||||
throw new ArgumentNullException(nameof(ts));
|
|
||||||
|
|
||||||
textures = ts;
|
|
||||||
sprite.Texture = textures.Get($@"Flags/{flagName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawableFlag(string name = null)
|
|
||||||
{
|
|
||||||
flagName = name ?? @"__";
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
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 ?? @"__"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ namespace osu.Game.Users
|
|||||||
Spacing = new Vector2(5f, 0f),
|
Spacing = new Vector2(5f, 0f),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DrawableFlag(user.Country?.FlagName)
|
new DrawableFlag(user.Country)
|
||||||
{
|
{
|
||||||
Width = 30f,
|
Width = 30f,
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Loading…
Reference in New Issue
Block a user