mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
Add mass export, drag import, fix onload
select folder to export drag import to current slot display slot 0 on form load
This commit is contained in:
parent
7da46623b8
commit
f5c5145cbf
2 changed files with 66 additions and 4 deletions
|
@ -63,6 +63,7 @@
|
|||
this.trainerID1 = new PKHeX.WinForms.Controls.TrainerID();
|
||||
this.GB_Adventure = new System.Windows.Forms.GroupBox();
|
||||
this.Tab_Complex = new System.Windows.Forms.TabPage();
|
||||
this.B_ExportGoFiles = new System.Windows.Forms.Button();
|
||||
this.L_GoSlotSummary = new System.Windows.Forms.Label();
|
||||
this.B_Import = new System.Windows.Forms.Button();
|
||||
this.B_Export = new System.Windows.Forms.Button();
|
||||
|
@ -389,6 +390,8 @@
|
|||
//
|
||||
// Tab_Complex
|
||||
//
|
||||
this.Tab_Complex.AllowDrop = true;
|
||||
this.Tab_Complex.Controls.Add(this.B_ExportGoFiles);
|
||||
this.Tab_Complex.Controls.Add(this.L_GoSlotSummary);
|
||||
this.Tab_Complex.Controls.Add(this.B_Import);
|
||||
this.Tab_Complex.Controls.Add(this.B_Export);
|
||||
|
@ -402,6 +405,18 @@
|
|||
this.Tab_Complex.TabIndex = 4;
|
||||
this.Tab_Complex.Text = "Go Complex";
|
||||
this.Tab_Complex.UseVisualStyleBackColor = true;
|
||||
this.Tab_Complex.DragDrop += new System.Windows.Forms.DragEventHandler(this.Main_DragDrop);
|
||||
this.Tab_Complex.DragEnter += new System.Windows.Forms.DragEventHandler(this.Main_DragEnter);
|
||||
//
|
||||
// B_ExportGoFiles
|
||||
//
|
||||
this.B_ExportGoFiles.Location = new System.Drawing.Point(6, 75);
|
||||
this.B_ExportGoFiles.Name = "B_ExportGoFiles";
|
||||
this.B_ExportGoFiles.Size = new System.Drawing.Size(131, 63);
|
||||
this.B_ExportGoFiles.TabIndex = 6;
|
||||
this.B_ExportGoFiles.Text = "Dump Individual Files of Go Park Entities";
|
||||
this.B_ExportGoFiles.UseVisualStyleBackColor = true;
|
||||
this.B_ExportGoFiles.Click += new System.EventHandler(this.B_ExportGoFiles_Click);
|
||||
//
|
||||
// L_GoSlotSummary
|
||||
//
|
||||
|
@ -460,12 +475,13 @@
|
|||
this.B_ExportGoSummary.Name = "B_ExportGoSummary";
|
||||
this.B_ExportGoSummary.Size = new System.Drawing.Size(131, 63);
|
||||
this.B_ExportGoSummary.TabIndex = 0;
|
||||
this.B_ExportGoSummary.Text = "Dump Summary of Go Park Entities";
|
||||
this.B_ExportGoSummary.Text = "Dump Text Summary of Go Park Entities";
|
||||
this.B_ExportGoSummary.UseVisualStyleBackColor = true;
|
||||
this.B_ExportGoSummary.Click += new System.EventHandler(this.B_ExportGoSummary_Click);
|
||||
//
|
||||
// SAV_Trainer7GG
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(414, 366);
|
||||
|
@ -479,6 +495,8 @@
|
|||
this.Name = "SAV_Trainer7GG";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Trainer Data Editor";
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Main_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Main_DragEnter);
|
||||
this.TC_Editor.ResumeLayout(false);
|
||||
this.Tab_Overview.ResumeLayout(false);
|
||||
this.Tab_Overview.PerformLayout();
|
||||
|
@ -532,5 +550,6 @@
|
|||
private System.Windows.Forms.Button B_Import;
|
||||
private System.Windows.Forms.Button B_Export;
|
||||
private System.Windows.Forms.Label L_GoSlotSummary;
|
||||
private System.Windows.Forms.Button B_ExportGoFiles;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,8 @@ namespace PKHeX.WinForms
|
|||
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
||||
SAV = (SAV7b)(Origin = sav).Clone();
|
||||
Park = new GoParkStorage(SAV);
|
||||
UpdateGoSummary(0);
|
||||
|
||||
if (Main.Unicode)
|
||||
{
|
||||
try { TB_OTName.Font = TB_RivalName.Font = FontUtil.GetPKXFont(11); }
|
||||
|
@ -28,7 +30,24 @@ namespace PKHeX.WinForms
|
|||
|
||||
GetComboBoxes();
|
||||
LoadTrainerInfo();
|
||||
}
|
||||
|
||||
// Drag & Drop Events
|
||||
private void Main_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.AllowedEffect == (DragDropEffects.Copy | DragDropEffects.Link)) // external file
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
else if (e.Data != null) // within
|
||||
e.Effect = DragDropEffects.Move;
|
||||
}
|
||||
|
||||
private void Main_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
if (files == null || files.Length == 0)
|
||||
return;
|
||||
ImportGP1From(files[0]);
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
private void GetComboBoxes()
|
||||
|
@ -125,10 +144,26 @@ namespace PKHeX.WinForms
|
|||
System.Media.SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
||||
private void B_ExportGoFiles_Click(object sender, EventArgs e)
|
||||
{
|
||||
var gofiles = Park.AllEntities.Where(z => z.Species != 0).ToArray();
|
||||
if (gofiles.Length == 0)
|
||||
{
|
||||
WinFormsUtil.Alert("No entities present in Go Park to dump.");
|
||||
return;
|
||||
}
|
||||
var fbd = new FolderBrowserDialog();
|
||||
if (fbd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var folder = fbd.SelectedPath;
|
||||
foreach (var gpk in gofiles)
|
||||
File.WriteAllBytes(Path.Combine(folder, gpk.FileName), gpk.Data);
|
||||
WinFormsUtil.Alert($"Dumped {gofiles.Length} files to {folder}");
|
||||
}
|
||||
|
||||
private void B_Import_Click(object sender, EventArgs e)
|
||||
{
|
||||
int index = (int)NUD_GoIndex.Value;
|
||||
index = Math.Min(GoParkStorage.Count - 1, Math.Max(0, index));
|
||||
|
||||
var sfd = new OpenFileDialog
|
||||
{
|
||||
|
@ -141,13 +176,21 @@ namespace PKHeX.WinForms
|
|||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var data = File.ReadAllBytes(sfd.FileName);
|
||||
string path = sfd.FileName;
|
||||
ImportGP1From(path);
|
||||
}
|
||||
|
||||
private void ImportGP1From(string path)
|
||||
{
|
||||
var data = File.ReadAllBytes(path);
|
||||
if (data.Length != GP1.SIZE)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgFileLoadIncompatible);
|
||||
return;
|
||||
}
|
||||
|
||||
int index = (int)NUD_GoIndex.Value;
|
||||
index = Math.Min(GoParkStorage.Count - 1, Math.Max(0, index));
|
||||
var gp1 = new GP1();
|
||||
data.CopyTo(gp1.Data);
|
||||
Park[index] = gp1;
|
||||
|
|
Loading…
Reference in a new issue