diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index 457e67756..d5effeae1 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -4937,6 +4937,8 @@ public void InitializeComponent() this.ppkx1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.ppkx1.TabIndex = 2; this.ppkx1.TabStop = false; + this.ppkx1.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop); + this.ppkx1.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter); this.ppkx1.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.pbBoxSlot_QueryContinueDrag); this.ppkx1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseClick); this.ppkx1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown); @@ -4952,6 +4954,8 @@ public void InitializeComponent() this.ppkx2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.ppkx2.TabIndex = 3; this.ppkx2.TabStop = false; + this.ppkx2.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop); + this.ppkx2.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter); this.ppkx2.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.pbBoxSlot_QueryContinueDrag); this.ppkx2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseClick); this.ppkx2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown); @@ -4967,6 +4971,8 @@ public void InitializeComponent() this.ppkx3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.ppkx3.TabIndex = 4; this.ppkx3.TabStop = false; + this.ppkx3.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop); + this.ppkx3.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter); this.ppkx3.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.pbBoxSlot_QueryContinueDrag); this.ppkx3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseClick); this.ppkx3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown); @@ -4982,6 +4988,8 @@ public void InitializeComponent() this.ppkx4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.ppkx4.TabIndex = 5; this.ppkx4.TabStop = false; + this.ppkx4.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop); + this.ppkx4.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter); this.ppkx4.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.pbBoxSlot_QueryContinueDrag); this.ppkx4.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseClick); this.ppkx4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown); @@ -4997,6 +5005,8 @@ public void InitializeComponent() this.ppkx5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.ppkx5.TabIndex = 6; this.ppkx5.TabStop = false; + this.ppkx5.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop); + this.ppkx5.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter); this.ppkx5.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.pbBoxSlot_QueryContinueDrag); this.ppkx5.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseClick); this.ppkx5.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown); @@ -5012,6 +5022,8 @@ public void InitializeComponent() this.ppkx6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.ppkx6.TabIndex = 7; this.ppkx6.TabStop = false; + this.ppkx6.DragDrop += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragDrop); + this.ppkx6.DragEnter += new System.Windows.Forms.DragEventHandler(this.pbBoxSlot_DragEnter); this.ppkx6.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.pbBoxSlot_QueryContinueDrag); this.ppkx6.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseClick); this.ppkx6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown); diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index b192d4aba..e93a18f33 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -3595,7 +3595,7 @@ private void updateIsNicknamed(object sender, EventArgs e) } // Generic Subfunctions // - private void setParty() + public void setParty() { PKM[] party = SAV.PartyData; PKM[] battle = SAV.BattleBoxData; @@ -4197,7 +4197,7 @@ private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e) getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset)); pb.BackgroundImage = null; - if (DragInfo.slotDestinationBoxNumber == DragInfo.slotSourceBoxNumber && DragInfo.slotDestinationSlotNumber > -1) + if (DragInfo.SameBox) SlotPictureBoxes[DragInfo.slotDestinationSlotNumber].Image = img; if (result == DragDropEffects.Copy) // viewed in tabs, apply 'view' highlight @@ -4219,6 +4219,8 @@ private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e) if (File.Exists(newfile) && DragInfo.CurrentPath == null) File.Delete(newfile); }).Start(); + if (DragInfo.SourceParty || DragInfo.DestinationParty) + setParty(); } } private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) @@ -4263,14 +4265,14 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { Console.WriteLine(c); Console.WriteLine(concat); return; } } - SAV.setStoredSlot(pk, DragInfo.slotDestinationOffset); + DragInfo.setPKMtoDestination(SAV, pk); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pk); getSlotColor(DragInfo.slotDestinationSlotNumber, Properties.Resources.slotSet); Console.WriteLine(c); } else { - PKM pkz = SAV.getStoredSlot(DragInfo.slotSourceOffset); + PKM pkz = DragInfo.getPKMfromSource(SAV); if (!DragInfo.SourceValid) { } // not overwritable, do nothing else if (ModifierKeys == Keys.Alt && DragInfo.DestinationValid) // overwrite delete old slot { @@ -4278,13 +4280,13 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) if (DragInfo.SameBox) getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], SAV.BlankPKM); // picturebox - SAV.setStoredSlot(SAV.BlankPKM, DragInfo.slotSourceOffset); + DragInfo.setPKMtoSource(SAV, SAV.BlankPKM); } else if (ModifierKeys != Keys.Control && DragInfo.DestinationValid) { // Load data from destination PKM pk = ((PictureBox) sender).Image != null - ? SAV.getStoredSlot(DragInfo.slotDestinationOffset) + ? DragInfo.getPKMfromDestination(SAV) : SAV.BlankPKM; // Set destination pokemon image to source picture box @@ -4292,18 +4294,20 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pk); // Set destination pokemon data to source slot - SAV.setStoredSlot(pk, DragInfo.slotSourceOffset); + DragInfo.setPKMtoSource(SAV, pk); } else if (DragInfo.SameBox) getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pkz); // Copy from temp to destination slot. - SAV.setStoredSlot(pkz, DragInfo.slotDestinationOffset); + DragInfo.setPKMtoDestination(SAV, pkz); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pkz); e.Effect = DragDropEffects.Link; Cursor = DefaultCursor; } + if (DragInfo.SourceParty || DragInfo.DestinationParty) + setParty(); if (DragInfo.slotSource == null) // another instance or file { notifyBoxViewerRefresh(); @@ -4353,8 +4357,51 @@ public static class DragInfo public static string CurrentPath; public static bool SameBox => slotSourceBoxNumber > -1 && slotSourceBoxNumber == slotDestinationBoxNumber; - public static bool SourceValid => slotSourceBoxNumber > -1; - public static bool DestinationValid => slotDestinationBoxNumber > -1; + public static bool SourceValid => slotSourceBoxNumber > -1 || SourceParty; + public static bool DestinationValid => slotDestinationBoxNumber > -1 || DestinationParty; + public static bool SourceParty => 30 <= slotSourceSlotNumber && slotSourceSlotNumber < 36; + public static bool DestinationParty => 30 <= slotDestinationSlotNumber && slotDestinationSlotNumber < 36; + + // PKM Get Set + public static PKM getPKMfromSource(SaveFile SAV) + { + int o = slotSourceOffset; + return SourceParty ? SAV.getPartySlot(o) : SAV.getStoredSlot(o); + } + public static PKM getPKMfromDestination(SaveFile SAV) + { + int o = slotDestinationOffset; + return DestinationParty ? SAV.getPartySlot(o) : SAV.getStoredSlot(o); + } + public static void setPKMtoSource(SaveFile SAV, PKM pk) + { + int o = slotSourceOffset; + if (!SourceParty) + { SAV.setStoredSlot(pk, o); return; } + + if (pk.Species == 0) // Empty Slot + { SAV.deletePartySlot(slotSourceSlotNumber-30); return; } + + if (pk.Stat_HPMax == 0) // Without Stats (Box) + pk.setStats(pk.getStats(pk.PersonalInfo)); + SAV.setPartySlot(pk, o); + } + public static void setPKMtoDestination(SaveFile SAV, PKM pk) + { + int o = slotDestinationOffset; + if (!DestinationParty) + { SAV.setStoredSlot(pk, o); return; } + + if (30 + SAV.PartyCount < slotDestinationSlotNumber) + { + o = SAV.getPartyOffset(SAV.PartyCount); + slotDestinationSlotNumber = 30 + SAV.PartyCount; + } + if (pk.Stat_HPMax == 0) // Without Stats (Box/File) + pk.setStats(pk.getStats(pk.PersonalInfo)); + SAV.setPartySlot(pk, o); + } + public static void Reset() { slotLeftMouseIsDown = false; diff --git a/PKHeX/MainWindow/Main.resx b/PKHeX/MainWindow/Main.resx index 940512ccf..1cbb3146b 100644 --- a/PKHeX/MainWindow/Main.resx +++ b/PKHeX/MainWindow/Main.resx @@ -129,15 +129,6 @@ True - - True - - - True - - - True - @@ -164,33 +155,12 @@ True - - True - - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -200,21 +170,6 @@ True - - True - - - True - - - True - - - True - - - True - True @@ -233,30 +188,12 @@ True - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -275,33 +212,9 @@ True - - True - - - True - - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -317,15 +230,6 @@ True - - True - - - True - - - True - True @@ -335,27 +239,9 @@ True - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -371,30 +257,12 @@ True - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -407,15 +275,6 @@ True - - True - - - True - - - True - True @@ -425,18 +284,6 @@ True - - True - - - True - - - True - - - True - True @@ -455,36 +302,12 @@ True - - True - - - True - - - True - - - True - True True - - True - - - True - - - True - - - True - True @@ -497,18 +320,6 @@ True - - True - - - True - - - True - - - True - True @@ -518,66 +329,12 @@ True - - True - True True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -620,9 +377,6 @@ True - - True - True @@ -632,18 +386,6 @@ True - - True - - - True - - - True - - - True - True @@ -656,30 +398,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -692,9 +413,6 @@ True - - True - True @@ -704,18 +422,6 @@ True - - True - - - True - - - True - - - True - True @@ -728,30 +434,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - - - True - True @@ -764,18 +449,6 @@ True - - True - - - True - - - True - - - True - True @@ -788,18 +461,6 @@ True - - True - - - True - - - True - - - True - True @@ -815,18 +476,6 @@ True - - True - - - True - - - True - - - True - True @@ -842,24 +491,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAeZJREFUOE+1 @@ -931,30 +562,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAeZJREFUOE+1 @@ -1077,57 +684,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1140,27 +696,9 @@ True - - True - - - True - - - True - True - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -1318,33 +856,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1381,108 +892,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1588,42 +997,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAAG8AAACgCAYAAAACezIBAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -1737,24 +1110,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - iVBORw0KGgoAAAANSUhEUgAAAG8AAACgCAYAAAACezIBAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -1825,54 +1180,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -1912,18 +1219,12 @@ True - - True - True True - - True - True @@ -1933,36 +1234,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True diff --git a/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs b/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs index 12ec9bf6c..3b557e35c 100644 --- a/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs +++ b/PKHeX/Subforms/Save Editors/SAV_BoxViewer.cs @@ -207,7 +207,7 @@ private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e) getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset)); pb.BackgroundImage = null; - if (DragInfo.slotDestinationBoxNumber == DragInfo.slotSourceBoxNumber) + if (DragInfo.SameBox) SlotPictureBoxes[DragInfo.slotDestinationSlotNumber].Image = img; } catch (Exception x) @@ -270,13 +270,13 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { Console.WriteLine(c); Console.WriteLine(concat); return; } } - SAV.setStoredSlot(pk, DragInfo.slotDestinationOffset); + DragInfo.setPKMtoDestination(SAV, pk); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pk); Console.WriteLine(c); } else { - PKM pkz = SAV.getStoredSlot(DragInfo.slotSourceOffset); + PKM pkz = DragInfo.getPKMfromSource(SAV); if (!DragInfo.SourceValid) { } // not overwritable, do nothing else if (ModifierKeys == Keys.Alt && DragInfo.DestinationValid) // overwrite { @@ -284,13 +284,13 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) if (DragInfo.SameBox) getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], SAV.BlankPKM); // picturebox - SAV.setStoredSlot(SAV.BlankPKM, DragInfo.slotSourceOffset); + DragInfo.setPKMtoSource(SAV, SAV.BlankPKM); } else if (ModifierKeys != Keys.Control && DragInfo.DestinationValid) // move { // Load data from destination PKM pk = ((PictureBox)sender).Image != null - ? SAV.getStoredSlot(DragInfo.slotDestinationOffset) + ? DragInfo.getPKMfromDestination(SAV) : SAV.BlankPKM; // Set destination pokemon image to source picture box @@ -298,18 +298,20 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pk); // Set destination pokemon data to source slot - SAV.setStoredSlot(pk, DragInfo.slotSourceOffset); + DragInfo.setPKMtoSource(SAV, pk); } else if (DragInfo.SameBox) // clone getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pkz); // Copy from temp to destination slot. - SAV.setStoredSlot(pkz, DragInfo.slotDestinationOffset); + DragInfo.setPKMtoDestination(SAV, pkz); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pkz); e.Effect = DragDropEffects.Link; Cursor = DefaultCursor; } + if (DragInfo.SourceParty || DragInfo.DestinationParty) + parent.setParty(); if (DragInfo.slotSource == null) // another instance or file { parent.notifyBoxViewerRefresh();