mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-16 21:38:40 +00:00
Dump Single Box (#962)
* Dump Single Box Probably can be better optimized or something. The code works, the thing is I can't seem to edit the Menu Items to add this in as it causes the view to go haywire. VS can be silly sometimes. For your consideration :) Related: https://projectpokemon.org/forums/forums/topic/40358-how-to-export-all-pokemon-in-boxes-as-pk7/ * Manual Design Edit of Main
This commit is contained in:
parent
2bb9f61033
commit
6f7c8e73a0
3 changed files with 49 additions and 0 deletions
11
PKHeX.WinForms/MainWindow/Main.Designer.cs
generated
11
PKHeX.WinForms/MainWindow/Main.Designer.cs
generated
|
@ -306,6 +306,7 @@
|
|||
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 @@
|
|||
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 @@
|
|||
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 @@
|
|||
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;
|
||||
|
|
|
@ -530,6 +530,22 @@ namespace PKHeX.WinForms
|
|||
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();
|
||||
|
|
|
@ -47,6 +47,28 @@ namespace PKHeX.WinForms
|
|||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a folder of files to the <see cref="SaveFile"/>.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Reference in a new issue