diff --git a/PKHeX.WinForms/MainWindow/Main.Designer.cs b/PKHeX.WinForms/MainWindow/Main.Designer.cs index 8ede52e30..725e079a5 100644 --- a/PKHeX.WinForms/MainWindow/Main.Designer.cs +++ b/PKHeX.WinForms/MainWindow/Main.Designer.cs @@ -306,6 +306,7 @@ public void InitializeComponent() this.Menu_Data = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_LoadBoxes = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_DumpBoxes = new System.Windows.Forms.ToolStripMenuItem(); + this.Menu_DumpBox = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_Report = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_Database = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_MGDatabase = new System.Windows.Forms.ToolStripMenuItem(); @@ -3881,6 +3882,7 @@ public void InitializeComponent() this.Menu_Data.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.Menu_LoadBoxes, this.Menu_DumpBoxes, + this.Menu_DumpBox, this.Menu_Report, this.Menu_Database, this.Menu_MGDatabase, @@ -3906,6 +3908,14 @@ public void InitializeComponent() this.Menu_DumpBoxes.Text = "Dump Boxes"; this.Menu_DumpBoxes.Click += new System.EventHandler(this.mainMenuBoxDump); // + // Menu_DumpBox + // + this.Menu_DumpBox.Image = ((System.Drawing.Image)(resources.GetObject("Menu_DumpBoxes.Image"))); + this.Menu_DumpBox.Name = "Menu_DumpBox"; + this.Menu_DumpBox.Size = new System.Drawing.Size(182, 22); + this.Menu_DumpBox.Text = "Dump Box"; + this.Menu_DumpBox.Click += new System.EventHandler(this.mainMenuBoxDumpSingle); + // // Menu_Report // this.Menu_Report.Image = ((System.Drawing.Image)(resources.GetObject("Menu_Report.Image"))); @@ -6291,6 +6301,7 @@ public void InitializeComponent() private System.Windows.Forms.MaskedTextBox Stat_ATK; private System.Windows.Forms.MaskedTextBox Stat_HP; private System.Windows.Forms.ToolStripMenuItem Menu_DumpBoxes; + private System.Windows.Forms.ToolStripMenuItem Menu_DumpBox; private System.Windows.Forms.ToolStripMenuItem Menu_ExportBAK; private System.Windows.Forms.ToolStripMenuItem Menu_ExportMAIN; private System.Windows.Forms.MaskedTextBox TB_PP1; diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs index d2bcc4252..5b349bdce 100644 --- a/PKHeX.WinForms/MainWindow/Main.cs +++ b/PKHeX.WinForms/MainWindow/Main.cs @@ -530,6 +530,22 @@ private void mainMenuBoxDump(object sender, EventArgs e) SAV.dumpBoxes(path, out result, separate); WinFormsUtil.Alert(result); } + private void mainMenuBoxDumpSingle(object sender, EventArgs e) + { + string path; + + // open folder dialog + FolderBrowserDialog fbd = new FolderBrowserDialog(); + if (fbd.ShowDialog() != DialogResult.OK) + return; + + path = fbd.SelectedPath; + + string result; + int currentBox = CB_BoxSelect.SelectedIndex; + SAV.dumpBox(path, out result, currentBox); + WinFormsUtil.Alert(result); + } private void manMenuBatchEditor(object sender, EventArgs e) { new BatchEditor(preparePKM()).ShowDialog(); diff --git a/PKHeX.WinForms/Util/SAVUtil.cs b/PKHeX.WinForms/Util/SAVUtil.cs index 47a79ff7d..0faf0ce41 100644 --- a/PKHeX.WinForms/Util/SAVUtil.cs +++ b/PKHeX.WinForms/Util/SAVUtil.cs @@ -47,6 +47,28 @@ public static bool dumpBoxes(this SaveFile SAV, string path, out string result, return true; } + public static bool dumpBox(this SaveFile SAV, string path, out string result, int currentBox) + { + PKM[] boxdata = SAV.BoxData; + if (boxdata == null) + { result = "Invalid Box Data, unable to dump."; return false; } + + int ctr = 0; + foreach (PKM pk in boxdata) + { + if (pk.Species == 0 || !pk.Valid || (pk.Box - 1) != currentBox) + continue; + + ctr++; + string fileName = Util.CleanFileName(pk.FileName); + if (!File.Exists(Path.Combine(path, fileName))) + File.WriteAllBytes(Path.Combine(path, fileName), pk.DecryptedBoxData); + } + + result = $"Dumped Box ({ctr} pkm) to path:\n" + path; + return true; + } + /// /// Loads a folder of files to the . ///