mirror of
https://github.com/kwsch/PKHeX
synced 2024-09-22 15:21:55 +00:00
Add gen4/5 event concatenated binaries
events now show up in the event browser too pcd(4)/pgf(5) will be used for encounter matching by the legality check.
This commit is contained in:
parent
623b836cdf
commit
deac1724c7
10 changed files with 2831 additions and 2757 deletions
|
@ -143,9 +143,10 @@ namespace PKHeX.WinForms
|
|||
mnuL.Items.Insert(0, mnuLLegality);
|
||||
};
|
||||
|
||||
// Load WC6 folder to legality
|
||||
// Load Event Databases
|
||||
refreshPCDDB();
|
||||
refreshPGFDB();
|
||||
refreshWC6DB();
|
||||
// Load WC7 folder to legality
|
||||
refreshWC7DB();
|
||||
|
||||
#endregion
|
||||
|
@ -1270,6 +1271,49 @@ namespace PKHeX.WinForms
|
|||
// Indicate audibly the save is loaded
|
||||
SystemSounds.Beep.Play();
|
||||
}
|
||||
|
||||
private static void refreshPCDDB()
|
||||
{
|
||||
List<MysteryGift> db = new List<MysteryGift>();
|
||||
byte[] bin = Resources.pcd;
|
||||
for (int i = 0; i < bin.Length; i += PCD.Size)
|
||||
{
|
||||
byte[] data = new byte[PCD.Size];
|
||||
Buffer.BlockCopy(bin, i, data, 0, PCD.Size);
|
||||
db.Add(new PCD(data));
|
||||
}
|
||||
if (Directory.Exists(MGDatabasePath))
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(MGDatabasePath, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
var fi = new FileInfo(file);
|
||||
if (fi.Length == PCD.Size && fi.Extension == ".pcd")
|
||||
db.Add(new PCD(File.ReadAllBytes(file)));
|
||||
else if (fi.Length == PGT.Size && fi.Extension == ".pgt")
|
||||
db.Add(new PCD {Gift = new PGT(File.ReadAllBytes(file)), CardTitle = "MGDB PGT"});
|
||||
}
|
||||
}
|
||||
|
||||
Legal.MGDB_G4 = db.Distinct().ToArray();
|
||||
}
|
||||
private static void refreshPGFDB()
|
||||
{
|
||||
List<MysteryGift> db = new List<MysteryGift>();
|
||||
byte[] bin = Resources.pgf;
|
||||
for (int i = 0; i < bin.Length; i += PGF.Size)
|
||||
{
|
||||
byte[] data = new byte[PGF.Size];
|
||||
Buffer.BlockCopy(bin, i, data, 0, PGF.Size);
|
||||
db.Add(new PGF(data));
|
||||
}
|
||||
if (Directory.Exists(MGDatabasePath))
|
||||
db.AddRange(from file in Directory.GetFiles(MGDatabasePath, "*", SearchOption.AllDirectories)
|
||||
let fi = new FileInfo(file)
|
||||
where ".pgf" == fi.Extension && PGF.Size == fi.Length
|
||||
select new PGF(File.ReadAllBytes(file)));
|
||||
|
||||
Legal.MGDB_G5 = db.Distinct().ToArray();
|
||||
}
|
||||
private static void refreshWC6DB()
|
||||
{
|
||||
List<MysteryGift> wc6db = new List<MysteryGift>();
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace PKHeX.WinForms
|
|||
|
||||
// Load Data
|
||||
RawDB = new List<MysteryGift>();
|
||||
RawDB.AddRange(Legal.MGDB_G4);
|
||||
RawDB.AddRange(Legal.MGDB_G5);
|
||||
RawDB.AddRange(Legal.MGDB_G6);
|
||||
RawDB.AddRange(Legal.MGDB_G7);
|
||||
|
||||
|
|
|
@ -871,7 +871,7 @@ namespace PKHeX.Core
|
|||
switch (pkm.GenNumber)
|
||||
{
|
||||
case 4:
|
||||
return getMatchingPGT(pkm, MGDB_G4);
|
||||
return getMatchingPCD(pkm, MGDB_G4);
|
||||
case 5:
|
||||
return getMatchingPGF(pkm, MGDB_G5);
|
||||
case 6:
|
||||
|
@ -882,17 +882,17 @@ namespace PKHeX.Core
|
|||
return new List<MysteryGift>();
|
||||
}
|
||||
}
|
||||
private static IEnumerable<MysteryGift> getMatchingPGT(PKM pkm, IEnumerable<MysteryGift> DB)
|
||||
private static IEnumerable<MysteryGift> getMatchingPCD(PKM pkm, IEnumerable<MysteryGift> DB)
|
||||
{
|
||||
var validPGT = new List<MysteryGift>();
|
||||
var validPCD = new List<MysteryGift>();
|
||||
if (DB == null)
|
||||
return validPGT;
|
||||
return validPCD;
|
||||
|
||||
// todo
|
||||
var vs = getValidPreEvolutions(pkm).ToArray();
|
||||
foreach (PGT mg in DB.OfType<PGT>().Where(wc => vs.Any(dl => dl.Species == wc.Species)))
|
||||
foreach (PCD mg in DB.OfType<PCD>().Where(wc => vs.Any(dl => dl.Species == wc.Species)))
|
||||
{
|
||||
var wc = mg.PK;
|
||||
var wc = mg.Gift.PK;
|
||||
if (pkm.Egg_Location == 0) // Not Egg
|
||||
{
|
||||
if (wc.SID != pkm.SID) continue;
|
||||
|
@ -922,9 +922,9 @@ namespace PKHeX.Core
|
|||
// if (wc.Level > pkm.CurrentLevel) continue; // Defer to level legality
|
||||
// RIBBONS: Defer to ribbon legality
|
||||
|
||||
validPGT.Add(mg);
|
||||
validPCD.Add(mg);
|
||||
}
|
||||
return validPGT;
|
||||
return validPCD;
|
||||
}
|
||||
private static IEnumerable<MysteryGift> getMatchingPGF(PKM pkm, IEnumerable<MysteryGift> DB)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
public sealed class PGF : MysteryGift
|
||||
{
|
||||
internal const int Size = 0xCC;
|
||||
public const int Size = 0xCC;
|
||||
public override int Format => 5;
|
||||
|
||||
public PGF(byte[] data = null)
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
public sealed class PGT : MysteryGift
|
||||
{
|
||||
internal const int Size = 0x104; // 260
|
||||
public const int Size = 0x104; // 260
|
||||
public override int Format => 4;
|
||||
public override int Level
|
||||
{
|
||||
|
|
|
@ -324,9 +324,11 @@
|
|||
<None Include="Resources\byte\lvlmove_rs.pkl" />
|
||||
<None Include="Resources\byte\lvlmove_sm.pkl" />
|
||||
<None Include="Resources\byte\lvlmove_y.pkl" />
|
||||
<None Include="Resources\byte\pcd.pkl" />
|
||||
<None Include="Resources\byte\personal_rb" />
|
||||
<None Include="Resources\byte\personal_sm" />
|
||||
<None Include="Resources\byte\personal_y" />
|
||||
<None Include="Resources\byte\pgf.pkl" />
|
||||
<None Include="Resources\byte\tutors_g3.pkl" />
|
||||
<None Include="Resources\byte\tutors_g4.pkl" />
|
||||
<None Include="Resources\byte\wc7.pkl" />
|
||||
|
|
5510
PKHeX/Properties/Resources.Designer.cs
generated
5510
PKHeX/Properties/Resources.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -7555,4 +7555,10 @@
|
|||
<data name="encunters_hb_ss" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\byte\encunters_hb_ss.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="pcd" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\byte\pcd.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="pgf" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\byte\pgf.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
BIN
PKHeX/Resources/byte/pcd.pkl
Normal file
BIN
PKHeX/Resources/byte/pcd.pkl
Normal file
Binary file not shown.
BIN
PKHeX/Resources/byte/pgf.pkl
Normal file
BIN
PKHeX/Resources/byte/pgf.pkl
Normal file
Binary file not shown.
Loading…
Reference in a new issue