Add block dump/import

Can do block swaps with other saves (fashion block is d224f9ac) -- export the block and import it to another save!
This commit is contained in:
Kurt 2020-01-13 19:04:21 -08:00
parent a6aabcdc96
commit df1d317861
5 changed files with 741 additions and 1 deletions

View file

@ -92,6 +92,7 @@
this.TB_GameSync = new System.Windows.Forms.TextBox();
this.B_SaveBoxBin = new System.Windows.Forms.Button();
this.B_VerifyCHK = new System.Windows.Forms.Button();
this.B_Blocks = new System.Windows.Forms.Button();
this.tabBoxMulti.SuspendLayout();
this.Tab_Box.SuspendLayout();
this.Tab_PartyBattle.SuspendLayout();
@ -401,6 +402,7 @@
this.FLP_SAVtools.Controls.Add(this.B_MailBox);
this.FLP_SAVtools.Controls.Add(this.B_OpenApricorn);
this.FLP_SAVtools.Controls.Add(this.B_Raids);
this.FLP_SAVtools.Controls.Add(this.B_Blocks);
this.FLP_SAVtools.Dock = System.Windows.Forms.DockStyle.Fill;
this.FLP_SAVtools.Location = new System.Drawing.Point(3, 16);
this.FLP_SAVtools.Name = "FLP_SAVtools";
@ -793,6 +795,16 @@
this.B_VerifyCHK.UseVisualStyleBackColor = true;
this.B_VerifyCHK.Click += new System.EventHandler(this.ClickVerifyCHK);
//
// B_Blocks
//
this.B_Blocks.Location = new System.Drawing.Point(3, 206);
this.B_Blocks.Name = "B_Blocks";
this.B_Blocks.Size = new System.Drawing.Size(87, 23);
this.B_Blocks.TabIndex = 35;
this.B_Blocks.Text = "Block Data";
this.B_Blocks.UseVisualStyleBackColor = true;
this.B_Blocks.Click += new System.EventHandler(this.B_Blocks_Click);
//
// SAVEditor
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@ -881,5 +893,6 @@
private SlotList SL_Extra;
private PartyEditor SL_Party;
private System.Windows.Forms.Button B_Raids;
private System.Windows.Forms.Button B_Blocks;
}
}

View file

@ -616,6 +616,14 @@ namespace PKHeX.WinForms.Controls
form.ShowDialog();
}
private void B_Blocks_Click(object sender, EventArgs e)
{
if (!(SAV is SAV8SWSH swsh))
return;
using var form = new SAV_BlockDump8(swsh);
form.ShowDialog();
}
private void B_OpenOPowers_Click(object sender, EventArgs e)
{
if (!(SAV is IOPower op))
@ -1095,7 +1103,7 @@ namespace PKHeX.WinForms.Controls
B_OpenRTCEditor.Enabled = sav.Generation == 2 || (sav is SAV3 s3 && (s3.RS || s3.E));
B_MailBox.Enabled = sav is SAV2 || sav is SAV3 || sav is SAV4 || sav is SAV5;
B_Raids.Enabled = sav is SAV8SWSH;
B_Raids.Enabled = B_Blocks.Enabled = sav is SAV8SWSH;
SL_Extra.SAV = sav;
SL_Extra.Initialize(sav.GetExtraSlots(HaX), InitializeDragDrop);

View file

@ -70,6 +70,9 @@
<Compile Update="Subforms\PKM Editors\TechRecordEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\Save Editors\Gen8\SAV_BlockDump8.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Subforms\Save Editors\Gen8\SAV_Trainer8.cs">
<SubType>Form</SubType>
</Compile>

View file

@ -0,0 +1,563 @@
namespace PKHeX.WinForms
{
partial class SAV_BlockDump8
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.L_Saying5 = new System.Windows.Forms.Label();
this.L_Saying4 = new System.Windows.Forms.Label();
this.L_Saying3 = new System.Windows.Forms.Label();
this.L_Saying2 = new System.Windows.Forms.Label();
this.L_Saying1 = new System.Windows.Forms.Label();
this.TB_Saying5 = new System.Windows.Forms.TextBox();
this.TB_Saying4 = new System.Windows.Forms.TextBox();
this.TB_Saying3 = new System.Windows.Forms.TextBox();
this.TB_Saying2 = new System.Windows.Forms.TextBox();
this.TB_Saying1 = new System.Windows.Forms.TextBox();
this.TB_MBMS = new System.Windows.Forms.MaskedTextBox();
this.TB_MBMN = new System.Windows.Forms.MaskedTextBox();
this.TB_MBRS = new System.Windows.Forms.MaskedTextBox();
this.TB_MBRN = new System.Windows.Forms.MaskedTextBox();
this.TB_MBTS = new System.Windows.Forms.MaskedTextBox();
this.TB_MBTN = new System.Windows.Forms.MaskedTextBox();
this.TB_MBDS = new System.Windows.Forms.MaskedTextBox();
this.TB_MBDN = new System.Windows.Forms.MaskedTextBox();
this.TB_MBSS = new System.Windows.Forms.MaskedTextBox();
this.TB_MBSN = new System.Windows.Forms.MaskedTextBox();
this.L_SuperB = new System.Windows.Forms.Label();
this.L_NormalB = new System.Windows.Forms.Label();
this.L_MultiB = new System.Windows.Forms.Label();
this.L_RotationB = new System.Windows.Forms.Label();
this.L_TriplesB = new System.Windows.Forms.Label();
this.L_DoublesB = new System.Windows.Forms.Label();
this.L_SinglesB = new System.Windows.Forms.Label();
this.TB_MCMS = new System.Windows.Forms.MaskedTextBox();
this.TB_MCMN = new System.Windows.Forms.MaskedTextBox();
this.TB_MCRS = new System.Windows.Forms.MaskedTextBox();
this.TB_MCRN = new System.Windows.Forms.MaskedTextBox();
this.TB_MCTS = new System.Windows.Forms.MaskedTextBox();
this.TB_MCTN = new System.Windows.Forms.MaskedTextBox();
this.TB_MCDS = new System.Windows.Forms.MaskedTextBox();
this.TB_MCDN = new System.Windows.Forms.MaskedTextBox();
this.TB_MCSS = new System.Windows.Forms.MaskedTextBox();
this.TB_MCSN = new System.Windows.Forms.MaskedTextBox();
this.L_SuperC = new System.Windows.Forms.Label();
this.L_NormalC = new System.Windows.Forms.Label();
this.L_MultiC = new System.Windows.Forms.Label();
this.L_RotationC = new System.Windows.Forms.Label();
this.L_TriplesC = new System.Windows.Forms.Label();
this.L_DoublesC = new System.Windows.Forms.Label();
this.L_SinglesC = new System.Windows.Forms.Label();
this.CB_Key = new System.Windows.Forms.ComboBox();
this.L_Key = new System.Windows.Forms.Label();
this.L_Detail_L = new System.Windows.Forms.Label();
this.L_Detail_R = new System.Windows.Forms.Label();
this.B_ExportAll = new System.Windows.Forms.Button();
this.B_ExportAllSingle = new System.Windows.Forms.Button();
this.B_ImportCurrent = new System.Windows.Forms.Button();
this.B_ExportCurrent = new System.Windows.Forms.Button();
this.B_ImportFolder = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// L_Saying5
//
this.L_Saying5.Location = new System.Drawing.Point(0, 0);
this.L_Saying5.Name = "L_Saying5";
this.L_Saying5.Size = new System.Drawing.Size(100, 23);
this.L_Saying5.TabIndex = 0;
//
// L_Saying4
//
this.L_Saying4.Location = new System.Drawing.Point(0, 0);
this.L_Saying4.Name = "L_Saying4";
this.L_Saying4.Size = new System.Drawing.Size(100, 23);
this.L_Saying4.TabIndex = 0;
//
// L_Saying3
//
this.L_Saying3.Location = new System.Drawing.Point(0, 0);
this.L_Saying3.Name = "L_Saying3";
this.L_Saying3.Size = new System.Drawing.Size(100, 23);
this.L_Saying3.TabIndex = 0;
//
// L_Saying2
//
this.L_Saying2.Location = new System.Drawing.Point(0, 0);
this.L_Saying2.Name = "L_Saying2";
this.L_Saying2.Size = new System.Drawing.Size(100, 23);
this.L_Saying2.TabIndex = 0;
//
// L_Saying1
//
this.L_Saying1.Location = new System.Drawing.Point(0, 0);
this.L_Saying1.Name = "L_Saying1";
this.L_Saying1.Size = new System.Drawing.Size(100, 23);
this.L_Saying1.TabIndex = 0;
//
// TB_Saying5
//
this.TB_Saying5.Location = new System.Drawing.Point(0, 0);
this.TB_Saying5.Name = "TB_Saying5";
this.TB_Saying5.Size = new System.Drawing.Size(100, 20);
this.TB_Saying5.TabIndex = 0;
//
// TB_Saying4
//
this.TB_Saying4.Location = new System.Drawing.Point(0, 0);
this.TB_Saying4.Name = "TB_Saying4";
this.TB_Saying4.Size = new System.Drawing.Size(100, 20);
this.TB_Saying4.TabIndex = 0;
//
// TB_Saying3
//
this.TB_Saying3.Location = new System.Drawing.Point(0, 0);
this.TB_Saying3.Name = "TB_Saying3";
this.TB_Saying3.Size = new System.Drawing.Size(100, 20);
this.TB_Saying3.TabIndex = 0;
//
// TB_Saying2
//
this.TB_Saying2.Location = new System.Drawing.Point(0, 0);
this.TB_Saying2.Name = "TB_Saying2";
this.TB_Saying2.Size = new System.Drawing.Size(100, 20);
this.TB_Saying2.TabIndex = 0;
//
// TB_Saying1
//
this.TB_Saying1.Location = new System.Drawing.Point(0, 0);
this.TB_Saying1.Name = "TB_Saying1";
this.TB_Saying1.Size = new System.Drawing.Size(100, 20);
this.TB_Saying1.TabIndex = 0;
//
// TB_MBMS
//
this.TB_MBMS.Location = new System.Drawing.Point(0, 0);
this.TB_MBMS.Name = "TB_MBMS";
this.TB_MBMS.Size = new System.Drawing.Size(100, 20);
this.TB_MBMS.TabIndex = 0;
//
// TB_MBMN
//
this.TB_MBMN.Location = new System.Drawing.Point(0, 0);
this.TB_MBMN.Name = "TB_MBMN";
this.TB_MBMN.Size = new System.Drawing.Size(100, 20);
this.TB_MBMN.TabIndex = 0;
//
// TB_MBRS
//
this.TB_MBRS.Location = new System.Drawing.Point(0, 0);
this.TB_MBRS.Name = "TB_MBRS";
this.TB_MBRS.Size = new System.Drawing.Size(100, 20);
this.TB_MBRS.TabIndex = 0;
//
// TB_MBRN
//
this.TB_MBRN.Location = new System.Drawing.Point(0, 0);
this.TB_MBRN.Name = "TB_MBRN";
this.TB_MBRN.Size = new System.Drawing.Size(100, 20);
this.TB_MBRN.TabIndex = 0;
//
// TB_MBTS
//
this.TB_MBTS.Location = new System.Drawing.Point(0, 0);
this.TB_MBTS.Name = "TB_MBTS";
this.TB_MBTS.Size = new System.Drawing.Size(100, 20);
this.TB_MBTS.TabIndex = 0;
//
// TB_MBTN
//
this.TB_MBTN.Location = new System.Drawing.Point(0, 0);
this.TB_MBTN.Name = "TB_MBTN";
this.TB_MBTN.Size = new System.Drawing.Size(100, 20);
this.TB_MBTN.TabIndex = 0;
//
// TB_MBDS
//
this.TB_MBDS.Location = new System.Drawing.Point(0, 0);
this.TB_MBDS.Name = "TB_MBDS";
this.TB_MBDS.Size = new System.Drawing.Size(100, 20);
this.TB_MBDS.TabIndex = 0;
//
// TB_MBDN
//
this.TB_MBDN.Location = new System.Drawing.Point(0, 0);
this.TB_MBDN.Name = "TB_MBDN";
this.TB_MBDN.Size = new System.Drawing.Size(100, 20);
this.TB_MBDN.TabIndex = 0;
//
// TB_MBSS
//
this.TB_MBSS.Location = new System.Drawing.Point(0, 0);
this.TB_MBSS.Name = "TB_MBSS";
this.TB_MBSS.Size = new System.Drawing.Size(100, 20);
this.TB_MBSS.TabIndex = 0;
//
// TB_MBSN
//
this.TB_MBSN.Location = new System.Drawing.Point(0, 0);
this.TB_MBSN.Name = "TB_MBSN";
this.TB_MBSN.Size = new System.Drawing.Size(100, 20);
this.TB_MBSN.TabIndex = 0;
//
// L_SuperB
//
this.L_SuperB.Location = new System.Drawing.Point(0, 0);
this.L_SuperB.Name = "L_SuperB";
this.L_SuperB.Size = new System.Drawing.Size(100, 23);
this.L_SuperB.TabIndex = 0;
//
// L_NormalB
//
this.L_NormalB.Location = new System.Drawing.Point(0, 0);
this.L_NormalB.Name = "L_NormalB";
this.L_NormalB.Size = new System.Drawing.Size(100, 23);
this.L_NormalB.TabIndex = 0;
//
// L_MultiB
//
this.L_MultiB.Location = new System.Drawing.Point(0, 0);
this.L_MultiB.Name = "L_MultiB";
this.L_MultiB.Size = new System.Drawing.Size(100, 23);
this.L_MultiB.TabIndex = 0;
//
// L_RotationB
//
this.L_RotationB.Location = new System.Drawing.Point(0, 0);
this.L_RotationB.Name = "L_RotationB";
this.L_RotationB.Size = new System.Drawing.Size(100, 23);
this.L_RotationB.TabIndex = 0;
//
// L_TriplesB
//
this.L_TriplesB.Location = new System.Drawing.Point(0, 0);
this.L_TriplesB.Name = "L_TriplesB";
this.L_TriplesB.Size = new System.Drawing.Size(100, 23);
this.L_TriplesB.TabIndex = 0;
//
// L_DoublesB
//
this.L_DoublesB.Location = new System.Drawing.Point(0, 0);
this.L_DoublesB.Name = "L_DoublesB";
this.L_DoublesB.Size = new System.Drawing.Size(100, 23);
this.L_DoublesB.TabIndex = 0;
//
// L_SinglesB
//
this.L_SinglesB.Location = new System.Drawing.Point(0, 0);
this.L_SinglesB.Name = "L_SinglesB";
this.L_SinglesB.Size = new System.Drawing.Size(100, 23);
this.L_SinglesB.TabIndex = 0;
//
// TB_MCMS
//
this.TB_MCMS.Location = new System.Drawing.Point(0, 0);
this.TB_MCMS.Name = "TB_MCMS";
this.TB_MCMS.Size = new System.Drawing.Size(100, 20);
this.TB_MCMS.TabIndex = 0;
//
// TB_MCMN
//
this.TB_MCMN.Location = new System.Drawing.Point(0, 0);
this.TB_MCMN.Name = "TB_MCMN";
this.TB_MCMN.Size = new System.Drawing.Size(100, 20);
this.TB_MCMN.TabIndex = 0;
//
// TB_MCRS
//
this.TB_MCRS.Location = new System.Drawing.Point(0, 0);
this.TB_MCRS.Name = "TB_MCRS";
this.TB_MCRS.Size = new System.Drawing.Size(100, 20);
this.TB_MCRS.TabIndex = 0;
//
// TB_MCRN
//
this.TB_MCRN.Location = new System.Drawing.Point(0, 0);
this.TB_MCRN.Name = "TB_MCRN";
this.TB_MCRN.Size = new System.Drawing.Size(100, 20);
this.TB_MCRN.TabIndex = 0;
//
// TB_MCTS
//
this.TB_MCTS.Location = new System.Drawing.Point(0, 0);
this.TB_MCTS.Name = "TB_MCTS";
this.TB_MCTS.Size = new System.Drawing.Size(100, 20);
this.TB_MCTS.TabIndex = 0;
//
// TB_MCTN
//
this.TB_MCTN.Location = new System.Drawing.Point(0, 0);
this.TB_MCTN.Name = "TB_MCTN";
this.TB_MCTN.Size = new System.Drawing.Size(100, 20);
this.TB_MCTN.TabIndex = 0;
//
// TB_MCDS
//
this.TB_MCDS.Location = new System.Drawing.Point(0, 0);
this.TB_MCDS.Name = "TB_MCDS";
this.TB_MCDS.Size = new System.Drawing.Size(100, 20);
this.TB_MCDS.TabIndex = 0;
//
// TB_MCDN
//
this.TB_MCDN.Location = new System.Drawing.Point(0, 0);
this.TB_MCDN.Name = "TB_MCDN";
this.TB_MCDN.Size = new System.Drawing.Size(100, 20);
this.TB_MCDN.TabIndex = 0;
//
// TB_MCSS
//
this.TB_MCSS.Location = new System.Drawing.Point(0, 0);
this.TB_MCSS.Name = "TB_MCSS";
this.TB_MCSS.Size = new System.Drawing.Size(100, 20);
this.TB_MCSS.TabIndex = 0;
//
// TB_MCSN
//
this.TB_MCSN.Location = new System.Drawing.Point(0, 0);
this.TB_MCSN.Name = "TB_MCSN";
this.TB_MCSN.Size = new System.Drawing.Size(100, 20);
this.TB_MCSN.TabIndex = 0;
//
// L_SuperC
//
this.L_SuperC.Location = new System.Drawing.Point(0, 0);
this.L_SuperC.Name = "L_SuperC";
this.L_SuperC.Size = new System.Drawing.Size(100, 23);
this.L_SuperC.TabIndex = 0;
//
// L_NormalC
//
this.L_NormalC.Location = new System.Drawing.Point(0, 0);
this.L_NormalC.Name = "L_NormalC";
this.L_NormalC.Size = new System.Drawing.Size(100, 23);
this.L_NormalC.TabIndex = 0;
//
// L_MultiC
//
this.L_MultiC.Location = new System.Drawing.Point(0, 0);
this.L_MultiC.Name = "L_MultiC";
this.L_MultiC.Size = new System.Drawing.Size(100, 23);
this.L_MultiC.TabIndex = 0;
//
// L_RotationC
//
this.L_RotationC.Location = new System.Drawing.Point(0, 0);
this.L_RotationC.Name = "L_RotationC";
this.L_RotationC.Size = new System.Drawing.Size(100, 23);
this.L_RotationC.TabIndex = 0;
//
// L_TriplesC
//
this.L_TriplesC.Location = new System.Drawing.Point(0, 0);
this.L_TriplesC.Name = "L_TriplesC";
this.L_TriplesC.Size = new System.Drawing.Size(100, 23);
this.L_TriplesC.TabIndex = 0;
//
// L_DoublesC
//
this.L_DoublesC.Location = new System.Drawing.Point(0, 0);
this.L_DoublesC.Name = "L_DoublesC";
this.L_DoublesC.Size = new System.Drawing.Size(100, 23);
this.L_DoublesC.TabIndex = 0;
//
// L_SinglesC
//
this.L_SinglesC.Location = new System.Drawing.Point(0, 0);
this.L_SinglesC.Name = "L_SinglesC";
this.L_SinglesC.Size = new System.Drawing.Size(100, 23);
this.L_SinglesC.TabIndex = 0;
//
// CB_Key
//
this.CB_Key.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
this.CB_Key.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
this.CB_Key.FormattingEnabled = true;
this.CB_Key.Location = new System.Drawing.Point(89, 12);
this.CB_Key.Name = "CB_Key";
this.CB_Key.Size = new System.Drawing.Size(121, 21);
this.CB_Key.TabIndex = 0;
this.CB_Key.SelectedIndexChanged += new System.EventHandler(this.CB_Key_SelectedIndexChanged);
//
// L_Key
//
this.L_Key.AutoSize = true;
this.L_Key.Location = new System.Drawing.Point(12, 15);
this.L_Key.Name = "L_Key";
this.L_Key.Size = new System.Drawing.Size(58, 13);
this.L_Key.TabIndex = 1;
this.L_Key.Text = "Block Key:";
//
// L_Detail_L
//
this.L_Detail_L.AutoSize = true;
this.L_Detail_L.Location = new System.Drawing.Point(12, 64);
this.L_Detail_L.Name = "L_Detail_L";
this.L_Detail_L.Size = new System.Drawing.Size(67, 13);
this.L_Detail_L.TabIndex = 2;
this.L_Detail_L.Text = "Block Detail:";
//
// L_Detail_R
//
this.L_Detail_R.AutoSize = true;
this.L_Detail_R.Location = new System.Drawing.Point(86, 64);
this.L_Detail_R.Name = "L_Detail_R";
this.L_Detail_R.Size = new System.Drawing.Size(69, 13);
this.L_Detail_R.TabIndex = 3;
this.L_Detail_R.Text = "Block Details";
//
// B_ExportAll
//
this.B_ExportAll.Location = new System.Drawing.Point(109, 143);
this.B_ExportAll.Name = "B_ExportAll";
this.B_ExportAll.Size = new System.Drawing.Size(91, 50);
this.B_ExportAll.TabIndex = 4;
this.B_ExportAll.Text = "Export Blocks To Folder";
this.B_ExportAll.UseVisualStyleBackColor = true;
this.B_ExportAll.Click += new System.EventHandler(this.B_ExportAll_Click);
//
// B_ExportAllSingle
//
this.B_ExportAllSingle.Location = new System.Drawing.Point(206, 143);
this.B_ExportAllSingle.Name = "B_ExportAllSingle";
this.B_ExportAllSingle.Size = new System.Drawing.Size(91, 50);
this.B_ExportAllSingle.TabIndex = 5;
this.B_ExportAllSingle.Text = "Export All (Single File)";
this.B_ExportAllSingle.UseVisualStyleBackColor = true;
this.B_ExportAllSingle.Click += new System.EventHandler(this.B_ExportAllSingle_Click);
//
// B_ImportCurrent
//
this.B_ImportCurrent.Location = new System.Drawing.Point(12, 199);
this.B_ImportCurrent.Name = "B_ImportCurrent";
this.B_ImportCurrent.Size = new System.Drawing.Size(91, 50);
this.B_ImportCurrent.TabIndex = 7;
this.B_ImportCurrent.Text = "Import Current Block";
this.B_ImportCurrent.UseVisualStyleBackColor = true;
this.B_ImportCurrent.Click += new System.EventHandler(this.B_ImportCurrent_Click);
//
// B_ExportCurrent
//
this.B_ExportCurrent.Location = new System.Drawing.Point(109, 199);
this.B_ExportCurrent.Name = "B_ExportCurrent";
this.B_ExportCurrent.Size = new System.Drawing.Size(91, 50);
this.B_ExportCurrent.TabIndex = 6;
this.B_ExportCurrent.Text = "Export Current Block";
this.B_ExportCurrent.UseVisualStyleBackColor = true;
this.B_ExportCurrent.Click += new System.EventHandler(this.B_ExportCurrent_Click);
//
// B_ImportFolder
//
this.B_ImportFolder.Location = new System.Drawing.Point(12, 143);
this.B_ImportFolder.Name = "B_ImportFolder";
this.B_ImportFolder.Size = new System.Drawing.Size(91, 50);
this.B_ImportFolder.TabIndex = 8;
this.B_ImportFolder.Text = "Import Blocks From Folder";
this.B_ImportFolder.UseVisualStyleBackColor = true;
this.B_ImportFolder.Click += new System.EventHandler(this.B_ImportFolder_Click);
//
// SAV_BlockDump8
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(306, 261);
this.Controls.Add(this.B_ImportFolder);
this.Controls.Add(this.B_ImportCurrent);
this.Controls.Add(this.B_ExportCurrent);
this.Controls.Add(this.B_ExportAllSingle);
this.Controls.Add(this.B_ExportAll);
this.Controls.Add(this.L_Detail_R);
this.Controls.Add(this.L_Detail_L);
this.Controls.Add(this.L_Key);
this.Controls.Add(this.CB_Key);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::PKHeX.WinForms.Properties.Resources.Icon;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SAV_BlockDump8";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Savedata Block Dump";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label L_Saying5;
private System.Windows.Forms.Label L_Saying4;
private System.Windows.Forms.Label L_Saying3;
private System.Windows.Forms.Label L_Saying2;
private System.Windows.Forms.Label L_Saying1;
private System.Windows.Forms.TextBox TB_Saying5;
private System.Windows.Forms.TextBox TB_Saying4;
private System.Windows.Forms.TextBox TB_Saying3;
private System.Windows.Forms.TextBox TB_Saying2;
private System.Windows.Forms.TextBox TB_Saying1;
private System.Windows.Forms.Label L_SuperB;
private System.Windows.Forms.Label L_NormalB;
private System.Windows.Forms.Label L_MultiB;
private System.Windows.Forms.Label L_RotationB;
private System.Windows.Forms.Label L_TriplesB;
private System.Windows.Forms.Label L_DoublesB;
private System.Windows.Forms.Label L_SinglesB;
private System.Windows.Forms.Label L_SuperC;
private System.Windows.Forms.Label L_NormalC;
private System.Windows.Forms.Label L_MultiC;
private System.Windows.Forms.Label L_RotationC;
private System.Windows.Forms.Label L_TriplesC;
private System.Windows.Forms.Label L_DoublesC;
private System.Windows.Forms.Label L_SinglesC;
private System.Windows.Forms.MaskedTextBox TB_MBMS;
private System.Windows.Forms.MaskedTextBox TB_MBMN;
private System.Windows.Forms.MaskedTextBox TB_MBRS;
private System.Windows.Forms.MaskedTextBox TB_MBRN;
private System.Windows.Forms.MaskedTextBox TB_MBTS;
private System.Windows.Forms.MaskedTextBox TB_MBTN;
private System.Windows.Forms.MaskedTextBox TB_MBDS;
private System.Windows.Forms.MaskedTextBox TB_MBDN;
private System.Windows.Forms.MaskedTextBox TB_MBSS;
private System.Windows.Forms.MaskedTextBox TB_MBSN;
private System.Windows.Forms.MaskedTextBox TB_MCMS;
private System.Windows.Forms.MaskedTextBox TB_MCMN;
private System.Windows.Forms.MaskedTextBox TB_MCRS;
private System.Windows.Forms.MaskedTextBox TB_MCRN;
private System.Windows.Forms.MaskedTextBox TB_MCTS;
private System.Windows.Forms.MaskedTextBox TB_MCTN;
private System.Windows.Forms.MaskedTextBox TB_MCDS;
private System.Windows.Forms.MaskedTextBox TB_MCDN;
private System.Windows.Forms.MaskedTextBox TB_MCSS;
private System.Windows.Forms.MaskedTextBox TB_MCSN;
private System.Windows.Forms.ComboBox CB_Key;
private System.Windows.Forms.Label L_Key;
private System.Windows.Forms.Label L_Detail_L;
private System.Windows.Forms.Label L_Detail_R;
private System.Windows.Forms.Button B_ExportAll;
private System.Windows.Forms.Button B_ExportAllSingle;
private System.Windows.Forms.Button B_ImportCurrent;
private System.Windows.Forms.Button B_ExportCurrent;
private System.Windows.Forms.Button B_ImportFolder;
}
}

View file

@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PKHeX.Core;
namespace PKHeX.WinForms
{
public partial class SAV_BlockDump8 : Form
{
private readonly SAV8SWSH SAV;
private SCBlock CurrentBlock;
public SAV_BlockDump8(SaveFile sav)
{
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
SAV = (SAV8SWSH)sav;
var blocks = SAV.AllBlocks.Select((z, i) => new ComboItem($"{z.Key:X8} - {i:0000}", (int)z.Key));
CB_Key.InitializeBinding();
CB_Key.DataSource = blocks.ToArray();
}
private void CB_Key_SelectedIndexChanged(object sender, EventArgs e)
{
var key = (uint)WinFormsUtil.GetIndex(CB_Key);
CurrentBlock = SAV.Blocks.GetBlock(key);
L_Detail_R.Text = GetBlockSummary(CurrentBlock);
}
private void B_ExportAll_Click(object sender, EventArgs e)
{
using var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() != DialogResult.OK)
return;
var path = fbd.SelectedPath;
var blocks = SAV.AllBlocks;
ExportAllBlocks(blocks, path);
}
private static void ExportAllBlocks(IEnumerable<SCBlock> blocks, string path)
{
foreach (var b in blocks.Where(z => z.Data.Length != 0))
File.WriteAllBytes(Path.Combine(path, $"{b.Key:X8}.bin"), b.Data);
}
private void B_ImportFolder_Click(object sender, EventArgs e)
{
using var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() != DialogResult.OK)
return;
var failed = ImportBlocksFromFolder(fbd.SelectedPath, SAV);
if (failed.Count != 0)
{
var msg = string.Join(Environment.NewLine, failed);
WinFormsUtil.Error("Failed to import:", msg);
}
}
private void B_ImportCurrent_Click(object sender, EventArgs e) => ImportSelectBlock(CurrentBlock);
private void B_ExportCurrent_Click(object sender, EventArgs e) => ExportSelectBlock(CurrentBlock);
private void B_ExportAllSingle_Click(object sender, EventArgs e)
{
using var sfd = new SaveFileDialog { FileName = "raw.bin" };
if (sfd.ShowDialog() != DialogResult.OK)
return;
var blocks = SAV.Blocks.BlockInfo;
ExportAllBlocksAsSingleFile(blocks, sfd.FileName);
}
private static void ExportSelectBlock(SCBlock block)
{
var key = block.Key;
using var sfd = new SaveFileDialog {FileName = $"{key:X8}.bin"};
if (sfd.ShowDialog() != DialogResult.OK)
return;
File.WriteAllBytes(sfd.FileName, block.Data);
}
private static void ImportSelectBlock(SCBlock blockTarget)
{
var key = blockTarget.Key;
var data = blockTarget.Data;
using var ofd = new OpenFileDialog {FileName = $"{key:X8}.bin"};
if (ofd.ShowDialog() != DialogResult.OK)
return;
var path = ofd.FileName;
var file = new FileInfo(path);
if (file.Length != data.Length)
{
WinFormsUtil.Error(string.Format(MessageStrings.MsgFileSize, $"0x{file.Length:X8}"));
return;
}
var bytes = File.ReadAllBytes(path);
bytes.CopyTo(data, 0);
}
private static void ExportAllBlocksAsSingleFile(IEnumerable<SCBlock> blocks, string path)
{
var data = SwishCrypto.GetDecryptedRawData(blocks);
File.WriteAllBytes(path, data);
}
private static string GetBlockSummary(SCBlock b)
{
var sb = new StringBuilder();
sb.Append("Block Info:")
.Append("Key: ").AppendFormat("{0:X8}", b.Key).AppendLine()
.Append("Length: ").AppendFormat("{0:X8}", b.Data.Length).AppendLine()
.Append("Type: ").Append(b.Type).AppendLine()
.Append("SubType: ").Append(b.SubType).AppendLine();
return sb.ToString();
}
private static List<string> ImportBlocksFromFolder(string path, SAV8SWSH sav)
{
var failed = new List<string>();
var files = Directory.EnumerateFiles(path);
foreach (var f in files)
{
var fn = Path.GetFileNameWithoutExtension(f);
var hex = Util.GetHexValue(fn);
try
{
var block = sav.Blocks.GetBlock(hex);
var len = block.Data.Length;
var fi = new FileInfo(f);
if (fi.Length != len)
{
failed.Add(fn);
continue;
}
var data = File.ReadAllBytes(f);
data.CopyTo(block.Data, 0);
}
catch
{
failed.Add(fn);
}
}
return failed;
}
}
}