public Vic2Country GetCountry(Eu4CountryBase eu4Country) { if (eu4Country == null) { return(null); } return(Vic2Countries.Find(c => c.Eu4Country == eu4Country)); }
public Vic2Country GetCountry(string eu4CountryTag) { var vic2Tag = V2Mapper.GetV2Country(eu4CountryTag); return(Vic2Countries.Find(c => c.CountryTag == vic2Tag)); }
private void CreateCountryFiles() { //common Console.WriteLine("Creating country files..."); var vanillaCtry = PdxSublist.ReadFile(Path.Combine(VIC2_DIR, @"common\countries.txt")); var txt = Path.Combine(OUTPUT, @"common\countries.txt"); using (var txtFile = File.CreateText(txt)) { foreach (var country in Vic2Countries) { txtFile.WriteLine($"{country.CountryTag} = \"countries/{country.CountryTag}.txt\""); } txtFile.WriteLine("# From vanilla"); foreach (var ctry in vanillaCtry.KeyValuePairs) { var genCtry = Vic2Countries.Find(c => c.CountryTag == ctry.Key); if (genCtry == null) { txtFile.WriteLine($"{ctry.Key} = \"{ctry.Value}\""); } } } var dir = Directory.CreateDirectory(Path.Combine(OUTPUT, @"common\countries")); var histDir = Directory.CreateDirectory(Path.Combine(OUTPUT, @"history\countries")); var flagDir = Directory.CreateDirectory(Path.Combine(OUTPUT, @"gfx\flags")); var eu4Flags = Eu4Save.GetFilesFor(@"gfx\flags"); var vic2Flags = Directory.GetFiles(Path.Combine(VIC2_DIR, @"gfx\flags")); var suffixes = new string[] { "", "communist", "fascist", "monarchy", "republic" }; foreach (var country in Vic2Countries) { //common\countries using (var file = File.CreateText(Path.Combine(dir.FullName, $"{country.CountryTag}.txt"))) { country.GetCommonCountryFile().WriteToFile(file); } //history\countries using (var file = File.CreateText(Path.Combine(histDir.FullName, $"{country.CountryTag}.txt"))) { country.GetHistoryCountryFile(this).WriteToFile(file); } if (country.CountryTag == "GRA") { Console.WriteLine(); } if (vic2Flags.FirstOrDefault(f => Path.GetFileName(f).StartsWith(country.CountryTag)) == null) { var eu4Flag = eu4Flags.Find(f => Path.GetFileName(f).StartsWith(country.Eu4Country?.CountryTag ?? "!")); foreach (var suff in suffixes) { var name = country.CountryTag + (suff == string.Empty ? string.Empty : $"_{suff}"); if (eu4Flag == null) { country.CreateFlag(Path.Combine(flagDir.FullName, $"{name}.tga"), suff); } else { File.Copy(eu4Flag, Path.Combine(flagDir.FullName, $"{name}.tga")); } } } } }