mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-24 05:09:42 -05:00
@@ -111,8 +111,7 @@ public static bool LoadBoxes(this SaveFile SAV, string path, out string result,
|
||||
/// <returns>True if any files are imported.</returns>
|
||||
public static bool LoadBoxes(this SaveFile SAV, IEnumerable<string> filepaths, out string result, int boxStart = 0, bool boxClear = false, bool? noSetb = null)
|
||||
{
|
||||
int generation = SAV.Generation;
|
||||
var pks = GetPKMsFromPaths(filepaths, generation);
|
||||
var pks = GetPossiblePKMsFromPaths(SAV, filepaths);
|
||||
return SAV.LoadBoxes(pks, out result, boxStart, boxClear, noSetb);
|
||||
}
|
||||
|
||||
@@ -162,7 +161,7 @@ public static bool LoadBoxes(this SaveFile SAV, IEnumerable<PKM> pks, out string
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IEnumerable<PKM> GetPKMsFromPaths(IEnumerable<string> filepaths, int generation)
|
||||
public static IEnumerable<PKM> GetPKMsFromPaths(IEnumerable<string> filepaths, int generation)
|
||||
{
|
||||
return filepaths
|
||||
.Where(file => PKX.IsPKM(new FileInfo(file).Length))
|
||||
@@ -170,5 +169,25 @@ private static IEnumerable<PKM> GetPKMsFromPaths(IEnumerable<string> filepaths,
|
||||
.Select(data => PKMConverter.GetPKMfromBytes(data, prefer: generation))
|
||||
.Where(temp => temp != null);
|
||||
}
|
||||
|
||||
private static IEnumerable<PKM> GetPossiblePKMsFromPaths(SaveFile sav, IEnumerable<string> filepaths)
|
||||
{
|
||||
foreach (var f in filepaths)
|
||||
{
|
||||
var obj = FileUtil.GetSupportedFile(f, sav);
|
||||
switch (obj)
|
||||
{
|
||||
case PKM pk:
|
||||
yield return pk;
|
||||
break;
|
||||
case MysteryGift g when g.IsPokémon:
|
||||
yield return g.ConvertToPKM(sav);
|
||||
break;
|
||||
case GP1 g when g.Species != 0:
|
||||
yield return g.ConvertToPB7(sav);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user