diff --git a/PKX/f1-Main.Designer.cs b/PKX/f1-Main.Designer.cs
index 2e7fbcf41..837ab6931 100644
--- a/PKX/f1-Main.Designer.cs
+++ b/PKX/f1-Main.Designer.cs
@@ -3304,6 +3304,7 @@ public void InitializeComponent()
this.bbpkx1.TabIndex = 8;
this.bbpkx1.TabStop = false;
this.bbpkx1.Click += new System.EventHandler(this.slotModifier_Click);
+ this.bbpkx1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bbpkx2
//
@@ -3314,6 +3315,7 @@ public void InitializeComponent()
this.bbpkx2.TabIndex = 9;
this.bbpkx2.TabStop = false;
this.bbpkx2.Click += new System.EventHandler(this.slotModifier_Click);
+ this.bbpkx2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bbpkx3
//
@@ -3324,6 +3326,7 @@ public void InitializeComponent()
this.bbpkx3.TabIndex = 10;
this.bbpkx3.TabStop = false;
this.bbpkx3.Click += new System.EventHandler(this.slotModifier_Click);
+ this.bbpkx3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bbpkx4
//
@@ -3334,6 +3337,7 @@ public void InitializeComponent()
this.bbpkx4.TabIndex = 11;
this.bbpkx4.TabStop = false;
this.bbpkx4.Click += new System.EventHandler(this.slotModifier_Click);
+ this.bbpkx4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bbpkx5
//
@@ -3344,6 +3348,7 @@ public void InitializeComponent()
this.bbpkx5.TabIndex = 12;
this.bbpkx5.TabStop = false;
this.bbpkx5.Click += new System.EventHandler(this.slotModifier_Click);
+ this.bbpkx5.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// bbpkx6
//
@@ -3354,6 +3359,7 @@ public void InitializeComponent()
this.bbpkx6.TabIndex = 13;
this.bbpkx6.TabStop = false;
this.bbpkx6.Click += new System.EventHandler(this.slotModifier_Click);
+ this.bbpkx6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// L_ReadOnlyPBB
//
@@ -3406,6 +3412,7 @@ public void InitializeComponent()
this.ppkx1.TabIndex = 2;
this.ppkx1.TabStop = false;
this.ppkx1.Click += new System.EventHandler(this.slotModifier_Click);
+ this.ppkx1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// ppkx2
//
@@ -3416,6 +3423,7 @@ public void InitializeComponent()
this.ppkx2.TabIndex = 3;
this.ppkx2.TabStop = false;
this.ppkx2.Click += new System.EventHandler(this.slotModifier_Click);
+ this.ppkx2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// ppkx3
//
@@ -3426,6 +3434,7 @@ public void InitializeComponent()
this.ppkx3.TabIndex = 4;
this.ppkx3.TabStop = false;
this.ppkx3.Click += new System.EventHandler(this.slotModifier_Click);
+ this.ppkx3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// ppkx4
//
@@ -3436,6 +3445,7 @@ public void InitializeComponent()
this.ppkx4.TabIndex = 5;
this.ppkx4.TabStop = false;
this.ppkx4.Click += new System.EventHandler(this.slotModifier_Click);
+ this.ppkx4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// ppkx5
//
@@ -3446,6 +3456,7 @@ public void InitializeComponent()
this.ppkx5.TabIndex = 6;
this.ppkx5.TabStop = false;
this.ppkx5.Click += new System.EventHandler(this.slotModifier_Click);
+ this.ppkx5.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// ppkx6
//
@@ -3456,15 +3467,16 @@ public void InitializeComponent()
this.ppkx6.TabIndex = 7;
this.ppkx6.TabStop = false;
this.ppkx6.Click += new System.EventHandler(this.slotModifier_Click);
+ this.ppkx6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// Tab_Other
//
this.Tab_Other.Controls.Add(this.B_OpenSecretBase);
- this.Tab_Other.Controls.Add(this.GB_SUBE);
this.Tab_Other.Controls.Add(this.GB_Daycare);
this.Tab_Other.Controls.Add(this.GB_GTS);
this.Tab_Other.Controls.Add(this.GB_Fused);
this.Tab_Other.Controls.Add(this.L_ReadOnlyOther);
+ this.Tab_Other.Controls.Add(this.GB_SUBE);
this.Tab_Other.Location = new System.Drawing.Point(4, 22);
this.Tab_Other.Name = "Tab_Other";
this.Tab_Other.Size = new System.Drawing.Size(302, 199);
@@ -3505,6 +3517,7 @@ public void InitializeComponent()
this.subepkx1.TabIndex = 18;
this.subepkx1.TabStop = false;
this.subepkx1.Click += new System.EventHandler(this.slotModifier_Click);
+ this.subepkx1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// subepkx2
//
@@ -3627,6 +3640,7 @@ public void InitializeComponent()
this.dcpkx2.TabIndex = 11;
this.dcpkx2.TabStop = false;
this.dcpkx2.Click += new System.EventHandler(this.slotModifier_Click);
+ this.dcpkx2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// dcpkx1
//
@@ -3638,6 +3652,7 @@ public void InitializeComponent()
this.dcpkx1.TabIndex = 10;
this.dcpkx1.TabStop = false;
this.dcpkx1.Click += new System.EventHandler(this.slotModifier_Click);
+ this.dcpkx1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// DayCare_HasEgg
//
@@ -3670,6 +3685,7 @@ public void InitializeComponent()
this.gtspkx.TabIndex = 23;
this.gtspkx.TabStop = false;
this.gtspkx.Click += new System.EventHandler(this.slotModifier_Click);
+ this.gtspkx.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// GB_Fused
//
@@ -3691,6 +3707,7 @@ public void InitializeComponent()
this.fusedpkx.TabIndex = 24;
this.fusedpkx.TabStop = false;
this.fusedpkx.Click += new System.EventHandler(this.slotModifier_Click);
+ this.fusedpkx.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pbBoxSlot_MouseDown);
//
// L_ReadOnlyOther
//
diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs
index 71ce15d18..07bb3cc1e 100644
--- a/PKX/f1-Main.cs
+++ b/PKX/f1-Main.cs
@@ -4307,9 +4307,14 @@ private void dragout_MouseDown(object sender, MouseEventArgs e)
// Create Temp File to Drag
string basepath = System.Windows.Forms.Application.StartupPath;
Cursor.Current = Cursors.Hand;
- // Make a new file name based off the PID
- string filename = TB_Nickname.Text + " - " + TB_PID.Text + ".pk6";
+ // Make a new file name
byte[] dragdata = preparepkx(buff);
+ PKX pkx = new PKX(dragdata);
+ string filename = pkx.Nickname;
+ if (filename != pkx.Species)
+ filename += " (" + pkx.Species + ")";
+ filename += " - " + pkx.PID + ".pk6";
+
// Strip out party stats (if they are there)
Array.Resize(ref dragdata, 232);
// Make File
@@ -4323,7 +4328,7 @@ private void dragout_MouseDown(object sender, MouseEventArgs e)
File.Delete(newfile);
}
catch (ArgumentException x)
- { MessageBox.Show("Drag&Drop Error\r\n" + x, "Error"); }
+ { MessageBox.Show("Drag&Drop Error\n\n" + x, "Error"); }
File.Delete(newfile);
}
}
@@ -4340,9 +4345,14 @@ private void eragout_MouseDown(object sender, MouseEventArgs e)
string basepath = System.Windows.Forms.Application.StartupPath;
Cursor.Current = Cursors.Hand;
- // Make a new file name based off the PID
- string filename = TB_Nickname.Text + " - " + TB_PID.Text + ".ek6";
- byte[] dragdata = PKX.encryptArray(preparepkx(buff));
+ // Make a new file name
+ byte[] dragdata = preparepkx(buff);
+ PKX pkx = new PKX(dragdata);
+ string filename = pkx.Nickname;
+ if (filename != pkx.Species)
+ filename += " (" + pkx.Species + ")";
+ filename += " - " + pkx.PID + ".ek6";
+ dragdata = PKX.encryptArray(preparepkx(buff));
// Strip out party stats (if they are there)
Array.Resize(ref dragdata, 232);
// Make file
@@ -4357,7 +4367,7 @@ private void eragout_MouseDown(object sender, MouseEventArgs e)
}
catch (ArgumentException x)
{
- MessageBox.Show("Drag&Drop Error\r\n" + x, "Error");
+ MessageBox.Show("Drag&Drop Error\n\n" + x, "Error");
}
File.Delete(newfile);
}
@@ -6123,25 +6133,94 @@ private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e)
int offset = getPKXOffset(slot);
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
+ // Create Temp File to Drag
+ string basepath = System.Windows.Forms.Application.StartupPath;
+ Cursor.Current = Cursors.Hand;
+
+ // Prepare Data
Array.Copy(savefile, offset, pkm_from, 0, 0xE8);
pkm_from_offset = offset;
- (sender as PictureBox).DoDragDrop(pkm_from, DragDropEffects.Move);
+
+ // Make a new file name based off the PID
+ byte[] dragdata = PKX.decryptArray(pkm_from);
+ Array.Resize(ref dragdata, 0xE8);
+ PKX pkx = new PKX(dragdata);
+ string filename = pkx.Nickname;
+ if (filename != pkx.Species)
+ filename += " (" + pkx.Species + ")";
+ filename += " - " + pkx.PID + ".pk6";
+
+ // Make File
+ string newfile = Path.Combine(basepath, Util.CleanFileName(filename));
+ try
+ {
+ File.WriteAllBytes(newfile, dragdata);
+
+ string[] filesToDrag = { newfile };
+ (sender as PictureBox).DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Move);
+ File.Delete(newfile);
+ }
+ catch (ArgumentException x)
+ { MessageBox.Show("Drag&Drop Error\n\n" + x, "Error"); }
+ File.Delete(newfile);
+ pkm_from_offset = 0;
+ //Array.Copy(savefile, offset, pkm_from, 0, 0xE8);
+ //pkm_from_offset = offset;
+ //(sender as PictureBox).DoDragDrop(pkm_from, DragDropEffects.Move);
}
}
private void pbBoxSlot_DragDrop(object sender, DragEventArgs e)
{
- string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
- if (files != null)
- if (files.Length > 0) openQuick(files[0]);
PictureBox pb = (PictureBox)(sender);
int slot = getSlot(sender);
int offset = getPKXOffset(slot);
- if (ModifierKeys == Keys.Alt)
- Array.Copy(PKX.encryptArray(new Byte[0xE8]), 0, savefile, pkm_from_offset, 0xE8);
- else if (ModifierKeys != Keys.Control)
- Array.Copy(savefile, offset, savefile, pkm_from_offset, 0xE8); // Copy from new slot to old slot.
- Array.Copy(pkm_from, 0, savefile, offset, 0xE8); // Copy from temp slot to new.
+ // Check for In-Dropped files (PKX,SAV,ETC)
+ string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
+ if (files != null && pkm_from_offset == 0)
+ {
+ if (files.Length > 0)
+ {
+ FileInfo fi = new FileInfo(files[0]);
+
+ // Detect if PKM/PKX
+ if ((fi.Length == 136) || (fi.Length == 220) || (fi.Length == 236) || (fi.Length == 100) || (fi.Length == 80))
+ {
+ byte[] input = File.ReadAllBytes(files[0]);
+ var Converter = new pk2pk();
+ if (!PKX.verifychk(input)) MessageBox.Show("Invalid File (Checksum Error)", "Error");
+ try // to convert past gen pkm
+ {
+ byte[] data = Converter.ConvertPKM(input, savefile, savindex);
+ data = PKX.encryptArray(data);
+ Array.Copy(PKX.encryptArray(data), 0, savefile, offset, 0xE8);
+ }
+ catch
+ { MessageBox.Show("Attempted to load previous generation PKM.\n\nConversion failed.", "Alert"); }
+ }
+ else if (fi.Length == 232 || fi.Length == 260)
+ {
+ byte[] data = File.ReadAllBytes(files[0]);
+ if (fi.Extension == ".pkx" || fi.Extension == ".pk6")
+ data = PKX.encryptArray(data);
+ else if (fi.Extension != ".ekx" || fi.Extension != ".ekx")
+ openQuick(files[0]);
+
+ Array.Copy(data, 0, savefile, offset, 0xE8);
+ }
+ else // not PKX/EKX, so load with the general function
+ { openQuick(files[0]); }
+ }
+ }
+ else
+ {
+ if (ModifierKeys == Keys.Alt)
+ Array.Copy(PKX.encryptArray(new Byte[0xE8]), 0, savefile, pkm_from_offset, 0xE8);
+ else if (ModifierKeys != Keys.Control)
+ Array.Copy(savefile, offset, savefile, pkm_from_offset, 0xE8); // Copy from new slot to old slot.
+ Array.Copy(pkm_from, 0, savefile, offset, 0xE8); // Copy from temp slot to new.
+ pkm_from_offset = 0; // Clear offset value
+ }
setPKXBoxes();
}
private void pbBoxSlot_DragEnter(object sender, DragEventArgs e)
@@ -6150,7 +6229,7 @@ private void pbBoxSlot_DragEnter(object sender, DragEventArgs e)
e.Effect = DragDropEffects.Move;
}
private byte[] pkm_from = new Byte[0xE8];
- private int pkm_from_offset;
+ private int pkm_from_offset = 0;
private void L_Save_Click(object sender, EventArgs e)
{
// Get latest SaveDataFiler save location
diff --git a/PKX/f1-Main.resx b/PKX/f1-Main.resx
index 9008ceff3..3e932927d 100644
--- a/PKX/f1-Main.resx
+++ b/PKX/f1-Main.resx
@@ -528,12 +528,6 @@
True
-
- True
-
-
- True
-
True
@@ -585,6 +579,12 @@
True
+
+ True
+
+
+ True
+
True