diff --git a/PKHeX.Core/Saves/Util/BoxUtil.cs b/PKHeX.Core/Saves/Util/BoxUtil.cs index 81edc1291..85ecb6dc1 100644 --- a/PKHeX.Core/Saves/Util/BoxUtil.cs +++ b/PKHeX.Core/Saves/Util/BoxUtil.cs @@ -180,7 +180,7 @@ public static IEnumerable GetPKMsFromPaths(IEnumerable files, int g foreach (var pkm in result) { - if (pkm != null) + if (pkm?.Species is > 0) yield return pkm; } } diff --git a/PKHeX.Core/Saves/Util/SaveExtensions.cs b/PKHeX.Core/Saves/Util/SaveExtensions.cs index da49de1f2..5b278cb73 100644 --- a/PKHeX.Core/Saves/Util/SaveExtensions.cs +++ b/PKHeX.Core/Saves/Util/SaveExtensions.cs @@ -178,7 +178,7 @@ public static PKM LoadTemplate(this SaveFile sav, string? templatePath = null) return LoadTemplateInternal(sav); var pk = PKMConverter.GetPKMfromBytes(File.ReadAllBytes(path), prefer: sav.Generation); - if (pk == null) + if (pk?.Species is not > 0) return LoadTemplateInternal(sav); return PKMConverter.ConvertToType(pk, sav.BlankPKM.GetType(), out _) ?? LoadTemplateInternal(sav); diff --git a/PKHeX.Core/Util/ResourceUtil.cs b/PKHeX.Core/Util/ResourceUtil.cs index 5dede1d5c..63902273a 100644 --- a/PKHeX.Core/Util/ResourceUtil.cs +++ b/PKHeX.Core/Util/ResourceUtil.cs @@ -88,6 +88,11 @@ public static partial class Util /// An array of strings whose indexes correspond to the IDs of each item. public static string[] GetItemsList(string language) => GetStringList("items", language); + /// + /// Retrieves the localization index list for all requested strings for the through Spanish. + /// + /// Base file name + /// Ignores Korean Language. public static string[][] GetLanguageStrings7(string fileName) { return new[] @@ -103,6 +108,10 @@ public static string[][] GetLanguageStrings7(string fileName) }; } + /// + /// Retrieves the localization index list for all requested strings for the through Korean. + /// + /// Base file name public static string[][] GetLanguageStrings8(string fileName) { return new[] @@ -119,6 +128,11 @@ public static string[][] GetLanguageStrings8(string fileName) }; } + /// + /// Retrieves the localization index list for all requested strings for the through Chinese. + /// + /// Base file name + /// String to use for the second Chinese localization. public static string[][] GetLanguageStrings10(string fileName, string zh2 = "zh") { return new[] @@ -181,7 +195,9 @@ public static string[] LoadStringList(string file, string? txt) return raw; } - public static string[] GetStringList(string fileName, string lang2char, string type = "text") => GetStringList($"{type}_{fileName}_{lang2char}"); + public static string[] GetStringList(string fileName, string lang2char, string type = "text") => GetStringList(GetFullResourceName(fileName, lang2char, type)); + + private static string GetFullResourceName(string fileName, string lang2char, string type) => $"{type}_{fileName}_{lang2char}"; public static byte[] GetBinaryResource(string name) { diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index 4bc4df8d9..205975392 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -224,11 +224,11 @@ private bool LoadMostRecentBackup() return false; } - private void LoadPKMFromPath(string pkmArg) + private void LoadPKMFromPath(string path) { - if (string.IsNullOrWhiteSpace(pkmArg) || !File.Exists(pkmArg)) + if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) return; - byte[] data = File.ReadAllBytes(pkmArg); + byte[] data = File.ReadAllBytes(path); var pk = PKMConverter.GetPKMfromBytes(data); if (pk != null) OpenPKM(pk);