From 4f99ef6c09b868cb6071ad63fadfa2374f5ac9e3 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 20 Jan 2017 08:43:41 -0800 Subject: [PATCH] Set Slot id to 3 if no pcd found Closes #730 Adds ability to set a PCD to a PGT slot (grabs the PGT from card) --- .../Subforms/Save Editors/SAV_Wondercard.cs | 19 +++++++++++++------ PKHeX/Saves/SAV4.cs | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs index 5a4a484ed..e0c5c4660 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_Wondercard.cs @@ -203,7 +203,10 @@ private void clickSet(object sender, EventArgs e) int lastUnfilled = getLastUnfilledByType(mg, mga); if (lastUnfilled > -1 && lastUnfilled < index) index = lastUnfilled; - if (mg.Type != mga.Gifts[index].Type) + + if (mg is PCD && mga.Gifts[index] is PGT) + mg = (mg as PCD).Gift; + else if (mg.Type != mga.Gifts[index].Type) { WinFormsUtil.Alert("Can't set slot here.", $"{mg.Type} != {mga.Gifts[index].Type}"); return; @@ -417,14 +420,18 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { WinFormsUtil.Alert("Data size invalid.", files[0]); return; } byte[] data = File.ReadAllBytes(files[0]); - if (data.Length != mga.Gifts[index].Data.Length) + MysteryGift mg = MysteryGift.getMysteryGift(data, new FileInfo(files[0]).Extension); + + if (mg is PCD && mga.Gifts[index] is PGT) + mg = (mg as PCD).Gift; + else if (mg.Type != mga.Gifts[index].Type) { - WinFormsUtil.Alert("Can't set slot here.", - $"{data.Length} != {mga.Gifts[index].Data.Length}, {mga.Gifts[index].Type}", files[0]); + WinFormsUtil.Alert("Can't set slot here.", $"{mg.Type} != {mga.Gifts[index].Type}"); return; } - - mga.Gifts[index].Data = data; + setBackground(index, Core.Properties.Resources.slotSet); + mga.Gifts[index] = mg.Clone(); + setCardID(mga.Gifts[index].CardID); viewGiftData(mga.Gifts[index]); } diff --git a/PKHeX/Saves/SAV4.cs b/PKHeX/Saves/SAV4.cs index 4293d4ce8..b33a88eab 100644 --- a/PKHeX/Saves/SAV4.cs +++ b/PKHeX/Saves/SAV4.cs @@ -605,6 +605,7 @@ private static int[] matchMysteryGifts(MysteryGift[] value) if (pgt == null) continue; + cardMatch[i] = pgt.Slot = 3; for (byte j = 0; j < 3; j++) { var pcd = value[8 + j] as PCD;