1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:52:55 +08:00

Update various usages of Country inline with new enum

This commit is contained in:
Salman Ahmed 2022-07-16 04:40:37 +03:00
parent b2b2a4adaf
commit e62049f4a9
19 changed files with 74 additions and 177 deletions

View File

@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual.Online
Id = 3103765, Id = 3103765,
IsOnline = true, IsOnline = true,
Statistics = new UserStatistics { GlobalRank = 1111 }, Statistics = new UserStatistics { GlobalRank = 1111 },
Country = new Country { FlagName = "JP" }, Country = Country.JP,
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
}, },
new APIUser new APIUser
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
Id = 2, Id = 2,
IsOnline = false, IsOnline = false,
Statistics = new UserStatistics { GlobalRank = 2222 }, Statistics = new UserStatistics { GlobalRank = 2222 },
Country = new Country { FlagName = "AU" }, Country = Country.AU,
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsSupporter = true, IsSupporter = true,
SupportLevel = 3, SupportLevel = 3,
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Username = "Evast", Username = "Evast",
Id = 8195163, Id = 8195163,
Country = new Country { FlagName = "BY" }, Country = Country.BY,
CoverUrl = "https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg", CoverUrl = "https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
IsOnline = false, IsOnline = false,
LastVisit = DateTimeOffset.Now LastVisit = DateTimeOffset.Now

View File

@ -56,20 +56,12 @@ namespace osu.Game.Tests.Visual.Online
} }
}); });
var country = new Country const Country country = Country.BY;
{ const Country unknown_country = Country.CK;
FlagName = "BY",
FullName = "Belarus"
};
var unknownCountry = new Country
{
FlagName = "CK",
FullName = "Cook Islands"
};
AddStep("Set country", () => countryBindable.Value = country); AddStep("Set country", () => countryBindable.Value = country);
AddStep("Set null country", () => countryBindable.Value = null); AddStep("Set default country", () => countryBindable.Value = default);
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry); AddStep("Set country with no flag", () => countryBindable.Value = unknown_country);
} }
} }
} }

View File

@ -30,21 +30,12 @@ namespace osu.Game.Tests.Visual.Online
Ruleset = { BindTarget = ruleset } Ruleset = { BindTarget = ruleset }
}); });
var country = new Country const Country country = Country.BY;
{ const Country unknown_country = Country.CK;
FlagName = "BY",
FullName = "Belarus"
};
var unknownCountry = new Country
{
FlagName = "CK",
FullName = "Cook Islands"
};
AddStep("Set country", () => countryBindable.Value = country); AddStep("Set country", () => countryBindable.Value = country);
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score); AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry); AddStep("Set country with no flag", () => countryBindable.Value = unknown_country);
} }
} }
} }

View File

@ -48,15 +48,15 @@ namespace osu.Game.Tests.Visual.Online
public void TestFlagScopeDependency() public void TestFlagScopeDependency()
{ {
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score); AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
AddAssert("Check country is Null", () => countryBindable.Value == null); AddAssert("Check country is default", () => countryBindable.Value == default);
AddStep("Set country", () => countryBindable.Value = us_country); AddStep("Set country", () => countryBindable.Value = Country.US);
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance); AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
} }
[Test] [Test]
public void TestShowCountry() public void TestShowCountry()
{ {
AddStep("Show US", () => rankingsOverlay.ShowCountry(us_country)); AddStep("Show US", () => rankingsOverlay.ShowCountry(Country.US));
} }
private void loadRankingsOverlay() private void loadRankingsOverlay()
@ -69,12 +69,6 @@ namespace osu.Game.Tests.Visual.Online
}; };
} }
private static readonly Country us_country = new Country
{
FlagName = "US",
FullName = "United States"
};
private class TestRankingsOverlay : RankingsOverlay private class TestRankingsOverlay : RankingsOverlay
{ {
public new Bindable<Country> Country => base.Country; public new Bindable<Country> Country => base.Country;

View File

@ -57,8 +57,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
new CountryStatistics new CountryStatistics
{ {
Country = new Country { FlagName = "US", FullName = "United States" }, Country = Country.US,
FlagName = "US",
ActiveUsers = 2_972_623, ActiveUsers = 2_972_623,
PlayCount = 3_086_515_743, PlayCount = 3_086_515_743,
RankedScore = 449_407_643_332_546, RankedScore = 449_407_643_332_546,
@ -66,8 +65,7 @@ namespace osu.Game.Tests.Visual.Online
}, },
new CountryStatistics new CountryStatistics
{ {
Country = new Country { FlagName = "RU", FullName = "Russian Federation" }, Country = Country.RU,
FlagName = "RU",
ActiveUsers = 1_609_989, ActiveUsers = 1_609_989,
PlayCount = 1_637_052_841, PlayCount = 1_637_052_841,
RankedScore = 221_660_827_473_004, RankedScore = 221_660_827_473_004,
@ -86,7 +84,7 @@ namespace osu.Game.Tests.Visual.Online
User = new APIUser User = new APIUser
{ {
Username = "first active user", Username = "first active user",
Country = new Country { FlagName = "JP" }, Country = Country.JP,
Active = true, Active = true,
}, },
Accuracy = 0.9972, Accuracy = 0.9972,
@ -106,7 +104,7 @@ namespace osu.Game.Tests.Visual.Online
User = new APIUser User = new APIUser
{ {
Username = "inactive user", Username = "inactive user",
Country = new Country { FlagName = "AU" }, Country = Country.AU,
Active = false, Active = false,
}, },
Accuracy = 0.9831, Accuracy = 0.9831,
@ -126,7 +124,7 @@ namespace osu.Game.Tests.Visual.Online
User = new APIUser User = new APIUser
{ {
Username = "second active user", Username = "second active user",
Country = new Country { FlagName = "PL" }, Country = Country.PL,
Active = true, Active = true,
}, },
Accuracy = 0.9584, Accuracy = 0.9584,

View File

@ -157,11 +157,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Id = 6602580, Id = 6602580,
Username = @"waaiiru", Username = @"waaiiru",
Country = new Country Country = Country.ES,
{
FullName = @"Spain",
FlagName = @"ES",
},
}, },
Mods = new[] Mods = new[]
{ {
@ -184,11 +180,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Id = 4608074, Id = 4608074,
Username = @"Skycries", Username = @"Skycries",
Country = new Country Country = Country.BR,
{
FullName = @"Brazil",
FlagName = @"BR",
},
}, },
Mods = new[] Mods = new[]
{ {
@ -210,11 +202,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Id = 1014222, Id = 1014222,
Username = @"eLy", Username = @"eLy",
Country = new Country Country = Country.JP,
{
FullName = @"Japan",
FlagName = @"JP",
},
}, },
Mods = new[] Mods = new[]
{ {
@ -235,11 +223,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Id = 1541390, Id = 1541390,
Username = @"Toukai", Username = @"Toukai",
Country = new Country Country = Country.CA,
{
FullName = @"Canada",
FlagName = @"CA",
},
}, },
Mods = new[] Mods = new[]
{ {
@ -259,11 +243,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Id = 7151382, Id = 7151382,
Username = @"Mayuri Hana", Username = @"Mayuri Hana",
Country = new Country Country = Country.TH,
{
FullName = @"Thailand",
FlagName = @"TH",
},
}, },
Rank = ScoreRank.D, Rank = ScoreRank.D,
PP = 160, PP = 160,
@ -302,11 +282,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Id = 7151382, Id = 7151382,
Username = @"Mayuri Hana", Username = @"Mayuri Hana",
Country = new Country Country = Country.TH,
{
FullName = @"Thailand",
FlagName = @"TH",
},
}, },
Rank = ScoreRank.D, Rank = ScoreRank.D,
PP = 160, PP = 160,

View File

@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Username = @"flyte", Username = @"flyte",
Id = 3103765, Id = 3103765,
Country = new Country { FlagName = @"JP" }, Country = Country.JP,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg", CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg",
Status = { Value = new UserStatusOnline() } Status = { Value = new UserStatusOnline() }
}) { Width = 300 }, }) { Width = 300 },
@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Username = @"peppy", Username = @"peppy",
Id = 2, Id = 2,
Country = new Country { FlagName = @"AU" }, Country = Country.AU,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsSupporter = true, IsSupporter = true,
SupportLevel = 3, SupportLevel = 3,
@ -77,7 +77,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Username = @"Evast", Username = @"Evast",
Id = 8195163, Id = 8195163,
Country = new Country { FlagName = @"BY" }, Country = Country.BY,
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg", CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
IsOnline = false, IsOnline = false,
LastVisit = DateTimeOffset.Now LastVisit = DateTimeOffset.Now

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Username = @"Somebody", Username = @"Somebody",
Id = 1, Id = 1,
Country = new Country { FullName = @"Alien" }, Country = Country.XX,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg", CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
JoinDate = DateTimeOffset.Now.AddDays(-1), JoinDate = DateTimeOffset.Now.AddDays(-1),
LastVisit = DateTimeOffset.Now, LastVisit = DateTimeOffset.Now,
@ -82,7 +82,7 @@ namespace osu.Game.Tests.Visual.Online
Username = @"peppy", Username = @"peppy",
Id = 2, Id = 2,
IsSupporter = true, IsSupporter = true,
Country = new Country { FullName = @"Australia", FlagName = @"AU" }, Country = Country.AU,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
})); }));
@ -90,7 +90,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
Username = @"flyte", Username = @"flyte",
Id = 3103765, Id = 3103765,
Country = new Country { FullName = @"Japan", FlagName = @"JP" }, Country = Country.JP,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
})); }));
@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual.Online
Username = @"BanchoBot", Username = @"BanchoBot",
Id = 3, Id = 3,
IsBot = true, IsBot = true,
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" }, Country = Country.SH,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
})); }));

View File

@ -140,11 +140,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 6602580, Id = 6602580,
Username = @"waaiiru", Username = @"waaiiru",
Country = new Country Country = Country.ES,
{
FullName = @"Spain",
FlagName = @"ES",
},
}, },
}); });
} }
@ -164,12 +160,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 6602580, Id = 6602580,
Username = @"waaiiru", Username = @"waaiiru",
Country = new Country Country = Country.ES,
{ }
FullName = @"Spain",
FlagName = @"ES",
},
},
}); });
} }
@ -225,11 +217,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 6602580, Id = 6602580,
Username = @"waaiiru", Username = @"waaiiru",
Country = new Country Country = Country.ES,
{
FullName = @"Spain",
FlagName = @"ES",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -246,11 +234,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 4608074, Id = 4608074,
Username = @"Skycries", Username = @"Skycries",
Country = new Country Country = Country.BR,
{
FullName = @"Brazil",
FlagName = @"BR",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -268,11 +252,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 1014222, Id = 1014222,
Username = @"eLy", Username = @"eLy",
Country = new Country Country = Country.JP,
{
FullName = @"Japan",
FlagName = @"JP",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -290,11 +270,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 1541390, Id = 1541390,
Username = @"Toukai", Username = @"Toukai",
Country = new Country Country = Country.CA,
{
FullName = @"Canada",
FlagName = @"CA",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -312,11 +288,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 2243452, Id = 2243452,
Username = @"Satoruu", Username = @"Satoruu",
Country = new Country Country = Country.VE,
{
FullName = @"Venezuela",
FlagName = @"VE",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -334,11 +306,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 2705430, Id = 2705430,
Username = @"Mooha", Username = @"Mooha",
Country = new Country Country = Country.FR,
{
FullName = @"France",
FlagName = @"FR",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -356,11 +324,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 7151382, Id = 7151382,
Username = @"Mayuri Hana", Username = @"Mayuri Hana",
Country = new Country Country = Country.TH,
{
FullName = @"Thailand",
FlagName = @"TH",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -378,11 +342,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 2051389, Id = 2051389,
Username = @"FunOrange", Username = @"FunOrange",
Country = new Country Country = Country.CA,
{
FullName = @"Canada",
FlagName = @"CA",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -400,11 +360,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 6169483, Id = 6169483,
Username = @"-Hebel-", Username = @"-Hebel-",
Country = new Country Country = Country.MX,
{
FullName = @"Mexico",
FlagName = @"MX",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -422,11 +378,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 6702666, Id = 6702666,
Username = @"prhtnsm", Username = @"prhtnsm",
Country = new Country Country = Country.DE,
{
FullName = @"Germany",
FlagName = @"DE",
},
}, },
}, },
}; };

View File

@ -69,11 +69,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 6602580, Id = 6602580,
Username = @"waaiiru", Username = @"waaiiru",
Country = new Country Country = Country.ES,
{
FullName = @"Spain",
FlagName = @"ES",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -88,11 +84,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 4608074, Id = 4608074,
Username = @"Skycries", Username = @"Skycries",
Country = new Country Country = Country.BR,
{
FullName = @"Brazil",
FlagName = @"BR",
},
}, },
}, },
new ScoreInfo new ScoreInfo
@ -107,11 +99,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
Id = 1541390, Id = 1541390,
Username = @"Toukai", Username = @"Toukai",
Country = new Country Country = Country.CA,
{
FullName = @"Canada",
FlagName = @"CA",
},
}, },
} }
}; };

View File

@ -5,6 +5,7 @@
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
@ -12,9 +13,9 @@ namespace osu.Game.Online.API.Requests
{ {
public readonly UserRankingsType Type; public readonly UserRankingsType Type;
private readonly string country; private readonly Country country;
public GetUserRankingsRequest(RulesetInfo ruleset, UserRankingsType type = UserRankingsType.Performance, int page = 1, string country = null) public GetUserRankingsRequest(RulesetInfo ruleset, UserRankingsType type = UserRankingsType.Performance, int page = 1, Country country = default)
: base(ruleset, page) : base(ruleset, page)
{ {
Type = type; Type = type;
@ -25,8 +26,8 @@ namespace osu.Game.Online.API.Requests
{ {
var req = base.CreateWebRequest(); var req = base.CreateWebRequest();
if (country != null) if (country != default)
req.AddParameter("country", country); req.AddParameter("country", country.ToString());
return req; return req;
} }

View File

@ -5,6 +5,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -174,8 +175,8 @@ namespace osu.Game.Overlays.Profile.Header
avatar.User = user; avatar.User = user;
usernameText.Text = user?.Username ?? string.Empty; usernameText.Text = user?.Username ?? string.Empty;
openUserExternally.Link = $@"{api.WebsiteRootUrl}/users/{user?.Id ?? 0}"; openUserExternally.Link = $@"{api.WebsiteRootUrl}/users/{user?.Id ?? 0}";
userFlag.Country = user?.Country; userFlag.Country = user?.Country ?? default;
userCountryText.Text = user?.Country?.FullName ?? "Alien"; userCountryText.Text = (user?.Country ?? default).GetDescription();
supporterTag.SupportLevel = user?.SupportLevel ?? 0; supporterTag.SupportLevel = user?.SupportLevel ?? 0;
titleText.Text = user?.Title ?? string.Empty; titleText.Text = user?.Title ?? string.Empty;
titleText.Colour = Color4Extensions.FromHex(user?.Colour ?? "fff"); titleText.Colour = Color4Extensions.FromHex(user?.Colour ?? "fff");

View File

@ -91,7 +91,7 @@ namespace osu.Game.Overlays.Rankings
private void onCountryChanged(ValueChangedEvent<Country> country) private void onCountryChanged(ValueChangedEvent<Country> country)
{ {
if (country.NewValue == null) if (country.NewValue == default)
{ {
countryPill.Collapse(); countryPill.Collapse();
this.ResizeHeightTo(0, duration, Easing.OutQuint); this.ResizeHeightTo(0, duration, Easing.OutQuint);

View File

@ -6,6 +6,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -93,7 +94,7 @@ namespace osu.Game.Overlays.Rankings
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Action = () => Current.Value = null Action = Current.SetDefault,
} }
} }
} }
@ -132,11 +133,11 @@ namespace osu.Game.Overlays.Rankings
private void onCountryChanged(ValueChangedEvent<Country> country) private void onCountryChanged(ValueChangedEvent<Country> country)
{ {
if (country.NewValue == null) if (country.NewValue == default)
return; return;
flag.Country = country.NewValue; flag.Country = country.NewValue;
countryName.Text = country.NewValue.FullName; countryName.Text = country.NewValue.GetDescription();
} }
private class CloseButton : OsuHoverContainer private class CloseButton : OsuHoverContainer

View File

@ -11,6 +11,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
@ -77,8 +78,8 @@ namespace osu.Game.Overlays.Rankings.Tables
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
TextAnchor = Anchor.CentreLeft; TextAnchor = Anchor.CentreLeft;
if (!string.IsNullOrEmpty(country.FullName)) if (country != default)
AddLink(country.FullName, () => rankings?.ShowCountry(country)); AddLink(country.GetDescription(), () => rankings?.ShowCountry(country));
} }
} }
} }

View File

@ -44,7 +44,7 @@ namespace osu.Game.Overlays
Country.BindValueChanged(_ => Country.BindValueChanged(_ =>
{ {
// if a country is requested, force performance scope. // if a country is requested, force performance scope.
if (Country.Value != null) if (!Country.IsDefault)
Header.Current.Value = RankingsScope.Performance; Header.Current.Value = RankingsScope.Performance;
Scheduler.AddOnce(triggerTabChanged); Scheduler.AddOnce(triggerTabChanged);
@ -76,7 +76,7 @@ namespace osu.Game.Overlays
{ {
// country filtering is only valid for performance scope. // country filtering is only valid for performance scope.
if (Header.Current.Value != RankingsScope.Performance) if (Header.Current.Value != RankingsScope.Performance)
Country.Value = null; Country.SetDefault();
Scheduler.AddOnce(triggerTabChanged); Scheduler.AddOnce(triggerTabChanged);
} }
@ -87,7 +87,7 @@ namespace osu.Game.Overlays
public void ShowCountry(Country requested) public void ShowCountry(Country requested)
{ {
if (requested == null) if (requested == default)
return; return;
Show(); Show();
@ -128,7 +128,7 @@ namespace osu.Game.Overlays
switch (Header.Current.Value) switch (Header.Current.Value)
{ {
case RankingsScope.Performance: case RankingsScope.Performance:
return new GetUserRankingsRequest(ruleset.Value, country: Country.Value?.FlagName); return new GetUserRankingsRequest(ruleset.Value, country: Country.Value);
case RankingsScope.Country: case RankingsScope.Country:
return new GetCountryRankingsRequest(ruleset.Value); return new GetCountryRankingsRequest(ruleset.Value);

View File

@ -128,7 +128,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Size = new Vector2(28, 20), Size = new Vector2(28, 20),
Country = user?.Country Country = user?.Country ?? default
}, },
new OsuSpriteText new OsuSpriteText
{ {

View File

@ -5,6 +5,7 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics.Cursor; 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;
@ -16,7 +17,7 @@ namespace osu.Game.Users.Drawables
{ {
private readonly Country country; private readonly Country country;
public LocalisableString TooltipText => country?.FullName; public LocalisableString TooltipText => country == default ? string.Empty : country.GetDescription();
public DrawableFlag(Country country) public DrawableFlag(Country country)
{ {
@ -29,7 +30,8 @@ namespace osu.Game.Users.Drawables
if (ts == null) if (ts == null)
throw new ArgumentNullException(nameof(ts)); throw new ArgumentNullException(nameof(ts));
Texture = ts.Get($@"Flags/{country?.FlagName ?? @"__"}") ?? ts.Get(@"Flags/__"); string textureName = country == default ? "__" : country.ToString();
Texture = ts.Get($@"Flags/{textureName}") ?? ts.Get(@"Flags/__");
} }
} }
} }

View File

@ -32,14 +32,14 @@ namespace osu.Game.Users.Drawables
/// </summary> /// </summary>
public Action Action; public Action Action;
public UpdateableFlag(Country country = null) public UpdateableFlag(Country country = default)
{ {
Country = country; Country = country;
} }
protected override Drawable CreateDrawable(Country country) protected override Drawable CreateDrawable(Country country)
{ {
if (country == null && !ShowPlaceholderOnNull) if (country == default && !ShowPlaceholderOnNull)
return null; return null;
return new Container return new Container