Replace countries.json with country enum and acronym extension

This commit is contained in:
Salman Ahmed
2022-07-16 05:16:59 +03:00
parent 08f1280aa8
commit 7c6f4b798b
3 changed files with 782 additions and 1258 deletions

View File

@ -3,13 +3,13 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -45,11 +45,17 @@ namespace osu.Game.Tournament.Screens.Editors
private void addAllCountries()
{
List<TournamentTeam> countries;
var countries = new List<TournamentTeam>();
using (Stream stream = game.Resources.GetStream("Resources/countries.json"))
using (var sr = new StreamReader(stream))
countries = JsonConvert.DeserializeObject<List<TournamentTeam>>(sr.ReadToEnd());
foreach (var country in Enum.GetValues(typeof(Country)).Cast<Country>().Skip(1))
{
countries.Add(new TournamentTeam
{
FlagName = { Value = country.ToString() },
FullName = { Value = country.GetDescription() },
Acronym = { Value = country.GetAcronym() },
});
}
Debug.Assert(countries != null);