Replace default with CountryCode.Unknown

This commit is contained in:
Salman Ahmed 2022-07-18 08:54:35 +03:00
parent cf99849478
commit 018da74fe8
8 changed files with 12 additions and 11 deletions

View File

@ -48,7 +48,7 @@ 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 default", () => countryBindable.Value == default); AddAssert("Check country is default", () => countryBindable.IsDefault);
AddStep("Set country", () => countryBindable.Value = CountryCode.US); AddStep("Set country", () => countryBindable.Value = CountryCode.US);
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance); AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
} }

View File

@ -21,6 +21,7 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Tournament.IO; using osu.Game.Tournament.IO;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osu.Game.Users;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Tournament namespace osu.Game.Tournament
@ -187,7 +188,7 @@ namespace osu.Game.Tournament
var playersRequiringPopulation = ladder.Teams var playersRequiringPopulation = ladder.Teams
.SelectMany(t => t.Players) .SelectMany(t => t.Players)
.Where(p => string.IsNullOrEmpty(p.Username) .Where(p => string.IsNullOrEmpty(p.Username)
|| p.CountryCode == default || p.CountryCode == CountryCode.Unknown
|| p.Rank == null).ToList(); || p.Rank == null).ToList();
if (playersRequiringPopulation.Count == 0) if (playersRequiringPopulation.Count == 0)

View File

@ -15,7 +15,7 @@ namespace osu.Game.Online.API.Requests
private readonly CountryCode countryCode; private readonly CountryCode countryCode;
public GetUserRankingsRequest(RulesetInfo ruleset, UserRankingsType type = UserRankingsType.Performance, int page = 1, CountryCode countryCode = default) public GetUserRankingsRequest(RulesetInfo ruleset, UserRankingsType type = UserRankingsType.Performance, int page = 1, CountryCode countryCode = CountryCode.Unknown)
: base(ruleset, page) : base(ruleset, page)
{ {
Type = type; Type = type;
@ -26,7 +26,7 @@ namespace osu.Game.Online.API.Requests
{ {
var req = base.CreateWebRequest(); var req = base.CreateWebRequest();
if (countryCode != default) if (countryCode != CountryCode.Unknown)
req.AddParameter("country", countryCode.ToString()); req.AddParameter("country", countryCode.ToString());
return req; return req;

View File

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

View File

@ -133,7 +133,7 @@ namespace osu.Game.Overlays.Rankings
private void onCountryChanged(ValueChangedEvent<CountryCode> country) private void onCountryChanged(ValueChangedEvent<CountryCode> country)
{ {
if (country.NewValue == default) if (Current.Value == CountryCode.Unknown)
return; return;
flag.CountryCode = country.NewValue; flag.CountryCode = country.NewValue;

View File

@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Rankings.Tables
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
TextAnchor = Anchor.CentreLeft; TextAnchor = Anchor.CentreLeft;
if (countryCode != default) if (countryCode != CountryCode.Unknown)
AddLink(countryCode.GetDescription(), () => rankings?.ShowCountry(countryCode)); AddLink(countryCode.GetDescription(), () => rankings?.ShowCountry(countryCode));
} }
} }

View File

@ -17,7 +17,7 @@ namespace osu.Game.Users.Drawables
{ {
private readonly CountryCode countryCode; private readonly CountryCode countryCode;
public LocalisableString TooltipText => countryCode == default ? string.Empty : countryCode.GetDescription(); public LocalisableString TooltipText => countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription();
public DrawableFlag(CountryCode countryCode) public DrawableFlag(CountryCode countryCode)
{ {
@ -30,7 +30,7 @@ namespace osu.Game.Users.Drawables
if (ts == null) if (ts == null)
throw new ArgumentNullException(nameof(ts)); throw new ArgumentNullException(nameof(ts));
string textureName = countryCode == default ? "__" : countryCode.ToString(); string textureName = countryCode == CountryCode.Unknown ? "__" : countryCode.ToString();
Texture = ts.Get($@"Flags/{textureName}") ?? ts.Get(@"Flags/__"); 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(CountryCode countryCode = default) public UpdateableFlag(CountryCode countryCode = CountryCode.Unknown)
{ {
CountryCode = countryCode; CountryCode = countryCode;
} }
protected override Drawable CreateDrawable(CountryCode countryCode) protected override Drawable CreateDrawable(CountryCode countryCode)
{ {
if (countryCode == default && !ShowPlaceholderOnUnknown) if (countryCode == CountryCode.Unknown && !ShowPlaceholderOnUnknown)
return null; return null;
return new Container return new Container