mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 20:26:55 -05:00
Minor tweaks
Discard empty pkm files (species 0) when loading boxes or templates Add more xmldoc Simplify some method parameter names for readability
This commit is contained in:
@@ -180,7 +180,7 @@ public static IEnumerable<PKM> GetPKMsFromPaths(IEnumerable<string> files, int g
|
||||
|
||||
foreach (var pkm in result)
|
||||
{
|
||||
if (pkm != null)
|
||||
if (pkm?.Species is > 0)
|
||||
yield return pkm;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -88,6 +88,11 @@ public static partial class Util
|
||||
/// <returns>An array of strings whose indexes correspond to the IDs of each item.</returns>
|
||||
public static string[] GetItemsList(string language) => GetStringList("items", language);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the localization index list for all requested strings for the <see cref="fileName"/> through Spanish.
|
||||
/// </summary>
|
||||
/// <param name="fileName">Base file name</param>
|
||||
/// <remarks>Ignores Korean Language.</remarks>
|
||||
public static string[][] GetLanguageStrings7(string fileName)
|
||||
{
|
||||
return new[]
|
||||
@@ -103,6 +108,10 @@ public static string[][] GetLanguageStrings7(string fileName)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the localization index list for all requested strings for the <see cref="fileName"/> through Korean.
|
||||
/// </summary>
|
||||
/// <param name="fileName">Base file name</param>
|
||||
public static string[][] GetLanguageStrings8(string fileName)
|
||||
{
|
||||
return new[]
|
||||
@@ -119,6 +128,11 @@ public static string[][] GetLanguageStrings8(string fileName)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the localization index list for all requested strings for the <see cref="fileName"/> through Chinese.
|
||||
/// </summary>
|
||||
/// <param name="fileName">Base file name</param>
|
||||
/// <param name="zh2">String to use for the second Chinese localization.</param>
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user