Merge pull request #2 from kwsch/master

Up to date
This commit is contained in:
ajtudela 2016-08-20 11:20:35 +02:00 committed by GitHub
commit 2728715855
13 changed files with 216 additions and 144 deletions

View file

@ -594,9 +594,9 @@ namespace PKHeX
if (!pk6.WasEvent && !(pk6.WasLink && (EncounterMatch as EncounterLink)?.OT == false) && (pk6.HT_Name.Length == 0 || pk6.Geo1_Country == 0)) // Is not Traded if (!pk6.WasEvent && !(pk6.WasLink && (EncounterMatch as EncounterLink)?.OT == false) && (pk6.HT_Name.Length == 0 || pk6.Geo1_Country == 0)) // Is not Traded
{ {
if (pk6.HT_Name.Length != 0) if (pk6.HT_Name.Length != 0)
return new LegalityCheck(Severity.Invalid, "GeoLocation -- HT Name present but has no previous Country."); return new LegalityCheck(Severity.Invalid, "GeoLocation Memory -- HT Name present but has no previous Country.");
if (pk6.Geo1_Country != 0) if (pk6.Geo1_Country != 0)
return new LegalityCheck(Severity.Invalid, "GeoLocation -- Previous country of residence but no Handling Trainer."); return new LegalityCheck(Severity.Invalid, "GeoLocation Memory -- Previous country of residence but no Handling Trainer.");
if (pk6.HT_Memory != 0) if (pk6.HT_Memory != 0)
return new LegalityCheck(Severity.Invalid, "Memory -- Handling Trainer memory present but no Handling Trainer."); return new LegalityCheck(Severity.Invalid, "Memory -- Handling Trainer memory present but no Handling Trainer.");
if (pk6.CurrentHandler != 0) // Badly edited; PKHeX doesn't trip this. if (pk6.CurrentHandler != 0) // Badly edited; PKHeX doesn't trip this.

View file

@ -341,14 +341,10 @@
this.B_VerifyCHK = new System.Windows.Forms.Button(); this.B_VerifyCHK = new System.Windows.Forms.Button();
this.GB_SAVtools = new System.Windows.Forms.GroupBox(); this.GB_SAVtools = new System.Windows.Forms.GroupBox();
this.FLP_SAVtools = new System.Windows.Forms.FlowLayoutPanel(); this.FLP_SAVtools = new System.Windows.Forms.FlowLayoutPanel();
this.B_OpenPokepuffs = new System.Windows.Forms.Button();
this.B_OpenItemPouch = new System.Windows.Forms.Button();
this.B_OpenTrainerInfo = new System.Windows.Forms.Button(); this.B_OpenTrainerInfo = new System.Windows.Forms.Button();
this.B_OUTPasserby = new System.Windows.Forms.Button(); this.B_OpenItemPouch = new System.Windows.Forms.Button();
this.B_OpenBoxLayout = new System.Windows.Forms.Button(); this.B_OpenBoxLayout = new System.Windows.Forms.Button();
this.B_OpenWondercards = new System.Windows.Forms.Button(); this.B_OpenWondercards = new System.Windows.Forms.Button();
this.B_OpenSuperTraining = new System.Windows.Forms.Button();
this.B_OpenHallofFame = new System.Windows.Forms.Button();
this.B_OpenOPowers = new System.Windows.Forms.Button(); this.B_OpenOPowers = new System.Windows.Forms.Button();
this.B_OpenEventFlags = new System.Windows.Forms.Button(); this.B_OpenEventFlags = new System.Windows.Forms.Button();
this.B_OpenPokedex = new System.Windows.Forms.Button(); this.B_OpenPokedex = new System.Windows.Forms.Button();
@ -356,6 +352,10 @@
this.B_OpenSecretBase = new System.Windows.Forms.Button(); this.B_OpenSecretBase = new System.Windows.Forms.Button();
this.B_Pokeblocks = new System.Windows.Forms.Button(); this.B_Pokeblocks = new System.Windows.Forms.Button();
this.B_LinkInfo = new System.Windows.Forms.Button(); this.B_LinkInfo = new System.Windows.Forms.Button();
this.B_OpenPokepuffs = new System.Windows.Forms.Button();
this.B_OpenSuperTraining = new System.Windows.Forms.Button();
this.B_OpenHallofFame = new System.Windows.Forms.Button();
this.B_OUTPasserby = new System.Windows.Forms.Button();
this.B_CGearSkin = new System.Windows.Forms.Button(); this.B_CGearSkin = new System.Windows.Forms.Button();
this.dragout = new System.Windows.Forms.PictureBox(); this.dragout = new System.Windows.Forms.PictureBox();
this.mnuL = new System.Windows.Forms.ContextMenuStrip(this.components); this.mnuL = new System.Windows.Forms.ContextMenuStrip(this.components);
@ -4363,36 +4363,36 @@
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.FLP_SAVtools.AutoScroll = true; this.FLP_SAVtools.AutoScroll = true;
this.FLP_SAVtools.Controls.Add(this.B_OpenPokepuffs);
this.FLP_SAVtools.Controls.Add(this.B_OpenItemPouch);
this.FLP_SAVtools.Controls.Add(this.B_OpenTrainerInfo); this.FLP_SAVtools.Controls.Add(this.B_OpenTrainerInfo);
this.FLP_SAVtools.Controls.Add(this.B_OUTPasserby); this.FLP_SAVtools.Controls.Add(this.B_OpenItemPouch);
this.FLP_SAVtools.Controls.Add(this.B_OpenBoxLayout); this.FLP_SAVtools.Controls.Add(this.B_OpenBoxLayout);
this.FLP_SAVtools.Controls.Add(this.B_OpenWondercards); this.FLP_SAVtools.Controls.Add(this.B_OpenWondercards);
this.FLP_SAVtools.Controls.Add(this.B_OpenSuperTraining);
this.FLP_SAVtools.Controls.Add(this.B_OpenHallofFame);
this.FLP_SAVtools.Controls.Add(this.B_OpenOPowers); this.FLP_SAVtools.Controls.Add(this.B_OpenOPowers);
this.FLP_SAVtools.Controls.Add(this.B_OpenEventFlags); this.FLP_SAVtools.Controls.Add(this.B_OpenEventFlags);
this.FLP_SAVtools.Controls.Add(this.B_OpenPokedex); this.FLP_SAVtools.Controls.Add(this.B_OpenPokedex);
this.FLP_SAVtools.Controls.Add(this.B_OpenBerryField);
this.FLP_SAVtools.Controls.Add(this.B_OpenSecretBase);
this.FLP_SAVtools.Controls.Add(this.B_Pokeblocks);
this.FLP_SAVtools.Controls.Add(this.B_LinkInfo); this.FLP_SAVtools.Controls.Add(this.B_LinkInfo);
this.FLP_SAVtools.Controls.Add(this.B_OpenBerryField);
this.FLP_SAVtools.Controls.Add(this.B_Pokeblocks);
this.FLP_SAVtools.Controls.Add(this.B_OpenSecretBase);
this.FLP_SAVtools.Controls.Add(this.B_OpenPokepuffs);
this.FLP_SAVtools.Controls.Add(this.B_OpenSuperTraining);
this.FLP_SAVtools.Controls.Add(this.B_OpenHallofFame);
this.FLP_SAVtools.Controls.Add(this.B_OUTPasserby);
this.FLP_SAVtools.Controls.Add(this.B_CGearSkin); this.FLP_SAVtools.Controls.Add(this.B_CGearSkin);
this.FLP_SAVtools.Location = new System.Drawing.Point(6, 10); this.FLP_SAVtools.Location = new System.Drawing.Point(6, 10);
this.FLP_SAVtools.Name = "FLP_SAVtools"; this.FLP_SAVtools.Name = "FLP_SAVtools";
this.FLP_SAVtools.Size = new System.Drawing.Size(297, 87); this.FLP_SAVtools.Size = new System.Drawing.Size(297, 87);
this.FLP_SAVtools.TabIndex = 101; this.FLP_SAVtools.TabIndex = 101;
// //
// B_OpenPokepuffs // B_OpenTrainerInfo
// //
this.B_OpenPokepuffs.Location = new System.Drawing.Point(3, 3); this.B_OpenTrainerInfo.Location = new System.Drawing.Point(3, 3);
this.B_OpenPokepuffs.Name = "B_OpenPokepuffs"; this.B_OpenTrainerInfo.Name = "B_OpenTrainerInfo";
this.B_OpenPokepuffs.Size = new System.Drawing.Size(87, 23); this.B_OpenTrainerInfo.Size = new System.Drawing.Size(87, 23);
this.B_OpenPokepuffs.TabIndex = 1; this.B_OpenTrainerInfo.TabIndex = 3;
this.B_OpenPokepuffs.Text = "Poké Puffs"; this.B_OpenTrainerInfo.Text = "Trainer Info";
this.B_OpenPokepuffs.UseVisualStyleBackColor = true; this.B_OpenTrainerInfo.UseVisualStyleBackColor = true;
this.B_OpenPokepuffs.Click += new System.EventHandler(this.B_OpenPokepuffs_Click); this.B_OpenTrainerInfo.Click += new System.EventHandler(this.B_OpenTrainerInfo_Click);
// //
// B_OpenItemPouch // B_OpenItemPouch
// //
@ -4404,29 +4404,9 @@
this.B_OpenItemPouch.UseVisualStyleBackColor = true; this.B_OpenItemPouch.UseVisualStyleBackColor = true;
this.B_OpenItemPouch.Click += new System.EventHandler(this.B_OpenItemPouch_Click); this.B_OpenItemPouch.Click += new System.EventHandler(this.B_OpenItemPouch_Click);
// //
// B_OpenTrainerInfo
//
this.B_OpenTrainerInfo.Location = new System.Drawing.Point(189, 3);
this.B_OpenTrainerInfo.Name = "B_OpenTrainerInfo";
this.B_OpenTrainerInfo.Size = new System.Drawing.Size(87, 23);
this.B_OpenTrainerInfo.TabIndex = 3;
this.B_OpenTrainerInfo.Text = "Trainer Info";
this.B_OpenTrainerInfo.UseVisualStyleBackColor = true;
this.B_OpenTrainerInfo.Click += new System.EventHandler(this.B_OpenTrainerInfo_Click);
//
// B_OUTPasserby
//
this.B_OUTPasserby.Location = new System.Drawing.Point(3, 32);
this.B_OUTPasserby.Name = "B_OUTPasserby";
this.B_OUTPasserby.Size = new System.Drawing.Size(87, 23);
this.B_OUTPasserby.TabIndex = 4;
this.B_OUTPasserby.Text = "Passerby";
this.B_OUTPasserby.UseVisualStyleBackColor = true;
this.B_OUTPasserby.Click += new System.EventHandler(this.B_OUTPasserby_Click);
//
// B_OpenBoxLayout // B_OpenBoxLayout
// //
this.B_OpenBoxLayout.Location = new System.Drawing.Point(96, 32); this.B_OpenBoxLayout.Location = new System.Drawing.Point(189, 3);
this.B_OpenBoxLayout.Name = "B_OpenBoxLayout"; this.B_OpenBoxLayout.Name = "B_OpenBoxLayout";
this.B_OpenBoxLayout.Size = new System.Drawing.Size(87, 23); this.B_OpenBoxLayout.Size = new System.Drawing.Size(87, 23);
this.B_OpenBoxLayout.TabIndex = 5; this.B_OpenBoxLayout.TabIndex = 5;
@ -4436,7 +4416,7 @@
// //
// B_OpenWondercards // B_OpenWondercards
// //
this.B_OpenWondercards.Location = new System.Drawing.Point(189, 32); this.B_OpenWondercards.Location = new System.Drawing.Point(3, 32);
this.B_OpenWondercards.Name = "B_OpenWondercards"; this.B_OpenWondercards.Name = "B_OpenWondercards";
this.B_OpenWondercards.Size = new System.Drawing.Size(87, 23); this.B_OpenWondercards.Size = new System.Drawing.Size(87, 23);
this.B_OpenWondercards.TabIndex = 6; this.B_OpenWondercards.TabIndex = 6;
@ -4444,30 +4424,9 @@
this.B_OpenWondercards.UseVisualStyleBackColor = true; this.B_OpenWondercards.UseVisualStyleBackColor = true;
this.B_OpenWondercards.Click += new System.EventHandler(this.B_OpenWondercards_Click); this.B_OpenWondercards.Click += new System.EventHandler(this.B_OpenWondercards_Click);
// //
// B_OpenSuperTraining
//
this.B_OpenSuperTraining.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.B_OpenSuperTraining.Location = new System.Drawing.Point(3, 61);
this.B_OpenSuperTraining.Name = "B_OpenSuperTraining";
this.B_OpenSuperTraining.Size = new System.Drawing.Size(87, 23);
this.B_OpenSuperTraining.TabIndex = 7;
this.B_OpenSuperTraining.Text = "Super Train";
this.B_OpenSuperTraining.UseVisualStyleBackColor = true;
this.B_OpenSuperTraining.Click += new System.EventHandler(this.B_OpenSuperTraining_Click);
//
// B_OpenHallofFame
//
this.B_OpenHallofFame.Location = new System.Drawing.Point(96, 61);
this.B_OpenHallofFame.Name = "B_OpenHallofFame";
this.B_OpenHallofFame.Size = new System.Drawing.Size(87, 23);
this.B_OpenHallofFame.TabIndex = 8;
this.B_OpenHallofFame.Text = "Hall of Fame";
this.B_OpenHallofFame.UseVisualStyleBackColor = true;
this.B_OpenHallofFame.Click += new System.EventHandler(this.B_OUTHallofFame_Click);
//
// B_OpenOPowers // B_OpenOPowers
// //
this.B_OpenOPowers.Location = new System.Drawing.Point(189, 61); this.B_OpenOPowers.Location = new System.Drawing.Point(96, 32);
this.B_OpenOPowers.Name = "B_OpenOPowers"; this.B_OpenOPowers.Name = "B_OpenOPowers";
this.B_OpenOPowers.Size = new System.Drawing.Size(87, 23); this.B_OpenOPowers.Size = new System.Drawing.Size(87, 23);
this.B_OpenOPowers.TabIndex = 9; this.B_OpenOPowers.TabIndex = 9;
@ -4477,7 +4436,7 @@
// //
// B_OpenEventFlags // B_OpenEventFlags
// //
this.B_OpenEventFlags.Location = new System.Drawing.Point(3, 90); this.B_OpenEventFlags.Location = new System.Drawing.Point(189, 32);
this.B_OpenEventFlags.Name = "B_OpenEventFlags"; this.B_OpenEventFlags.Name = "B_OpenEventFlags";
this.B_OpenEventFlags.Size = new System.Drawing.Size(87, 23); this.B_OpenEventFlags.Size = new System.Drawing.Size(87, 23);
this.B_OpenEventFlags.TabIndex = 10; this.B_OpenEventFlags.TabIndex = 10;
@ -4487,7 +4446,7 @@
// //
// B_OpenPokedex // B_OpenPokedex
// //
this.B_OpenPokedex.Location = new System.Drawing.Point(96, 90); this.B_OpenPokedex.Location = new System.Drawing.Point(3, 61);
this.B_OpenPokedex.Name = "B_OpenPokedex"; this.B_OpenPokedex.Name = "B_OpenPokedex";
this.B_OpenPokedex.Size = new System.Drawing.Size(87, 23); this.B_OpenPokedex.Size = new System.Drawing.Size(87, 23);
this.B_OpenPokedex.TabIndex = 11; this.B_OpenPokedex.TabIndex = 11;
@ -4497,7 +4456,7 @@
// //
// B_OpenBerryField // B_OpenBerryField
// //
this.B_OpenBerryField.Location = new System.Drawing.Point(189, 90); this.B_OpenBerryField.Location = new System.Drawing.Point(189, 61);
this.B_OpenBerryField.Name = "B_OpenBerryField"; this.B_OpenBerryField.Name = "B_OpenBerryField";
this.B_OpenBerryField.Size = new System.Drawing.Size(87, 23); this.B_OpenBerryField.Size = new System.Drawing.Size(87, 23);
this.B_OpenBerryField.TabIndex = 12; this.B_OpenBerryField.TabIndex = 12;
@ -4507,7 +4466,7 @@
// //
// B_OpenSecretBase // B_OpenSecretBase
// //
this.B_OpenSecretBase.Location = new System.Drawing.Point(3, 119); this.B_OpenSecretBase.Location = new System.Drawing.Point(96, 90);
this.B_OpenSecretBase.Name = "B_OpenSecretBase"; this.B_OpenSecretBase.Name = "B_OpenSecretBase";
this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23); this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23);
this.B_OpenSecretBase.TabIndex = 21; this.B_OpenSecretBase.TabIndex = 21;
@ -4518,7 +4477,7 @@
// //
// B_Pokeblocks // B_Pokeblocks
// //
this.B_Pokeblocks.Location = new System.Drawing.Point(96, 119); this.B_Pokeblocks.Location = new System.Drawing.Point(3, 90);
this.B_Pokeblocks.Name = "B_Pokeblocks"; this.B_Pokeblocks.Name = "B_Pokeblocks";
this.B_Pokeblocks.Size = new System.Drawing.Size(87, 23); this.B_Pokeblocks.Size = new System.Drawing.Size(87, 23);
this.B_Pokeblocks.TabIndex = 22; this.B_Pokeblocks.TabIndex = 22;
@ -4529,7 +4488,7 @@
// //
// B_LinkInfo // B_LinkInfo
// //
this.B_LinkInfo.Location = new System.Drawing.Point(189, 119); this.B_LinkInfo.Location = new System.Drawing.Point(96, 61);
this.B_LinkInfo.Name = "B_LinkInfo"; this.B_LinkInfo.Name = "B_LinkInfo";
this.B_LinkInfo.Size = new System.Drawing.Size(87, 23); this.B_LinkInfo.Size = new System.Drawing.Size(87, 23);
this.B_LinkInfo.TabIndex = 23; this.B_LinkInfo.TabIndex = 23;
@ -4537,6 +4496,47 @@
this.B_LinkInfo.UseVisualStyleBackColor = true; this.B_LinkInfo.UseVisualStyleBackColor = true;
this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click); this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click);
// //
// B_OpenPokepuffs
//
this.B_OpenPokepuffs.Location = new System.Drawing.Point(189, 90);
this.B_OpenPokepuffs.Name = "B_OpenPokepuffs";
this.B_OpenPokepuffs.Size = new System.Drawing.Size(87, 23);
this.B_OpenPokepuffs.TabIndex = 1;
this.B_OpenPokepuffs.Text = "Poké Puffs";
this.B_OpenPokepuffs.UseVisualStyleBackColor = true;
this.B_OpenPokepuffs.Click += new System.EventHandler(this.B_OpenPokepuffs_Click);
//
// B_OpenSuperTraining
//
this.B_OpenSuperTraining.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.B_OpenSuperTraining.Location = new System.Drawing.Point(3, 119);
this.B_OpenSuperTraining.Name = "B_OpenSuperTraining";
this.B_OpenSuperTraining.Size = new System.Drawing.Size(87, 23);
this.B_OpenSuperTraining.TabIndex = 7;
this.B_OpenSuperTraining.Text = "Super Train";
this.B_OpenSuperTraining.UseVisualStyleBackColor = true;
this.B_OpenSuperTraining.Click += new System.EventHandler(this.B_OpenSuperTraining_Click);
//
// B_OpenHallofFame
//
this.B_OpenHallofFame.Location = new System.Drawing.Point(96, 119);
this.B_OpenHallofFame.Name = "B_OpenHallofFame";
this.B_OpenHallofFame.Size = new System.Drawing.Size(87, 23);
this.B_OpenHallofFame.TabIndex = 8;
this.B_OpenHallofFame.Text = "Hall of Fame";
this.B_OpenHallofFame.UseVisualStyleBackColor = true;
this.B_OpenHallofFame.Click += new System.EventHandler(this.B_OUTHallofFame_Click);
//
// B_OUTPasserby
//
this.B_OUTPasserby.Location = new System.Drawing.Point(189, 119);
this.B_OUTPasserby.Name = "B_OUTPasserby";
this.B_OUTPasserby.Size = new System.Drawing.Size(87, 23);
this.B_OUTPasserby.TabIndex = 4;
this.B_OUTPasserby.Text = "Passerby";
this.B_OUTPasserby.UseVisualStyleBackColor = true;
this.B_OUTPasserby.Click += new System.EventHandler(this.B_OUTPasserby_Click);
//
// B_CGearSkin // B_CGearSkin
// //
this.B_CGearSkin.Location = new System.Drawing.Point(3, 148); this.B_CGearSkin.Location = new System.Drawing.Point(3, 148);

View file

@ -787,7 +787,7 @@ namespace PKHeX
PAN_Box.Visible = CB_BoxSelect.Visible = B_BoxLeft.Visible = B_BoxRight.Visible = SAV.HasBox; PAN_Box.Visible = CB_BoxSelect.Visible = B_BoxLeft.Visible = B_BoxRight.Visible = SAV.HasBox;
Menu_LoadBoxes.Enabled = Menu_DumpBoxes.Enabled = Menu_Report.Enabled = Menu_Modify.Enabled = B_SaveBoxBin.Enabled = SAV.HasBox; Menu_LoadBoxes.Enabled = Menu_DumpBoxes.Enabled = Menu_Report.Enabled = Menu_Modify.Enabled = B_SaveBoxBin.Enabled = SAV.HasBox;
if (GB_SAVtools.Visible) if (path != null) // Actual save file
{ {
PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = SAV.HasBattleBox; PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = SAV.HasBattleBox;
GB_Daycare.Visible = SAV.HasDaycare; GB_Daycare.Visible = SAV.HasDaycare;
@ -802,7 +802,7 @@ namespace PKHeX
B_OpenHallofFame.Visible = SAV.HasHoF; B_OpenHallofFame.Visible = SAV.HasHoF;
B_OpenOPowers.Visible = SAV.HasOPower; B_OpenOPowers.Visible = SAV.HasOPower;
B_OpenPokedex.Visible = SAV.HasPokeDex; B_OpenPokedex.Visible = SAV.HasPokeDex;
B_OpenBerryField.Visible = SAV.HasBerryField; B_OpenBerryField.Visible = SAV.HasBerryField && SAV.XY;
B_Pokeblocks.Visible = SAV.HasPokeBlock; B_Pokeblocks.Visible = SAV.HasPokeBlock;
B_JPEG.Visible = SAV.HasJPEG; B_JPEG.Visible = SAV.HasJPEG;
B_OpenEventFlags.Visible = SAV.HasEvents; B_OpenEventFlags.Visible = SAV.HasEvents;
@ -821,7 +821,6 @@ namespace PKHeX
PB_Legal.Visible = PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible = SAV.Generation >= 6; PB_Legal.Visible = PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible = SAV.Generation >= 6;
PB_MarkPentagon.Visible = SAV.Generation == 6; PB_MarkPentagon.Visible = SAV.Generation == 6;
PB_Legal.Visible = PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible = SAV.Generation == 6;
TB_GameSync.Visible = TB_Secure1.Visible = TB_Secure2.Visible = L_GameSync.Visible = L_Secure1.Visible = L_Secure2.Visible = SAV.Exportable && SAV.Generation == 6; TB_GameSync.Visible = TB_Secure1.Visible = TB_Secure2.Visible = L_GameSync.Visible = L_Secure1.Visible = L_Secure2.Visible = SAV.Exportable && SAV.Generation == 6;
CB_Form.Visible = Label_Form.Visible = CHK_AsEgg.Visible = GB_EggConditions.Visible = CB_Form.Visible = Label_Form.Visible = CHK_AsEgg.Visible = GB_EggConditions.Visible =
@ -876,7 +875,6 @@ namespace PKHeX
// Common HaX Interface // Common HaX Interface
CHK_HackedStats.Enabled = CHK_HackedStats.Visible = MT_Level.Enabled = MT_Level.Visible = MT_Form.Enabled = MT_Form.Visible = HaX; CHK_HackedStats.Enabled = CHK_HackedStats.Visible = MT_Level.Enabled = MT_Level.Visible = MT_Form.Enabled = MT_Form.Visible = HaX;
PB_Legal.Visible = PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible &= !HaX;
TB_Level.Visible = !HaX; TB_Level.Visible = !HaX;
// Load Extra Byte List // Load Extra Byte List
@ -2272,13 +2270,13 @@ namespace PKHeX
return; return;
Legality = la ?? new LegalityAnalysis((PK6) pkm); Legality = la ?? new LegalityAnalysis((PK6) pkm);
PB_Legal.Image = Legality.Valid ? Properties.Resources.valid : Properties.Resources.warn; PB_Legal.Image = Legality.Valid ? Properties.Resources.valid : Properties.Resources.warn;
PB_Legal.Visible = pkm.Gen6 /*&& pkm is PK6*/; PB_Legal.Visible = pkm.Gen6 /*&& pkm is PK6*/ && !HaX;
// Refresh Move Legality // Refresh Move Legality
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
movePB[i].Visible = !Legality.vMoves[i].Valid; movePB[i].Visible = !Legality.vMoves[i].Valid && !HaX;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
relearnPB[i].Visible = !Legality.vRelearn[i].Valid; relearnPB[i].Visible = !Legality.vRelearn[i].Valid && !HaX;
} }
private void updateStats() private void updateStats()
{ {

View file

@ -1261,16 +1261,10 @@
<metadata name="FLP_SAVtools.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="FLP_SAVtools.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_OpenPokepuffs.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OpenItemPouch.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OpenTrainerInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenTrainerInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_OUTPasserby.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenItemPouch.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_OpenBoxLayout.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenBoxLayout.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@ -1279,12 +1273,6 @@
<metadata name="B_OpenWondercards.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenWondercards.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_OpenSuperTraining.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OpenHallofFame.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OpenOPowers.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenOPowers.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
@ -1294,16 +1282,28 @@
<metadata name="B_OpenPokedex.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenPokedex.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_OpenBerryField.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_LinkInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_OpenSecretBase.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenBerryField.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_Pokeblocks.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_Pokeblocks.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_LinkInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_OpenSecretBase.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OpenPokepuffs.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OpenSuperTraining.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OpenHallofFame.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_OUTPasserby.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="B_CGearSkin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="B_CGearSkin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View file

@ -160,8 +160,6 @@ namespace PKHeX
pk5.SID = Util.ToInt32(TB_SID.Text); pk5.SID = Util.ToInt32(TB_SID.Text);
pk5.EXP = Util.ToUInt32(TB_EXP.Text); pk5.EXP = Util.ToUInt32(TB_EXP.Text);
pk5.PID = Util.getHEXval(TB_PID.Text); pk5.PID = Util.getHEXval(TB_PID.Text);
pk5.Ability = (byte)Util.getIndex(DEV_Ability);
pk5.Ability = (byte)Array.IndexOf(abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk5.Nature = (byte)Util.getIndex(CB_Nature); pk5.Nature = (byte)Util.getIndex(CB_Nature);
pk5.FatefulEncounter = CHK_Fateful.Checked; pk5.FatefulEncounter = CHK_Fateful.Checked;
@ -250,6 +248,11 @@ namespace PKHeX
pk5.Ability = (byte)Util.getIndex(DEV_Ability); pk5.Ability = (byte)Util.getIndex(DEV_Ability);
pk5.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); pk5.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
} }
else
{
pk5.Ability = (byte)Array.IndexOf(abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
}
// Fix Moves if a slot is empty // Fix Moves if a slot is empty
pk5.FixMoves(); pk5.FixMoves();

View file

@ -45,6 +45,13 @@ namespace PKHeX
public virtual byte[] Data { get; set; } public virtual byte[] Data { get; set; }
public abstract PKM convertToPKM(SaveFile SAV); public abstract PKM convertToPKM(SaveFile SAV);
public MysteryGift Clone()
{
byte[] data = (byte[])Data.Clone();
return getMysteryGift(data);
}
public string Type => GetType().Name;
// Properties // Properties
public abstract bool GiftUsed { get; set; } public abstract bool GiftUsed { get; set; }
public abstract string CardTitle { get; set; } public abstract string CardTitle { get; set; }
@ -57,6 +64,6 @@ namespace PKHeX
public virtual int Quantity { get { return 1; } set { } } public virtual int Quantity { get { return 1; } set { } }
public bool Empty => Data.SequenceEqual(new byte[Data.Length]); public bool Empty => Data.SequenceEqual(new byte[Data.Length]);
public string getCardHeader() => (CardID > 0 ? $"Card #: {CardID.ToString("0000")}" : "N/A") + $" - {CardTitle.Trim()}" + Environment.NewLine; public string getCardHeader() => (CardID > 0 ? $"Card #: {CardID.ToString("0000")}" : "N/A") + $" - {CardTitle.Replace('\u3000',' ').Trim()}" + Environment.NewLine;
} }
} }

View file

@ -269,7 +269,7 @@ namespace PKHeX
else if (PtHGSS) else if (PtHGSS)
{ {
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x44); BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x44);
BitConverter.GetBytes(0xBBA).CopyTo(Data, 0x7E); // Faraway Place (for DP display) BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x7E); // Faraway Place (for DP display)
} }
else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010)) else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010))
{ {
@ -303,7 +303,7 @@ namespace PKHeX
else if (PtHGSS) else if (PtHGSS)
{ {
BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x46); BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x46);
BitConverter.GetBytes(0xBBA).CopyTo(Data, 0x80); // Faraway Place (for DP display) BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x80); // Faraway Place (for DP display)
} }
else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010)) else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010))
{ {

View file

@ -158,8 +158,8 @@ namespace PKHeX
public override int Gender { get { return (Data[0x40] >> 1) & 0x3; } set { Data[0x40] = (byte)(Data[0x40] & ~0x06 | (value << 1)); } } public override int Gender { get { return (Data[0x40] >> 1) & 0x3; } set { Data[0x40] = (byte)(Data[0x40] & ~0x06 | (value << 1)); } }
public override int AltForm { get { return Data[0x40] >> 3; } set { Data[0x40] = (byte)(Data[0x40] & 0x07 | (value << 3)); } } public override int AltForm { get { return Data[0x40] >> 3; } set { Data[0x40] = (byte)(Data[0x40] & 0x07 | (value << 3)); } }
public override int Nature { get { return Data[0x41]; } set { Data[0x41] = (byte)value; } } public override int Nature { get { return Data[0x41]; } set { Data[0x41] = (byte)value; } }
public bool HiddenAbility { get { return (Data[0x41] & 1) == 1; } set { Data[0x41] = (byte)(Data[0x41] & ~0x01 | (value ? 1 : 0)); } } public bool HiddenAbility { get { return (Data[0x42] & 1) == 1; } set { Data[0x42] = (byte)(Data[0x42] & ~0x01 | (value ? 1 : 0)); } }
public bool NPokémon { get { return (Data[0x41] & 2) == 2; } set { Data[0x41] = (byte)(Data[0x41] & ~0x02 | (value ? 2 : 0)); } } public bool NPokémon { get { return (Data[0x42] & 2) == 2; } set { Data[0x42] = (byte)(Data[0x42] & ~0x02 | (value ? 2 : 0)); } }
// 0x43-0x47 Unused // 0x43-0x47 Unused
#endregion #endregion

View file

@ -426,16 +426,19 @@ namespace PKHeX
public void setShinyPID() public void setShinyPID()
{ {
do PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm, PID); while (!IsShiny); do PID = PKX.getRandomPID(Species, Gender, Version, Nature, AltForm, PID); while (!IsShiny);
if (GenNumber < 6)
EncryptionConstant = PID; EncryptionConstant = PID;
} }
public void setPIDGender(int gender) public void setPIDGender(int gender)
{ {
do PID = PKX.getRandomPID(Species, gender, Version, Nature, AltForm, PID); while (IsShiny); do PID = PKX.getRandomPID(Species, gender, Version, Nature, AltForm, PID); while (IsShiny);
if (GenNumber < 6)
EncryptionConstant = PID; EncryptionConstant = PID;
} }
public void setPIDNature(int nature) public void setPIDNature(int nature)
{ {
do PID = PKX.getRandomPID(Species, Gender, Version, nature, AltForm, PID); while (IsShiny); do PID = PKX.getRandomPID(Species, Gender, Version, nature, AltForm, PID); while (IsShiny);
if (GenNumber < 6)
EncryptionConstant = PID; EncryptionConstant = PID;
} }
} }

View file

@ -98,7 +98,8 @@ namespace PKHeX
// Apply checksums // Apply checksums
for (int i = 0; i < Blocks.Length; i++) for (int i = 0; i < Blocks.Length; i++)
{ {
byte[] array = Data.Skip(Blocks[i].Offset).Take(Blocks[i].Length).ToArray(); byte[] array = new byte[Blocks[i].Length];
Array.Copy(Data, Blocks[i].Offset, array, 0, array.Length);
BitConverter.GetBytes(SaveUtil.ccitt16(array)).CopyTo(Data, BlockInfoOffset + 6 + i * 8); BitConverter.GetBytes(SaveUtil.ccitt16(array)).CopyTo(Data, BlockInfoOffset + 6 + i * 8);
} }
} }
@ -108,7 +109,8 @@ namespace PKHeX
{ {
for (int i = 0; i < Blocks.Length; i++) for (int i = 0; i < Blocks.Length; i++)
{ {
byte[] array = Data.Skip(Blocks[i].Offset).Take(Blocks[i].Length).ToArray(); byte[] array = new byte[Blocks[i].Length];
Array.Copy(Data, Blocks[i].Offset, array, 0, array.Length);
if (SaveUtil.ccitt16(array) != BitConverter.ToUInt16(Data, BlockInfoOffset + 6 + i * 8)) if (SaveUtil.ccitt16(array) != BitConverter.ToUInt16(Data, BlockInfoOffset + 6 + i * 8))
return false; return false;
} }
@ -123,7 +125,8 @@ namespace PKHeX
string rv = ""; string rv = "";
for (int i = 0; i < Blocks.Length; i++) for (int i = 0; i < Blocks.Length; i++)
{ {
byte[] array = Data.Skip(Blocks[i].Offset).Take(Blocks[i].Length).ToArray(); byte[] array = new byte[Blocks[i].Length];
Array.Copy(Data, Blocks[i].Offset, array, 0, array.Length);
if (SaveUtil.ccitt16(array) == BitConverter.ToUInt16(Data, BlockInfoOffset + 6 + i * 8)) if (SaveUtil.ccitt16(array) == BitConverter.ToUInt16(Data, BlockInfoOffset + 6 + i * 8))
continue; continue;

View file

@ -48,8 +48,8 @@ namespace PKHeX
public PersonalTable Personal { get; set; } public PersonalTable Personal { get; set; }
public bool ORASDEMO => Data.Length == SaveUtil.SIZE_G6ORASDEMO; public bool ORASDEMO => Data.Length == SaveUtil.SIZE_G6ORASDEMO;
public bool ORAS => Version == GameVersion.OR || Version == GameVersion.AS; public bool ORAS => Data.Length == SaveUtil.SIZE_G6ORAS;
public bool XY => Version == GameVersion.X || Version == GameVersion.Y; public bool XY => Data.Length == SaveUtil.SIZE_G6XY;
public bool B2W2 => Version == GameVersion.B2W2; public bool B2W2 => Version == GameVersion.B2W2;
public bool BW => Version == GameVersion.BW; public bool BW => Version == GameVersion.BW;
public bool HGSS => Version == GameVersion.HGSS; public bool HGSS => Version == GameVersion.HGSS;
@ -450,7 +450,10 @@ namespace PKHeX
// split up data to individual pkm // split up data to individual pkm
byte[][] pkdata = new byte[data.Length/SIZE_STORED][]; byte[][] pkdata = new byte[data.Length/SIZE_STORED][];
for (int i = 0; i < data.Length; i += SIZE_STORED) for (int i = 0; i < data.Length; i += SIZE_STORED)
pkdata[i/SIZE_STORED] = data.Skip(i).Take(SIZE_STORED).ToArray(); {
pkdata[i/SIZE_STORED] = new byte[SIZE_STORED];
Array.Copy(data, i, pkdata[i/SIZE_STORED], 0, SIZE_STORED);
}
PKM[] pkms = BoxData; PKM[] pkms = BoxData;
for (int i = 0; i < pkms.Length; i++) for (int i = 0; i < pkms.Length; i++)
@ -465,7 +468,10 @@ namespace PKHeX
byte[][] pkdata = new byte[data.Length / SIZE_STORED][]; byte[][] pkdata = new byte[data.Length / SIZE_STORED][];
for (int i = 0; i < data.Length; i += SIZE_STORED) for (int i = 0; i < data.Length; i += SIZE_STORED)
pkdata[i/SIZE_STORED] = data.Skip(i).Take(SIZE_STORED).ToArray(); {
pkdata[i/SIZE_STORED] = new byte[SIZE_STORED];
Array.Copy(data, i, pkdata[i/SIZE_STORED], 0, SIZE_STORED);
}
PKM[] pkms = BoxData; PKM[] pkms = BoxData;
for (int i = 0; i < 30; i++) for (int i = 0; i < 30; i++)
@ -479,7 +485,12 @@ namespace PKHeX
public byte[] getData(int Offset, int Length) public byte[] getData(int Offset, int Length)
{ {
return Data.Skip(Offset).Take(Length).ToArray(); if (Offset + Length > Data.Length)
return null;
byte[] data = new byte[Length];
Array.Copy(Data, Offset, data, 0, Length);
return data;
} }
public void setData(byte[] input, int Offset) public void setData(byte[] input, int Offset)
{ {

View file

@ -262,11 +262,15 @@ namespace PKHeX
{ {
try try
{ {
if (cmd.PropertyValue == CONST_RAND && (cmd.PropertyName == "PID" || cmd.PropertyName == "EncryptionConstant")) if (cmd.PropertyName == "EncryptionConstant" && cmd.PropertyValue == CONST_RAND)
ReflectUtil.SetValue(PKM, cmd.PropertyName, Util.rnd32().ToString()); ReflectUtil.SetValue(PKM, cmd.PropertyName, Util.rnd32().ToString());
else if (cmd.PropertyValue == CONST_SHINY && cmd.PropertyName == "PID") else if(cmd.PropertyName == "PID" && cmd.PropertyValue == CONST_RAND)
PKM.setPIDGender(PKM.Gender);
else if (cmd.PropertyName == "EncryptionConstant" && cmd.PropertyValue == "PID")
PKM.EncryptionConstant = PKM.PID;
else if (cmd.PropertyName == "PID" && cmd.PropertyValue == CONST_SHINY)
PKM.setShinyPID(); PKM.setShinyPID();
else if (cmd.PropertyValue == "0" && cmd.PropertyName == "Species") else if (cmd.PropertyName == "Species" && cmd.PropertyValue == "0")
PKM.Data = new byte[PKM.Data.Length]; PKM.Data = new byte[PKM.Data.Length];
else else
ReflectUtil.SetValue(PKM, cmd.PropertyName, cmd.PropertyValue); ReflectUtil.SetValue(PKM, cmd.PropertyName, cmd.PropertyValue);

View file

@ -123,7 +123,7 @@ namespace PKHeX
LB_Received.SelectedIndex = LB_Received.Items.IndexOf(card); LB_Received.SelectedIndex = LB_Received.Items.IndexOf(card);
} }
// Wonder Card IO (.wc6<->window) // Mystery Gift IO (.file<->window)
private string getFilter() private string getFilter()
{ {
switch (SAV.Generation) switch (SAV.Generation)
@ -169,7 +169,19 @@ namespace PKHeX
File.WriteAllBytes(path, mg.Data); File.WriteAllBytes(path, mg.Data);
} }
// Wonder Card RW (window<->sav) private int getLastUnfilledByType(MysteryGift Gift, MysteryGiftAlbum Album)
{
for (int i = 0; i < Album.Gifts.Length; i++)
{
if (!Album.Gifts[i].Empty)
continue;
if (Album.Gifts[i].Type != Gift.Type)
continue;
return i;
}
return -1;
}
// Mystery Gift RW (window<->sav)
private void clickView(object sender, EventArgs e) private void clickView(object sender, EventArgs e)
{ {
sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox; sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
@ -187,16 +199,16 @@ namespace PKHeX
int index = Array.IndexOf(pba, sender); int index = Array.IndexOf(pba, sender);
// Hijack to the latest unfilled slot if index creates interstitial empty slots. // Hijack to the latest unfilled slot if index creates interstitial empty slots.
int lastUnfilled = Array.FindIndex(pba, p => p.Image == null); int lastUnfilled = getLastUnfilledByType(mg, mga);
if (lastUnfilled > -1 && lastUnfilled < index) if (lastUnfilled > -1 && lastUnfilled < index)
index = lastUnfilled; index = lastUnfilled;
if (mg.Data.Length != mga.Gifts[index].Data.Length) if (mg.Type != mga.Gifts[index].Type)
{ {
Util.Alert("Can't set slot here.", $"{mg.GetType()} != {mga.Gifts[index].GetType()}"); Util.Alert("Can't set slot here.", $"{mg.Type} != {mga.Gifts[index].Type}");
return; return;
} }
setBackground(index, Properties.Resources.slotSet); setBackground(index, Properties.Resources.slotSet);
mga.Gifts[index] = mg; mga.Gifts[index] = mg.Clone();
setGiftBoxes(); setGiftBoxes();
setCardID(mg.CardID); setCardID(mg.CardID);
} }
@ -205,8 +217,26 @@ namespace PKHeX
sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox; sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
int index = Array.IndexOf(pba, sender); int index = Array.IndexOf(pba, sender);
setBackground(index, Properties.Resources.slotDel);
mga.Gifts[index].Data = new byte[mga.Gifts[index].Data.Length]; mga.Gifts[index].Data = new byte[mga.Gifts[index].Data.Length];
// Shuffle blank card down
int i = index;
while (i < mga.Gifts.Length - 1)
{
if (mga.Gifts[i+1].Empty)
break;
if (mga.Gifts[i+1].Type != mga.Gifts[i].Type)
break;
i++;
var mg1 = mga.Gifts[i];
var mg2 = mga.Gifts[i-1];
mga.Gifts[i-1] = mg1;
mga.Gifts[i] = mg2;
}
setBackground(i, Properties.Resources.slotDel);
setGiftBoxes(); setGiftBoxes();
} }
@ -230,7 +260,7 @@ namespace PKHeX
Close(); Close();
} }
// Delete WC Flag // Delete Received Flag
private void clearRecievedFlag(object sender, EventArgs e) private void clearRecievedFlag(object sender, EventArgs e)
{ {
if (LB_Received.SelectedIndex < 0) return; if (LB_Received.SelectedIndex < 0) return;
@ -301,14 +331,14 @@ namespace PKHeX
byte[] data = QR.getQRData(); byte[] data = QR.getQRData();
if (data == null) return; if (data == null) return;
string[] types = mga.Gifts.Select(g => g.GetType().Name).Distinct().ToArray(); string[] types = mga.Gifts.Select(g => g.Type).Distinct().ToArray();
MysteryGift gift = MysteryGift.getMysteryGift(data); MysteryGift gift = MysteryGift.getMysteryGift(data);
string giftType = gift.GetType().Name; string giftType = gift.Type;
if (mga.Gifts.All(card => card.Data.Length != data.Length)) if (mga.Gifts.All(card => card.Data.Length != data.Length))
Util.Alert("Decoded data not valid for loaded save file.", $"QR Data Size: 0x{data.Length.ToString("X")}"); Util.Alert("Decoded data not valid for loaded save file.", $"QR Data Size: 0x{data.Length.ToString("X")}");
else if (types.All(type => type != giftType)) else if (types.All(type => type != giftType))
Util.Alert("Gift type is not compatible with the save file.", $"QR Gift Type: {gift.GetType().Name}" + Environment.NewLine + $"Expected Types: {string.Join(", ", types)}"); Util.Alert("Gift type is not compatible with the save file.", $"QR Gift Type: {gift.Type}" + Environment.NewLine + $"Expected Types: {string.Join(", ", types)}");
else else
try { viewGiftData(gift); } try { viewGiftData(gift); }
catch { Util.Alert("Error loading Mystery Gift data."); } catch { Util.Alert("Error loading Mystery Gift data."); }
@ -324,7 +354,7 @@ namespace PKHeX
Image qr = QR.getQRImage(mg.Data, server); Image qr = QR.getQRImage(mg.Data, server);
if (qr == null) return; if (qr == null) return;
string desc = $"({mg.GetType().Name}) {getDescription(mg)}"; string desc = $"({mg.Type}) {getDescription(mg)}";
new QR(qr, PB_Preview.Image, desc, "", "", "PKHeX Wonder Card @ ProjectPokemon.org").ShowDialog(); new QR(qr, PB_Preview.Image, desc, "", "", "PKHeX Wonder Card @ ProjectPokemon.org").ShowDialog();
} }
@ -370,8 +400,8 @@ namespace PKHeX
int index = Array.IndexOf(pba, sender); int index = Array.IndexOf(pba, sender);
// Hijack to the latest unfilled slot if index creates interstitial empty slots. // Hijack to the latest unfilled slot if index creates interstitial empty slots.
int lastUnfilled = Array.FindIndex(pba, p => p.Image == null); int lastUnfilled = getLastUnfilledByType(mg, mga);
if (lastUnfilled < index) if (lastUnfilled > -1 && lastUnfilled < index)
index = lastUnfilled; index = lastUnfilled;
if (wc_slot == -1) // dropped if (wc_slot == -1) // dropped
@ -384,15 +414,11 @@ namespace PKHeX
{ Util.Alert("Data size invalid.", files[0]); return; } { Util.Alert("Data size invalid.", files[0]); return; }
byte[] data = File.ReadAllBytes(files[0]); byte[] data = File.ReadAllBytes(files[0]);
chk:
if (data.Length != mga.Gifts[index].Data.Length) if (data.Length != mga.Gifts[index].Data.Length)
{ {
if (index < 8) Util.Alert("Can't set slot here.",
{ $"{data.Length} != {mga.Gifts[index].Data.Length}, {mga.Gifts[index].Type}", files[0]);
index = 8; return;
goto chk;
}
{ Util.Alert("Can't set slot here.", $"{data.Length} != {mga.Gifts[index].Data.Length}, {mga.Gifts[index].GetType()}", files[0]); return; }
} }
mga.Gifts[index].Data = data; mga.Gifts[index].Data = data;
@ -401,17 +427,34 @@ namespace PKHeX
} }
else // Swap Data else // Swap Data
{ {
// Check to see if they copied beyond blank slots.
if (index > Math.Max(wc_slot, lastUnfilled - 1))
index = Math.Max(wc_slot, lastUnfilled - 1);
MysteryGift s1 = mga.Gifts[index]; MysteryGift s1 = mga.Gifts[index];
MysteryGift s2 = mga.Gifts[wc_slot]; MysteryGift s2 = mga.Gifts[wc_slot];
if (s1.Data.Length != s2.Data.Length) if (s1.Type != s2.Type)
{ Util.Alert("Can't swap these two slots."); return; } { Util.Alert($"Can't swap {s1.Type} with {s2.Type}."); return; }
mga.Gifts[wc_slot] = s1; mga.Gifts[wc_slot] = s1;
mga.Gifts[index] = s2; mga.Gifts[index] = s2;
if (mga.Gifts[wc_slot].Empty) // empty slot created, slide down
{
int i = wc_slot;
while (i < index)
{
if (mga.Gifts[i + 1].Empty)
break;
if (mga.Gifts[i + 1].Type != mga.Gifts[i].Type)
break;
i++;
var mg1 = mga.Gifts[i];
var mg2 = mga.Gifts[i - 1];
mga.Gifts[i - 1] = mg1;
mga.Gifts[i] = mg2;
}
index = i-1;
}
} }
setBackground(index, Properties.Resources.slotView); setBackground(index, Properties.Resources.slotView);
setGiftBoxes(); setGiftBoxes();