Handling improvements

call garbage collection,
prevent large file loading to keep low RAM footprint longer,
Box data clarified a little bit more
labeled O-Power with guesses
This commit is contained in:
Kurt 2014-07-26 20:21:31 -07:00
parent 9651d37404
commit eb0b417697
7 changed files with 151 additions and 55 deletions

View file

@ -265,28 +265,36 @@ namespace PKHeX
private void B_Diff_Click(object sender, EventArgs e)
{
string result = "";
RTB_Code.Clear();
byte[] cybersav = m_parent.cyberSAV;
byte[] editedsav = m_parent.savefile;
byte[] newcyber = new Byte[0x65600];
Array.Copy(editedsav, 0x5400, newcyber, 0, 0x65600);
if (!m_parent.cybergadget) Array.Copy(editedsav, m_parent.savindex * 0x7F000 + 0x5400, newcyber, 0, 0x65600);
int lines = 0;
for (int i = 0; i < 0x65400; i += 4)
{
if (BitConverter.ToUInt32(cybersav, i) != BitConverter.ToUInt32(newcyber, i))
{
RTB_Code.AppendText((0x20000000 + i).ToString("X8") + " ");
RTB_Code.AppendText(BitConverter.ToUInt32(newcyber, i).ToString("X8") + "\n");
result += ((0x20000000 + i).ToString("X8") + " ");
result += (BitConverter.ToUInt32(newcyber, i).ToString("X8") + "\n");
lines++;
if (lines % 128 == 0)
{ RTB_Code.AppendText("\r\n--- Segment " + (lines/128 + 1).ToString() + " ---\r\n\r\n"); }
{ result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); }
if (lines > 10000) goto toomany;
}
}
if (lines / 128 > 0)
{
MessageBox.Show((1+ (lines / 128)).ToString() + " Code Segments","Alert");
}
RTB_Code.Text = result; return;
toomany:
{
MessageBox.Show("Too many differences. Export your save instead.", "Alert");
}
}
}
}

View file

@ -37,9 +37,10 @@
this.L_Flags = new System.Windows.Forms.Label();
this.MT_BG1 = new System.Windows.Forms.MaskedTextBox();
this.MT_BG2 = new System.Windows.Forms.MaskedTextBox();
this.MT_BG3 = new System.Windows.Forms.MaskedTextBox();
this.B_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.CB_Unlocked = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// LB_BoxSelect
@ -79,7 +80,7 @@
"Box 31"});
this.LB_BoxSelect.Location = new System.Drawing.Point(12, 14);
this.LB_BoxSelect.Name = "LB_BoxSelect";
this.LB_BoxSelect.Size = new System.Drawing.Size(78, 134);
this.LB_BoxSelect.Size = new System.Drawing.Size(78, 212);
this.LB_BoxSelect.TabIndex = 0;
this.LB_BoxSelect.SelectedIndexChanged += new System.EventHandler(this.changeBox);
//
@ -124,7 +125,7 @@
// L_Flags
//
this.L_Flags.AutoSize = true;
this.L_Flags.Location = new System.Drawing.Point(104, 82);
this.L_Flags.Location = new System.Drawing.Point(103, 112);
this.L_Flags.Name = "L_Flags";
this.L_Flags.Size = new System.Drawing.Size(102, 13);
this.L_Flags.TabIndex = 5;
@ -132,7 +133,7 @@
//
// MT_BG1
//
this.MT_BG1.Location = new System.Drawing.Point(106, 98);
this.MT_BG1.Location = new System.Drawing.Point(117, 128);
this.MT_BG1.Mask = "00";
this.MT_BG1.Name = "MT_BG1";
this.MT_BG1.Size = new System.Drawing.Size(29, 20);
@ -142,7 +143,7 @@
//
// MT_BG2
//
this.MT_BG2.Location = new System.Drawing.Point(142, 98);
this.MT_BG2.Location = new System.Drawing.Point(157, 128);
this.MT_BG2.Mask = "00";
this.MT_BG2.Name = "MT_BG2";
this.MT_BG2.Size = new System.Drawing.Size(29, 20);
@ -150,19 +151,9 @@
this.MT_BG2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.MT_BG2.TextChanged += new System.EventHandler(this.changeBoxDetails);
//
// MT_BG3
//
this.MT_BG3.Location = new System.Drawing.Point(177, 98);
this.MT_BG3.Mask = "00";
this.MT_BG3.Name = "MT_BG3";
this.MT_BG3.Size = new System.Drawing.Size(29, 20);
this.MT_BG3.TabIndex = 8;
this.MT_BG3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.MT_BG3.TextChanged += new System.EventHandler(this.changeBoxDetails);
//
// B_Save
//
this.B_Save.Location = new System.Drawing.Point(157, 127);
this.B_Save.Location = new System.Drawing.Point(157, 203);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(50, 23);
this.B_Save.TabIndex = 9;
@ -172,7 +163,7 @@
//
// B_Cancel
//
this.B_Cancel.Location = new System.Drawing.Point(101, 127);
this.B_Cancel.Location = new System.Drawing.Point(96, 203);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(50, 23);
this.B_Cancel.TabIndex = 10;
@ -180,14 +171,66 @@
this.B_Cancel.UseVisualStyleBackColor = true;
this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(103, 179);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 13);
this.label1.TabIndex = 11;
this.label1.Text = "Unlocked:";
//
// CB_Unlocked
//
this.CB_Unlocked.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_Unlocked.FormattingEnabled = true;
this.CB_Unlocked.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31"});
this.CB_Unlocked.Location = new System.Drawing.Point(165, 176);
this.CB_Unlocked.Name = "CB_Unlocked";
this.CB_Unlocked.Size = new System.Drawing.Size(40, 21);
this.CB_Unlocked.TabIndex = 12;
this.CB_Unlocked.TextChanged += new System.EventHandler(this.changeBoxDetails);
//
// SAV_BoxLayout
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(219, 162);
this.ClientSize = new System.Drawing.Size(219, 239);
this.Controls.Add(this.CB_Unlocked);
this.Controls.Add(this.label1);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.MT_BG3);
this.Controls.Add(this.MT_BG2);
this.Controls.Add(this.MT_BG1);
this.Controls.Add(this.L_Flags);
@ -218,8 +261,9 @@
private System.Windows.Forms.Label L_Flags;
private System.Windows.Forms.MaskedTextBox MT_BG1;
private System.Windows.Forms.MaskedTextBox MT_BG2;
private System.Windows.Forms.MaskedTextBox MT_BG3;
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.Button B_Cancel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox CB_Unlocked;
}
}

View file

@ -15,6 +15,7 @@ namespace PKHeX
{
InitializeComponent();
m_parent = frm1;
editing = true;
Array.Copy(m_parent.savefile, sav, 0x100000);
savindex = m_parent.savindex;
LB_BoxSelect.SelectedIndex = 0;
@ -41,8 +42,10 @@ namespace PKHeX
MT_BG.Text = sav[0x9C1E + savindex * 0x7F000 + index].ToString();
MT_BG1.Text = sav[0x9C3D + savindex * 0x7F000].ToString();
MT_BG2.Text = sav[0x9C3E + savindex * 0x7F000].ToString();
MT_BG3.Text = sav[0x9C3F + savindex * 0x7F000].ToString();
MT_BG2.Text = sav[0x9C3F + savindex * 0x7F000].ToString();
CB_Unlocked.SelectedIndex = sav[0x9C3E + savindex * 0x7F000] - 1;
editing = false;
}
private void changeBoxDetails(object sender, EventArgs e)
@ -60,8 +63,9 @@ namespace PKHeX
sav[0x9C1E + savindex * 0x7F000 + index] = (byte)ToUInt32(MT_BG.Text);
sav[0x9C3D + savindex * 0x7F000] = (byte)ToUInt32(MT_BG1.Text);
sav[0x9C3E + savindex * 0x7F000] = (byte)ToUInt32(MT_BG2.Text);
sav[0x9C3F + savindex * 0x7F000] = (byte)ToUInt32(MT_BG3.Text);
sav[0x9C3F + savindex * 0x7F000] = (byte)ToUInt32(MT_BG2.Text);
sav[0x9C3E + savindex * 0x7F000] = (byte)ToUInt32(CB_Unlocked.Text);
}
}
private void B_Cancel_Click(object sender, EventArgs e)

View file

@ -117,7 +117,37 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="TB_BoxName.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_BoxName.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MT_BG.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_BG.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_Flags.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MT_BG1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="MT_BG2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_Save.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_Cancel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CB_Unlocked.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

30
SAV_OPower.Designer.cs generated
View file

@ -90,7 +90,7 @@
this.L_1.Name = "L_1";
this.L_1.Size = new System.Drawing.Size(70, 13);
this.L_1.TabIndex = 1;
this.L_1.Text = "Power 1:";
this.L_1.Text = "?Bargain:";
this.L_1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_2
@ -99,7 +99,7 @@
this.L_2.Name = "L_2";
this.L_2.Size = new System.Drawing.Size(70, 13);
this.L_2.TabIndex = 3;
this.L_2.Text = "Power 2:";
this.L_2.Text = "?EXP:";
this.L_2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_2
@ -123,7 +123,7 @@
this.L_3.Name = "L_3";
this.L_3.Size = new System.Drawing.Size(70, 13);
this.L_3.TabIndex = 5;
this.L_3.Text = "Power 3:";
this.L_3.Text = "?Prize:";
this.L_3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_3
@ -147,7 +147,7 @@
this.L_4.Name = "L_4";
this.L_4.Size = new System.Drawing.Size(70, 13);
this.L_4.TabIndex = 7;
this.L_4.Text = "Power 4:";
this.L_4.Text = "?Hatch:";
this.L_4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_4
@ -195,7 +195,7 @@
this.L_6.Name = "L_6";
this.L_6.Size = new System.Drawing.Size(70, 13);
this.L_6.TabIndex = 11;
this.L_6.Text = "Power 6:";
this.L_6.Text = "?Encounter";
this.L_6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_6
@ -218,7 +218,7 @@
this.L_7.Name = "L_7";
this.L_7.Size = new System.Drawing.Size(70, 13);
this.L_7.TabIndex = 13;
this.L_7.Text = "Power 7:";
this.L_7.Text = "?Stealth:";
this.L_7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_7
@ -264,7 +264,7 @@
this.L_17.Name = "L_17";
this.L_17.Size = new System.Drawing.Size(70, 13);
this.L_17.TabIndex = 31;
this.L_17.Text = "Power 17:";
this.L_17.Text = "?Accuracy:";
this.L_17.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_17
@ -287,7 +287,7 @@
this.L_16.Name = "L_16";
this.L_16.Size = new System.Drawing.Size(70, 13);
this.L_16.TabIndex = 29;
this.L_16.Text = "Power 16:";
this.L_16.Text = "?Critical Hit:";
this.L_16.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_16
@ -310,7 +310,7 @@
this.L_15.Name = "L_15";
this.L_15.Size = new System.Drawing.Size(70, 13);
this.L_15.TabIndex = 27;
this.L_15.Text = "Power 15:";
this.L_15.Text = "?Speed:";
this.L_15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_15
@ -333,7 +333,7 @@
this.L_14.Name = "L_14";
this.L_14.Size = new System.Drawing.Size(70, 13);
this.L_14.TabIndex = 25;
this.L_14.Text = "Power 14:";
this.L_14.Text = "?Sp. Def:";
this.L_14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_14
@ -356,7 +356,7 @@
this.L_13.Name = "L_13";
this.L_13.Size = new System.Drawing.Size(70, 13);
this.L_13.TabIndex = 23;
this.L_13.Text = "Power 13:";
this.L_13.Text = "?Sp. Atk:";
this.L_13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_13
@ -379,7 +379,7 @@
this.L_12.Name = "L_12";
this.L_12.Size = new System.Drawing.Size(70, 13);
this.L_12.TabIndex = 21;
this.L_12.Text = "Power 12:";
this.L_12.Text = "?Defense:";
this.L_12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_12
@ -402,7 +402,7 @@
this.L_11.Name = "L_11";
this.L_11.Size = new System.Drawing.Size(70, 13);
this.L_11.TabIndex = 19;
this.L_11.Text = "Power 11:";
this.L_11.Text = "?Attack:";
this.L_11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_11
@ -425,7 +425,7 @@
this.L_10.Name = "L_10";
this.L_10.Size = new System.Drawing.Size(70, 13);
this.L_10.TabIndex = 17;
this.L_10.Text = "Power 10:";
this.L_10.Text = "?Befriend:";
this.L_10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_10
@ -449,7 +449,7 @@
this.L_9.Name = "L_9";
this.L_9.Size = new System.Drawing.Size(70, 13);
this.L_9.TabIndex = 33;
this.L_9.Text = "Power 9:";
this.L_9.Text = "?PP:";
this.L_9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CB_9

16
f1-Main.Designer.cs generated
View file

@ -212,7 +212,7 @@
this.Menu_Save = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_Exit = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_Tools = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_OpenBoxUI = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_ToggleBoxUI = new System.Windows.Forms.ToolStripMenuItem();
this.Menu_BoxIO = new System.Windows.Forms.ToolStripMenuItem();
this.reportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.codeGeneratorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -2540,7 +2540,7 @@
// Menu_Tools
//
this.Menu_Tools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.Menu_OpenBoxUI,
this.Menu_ToggleBoxUI,
this.Menu_BoxIO,
this.reportToolStripMenuItem,
this.codeGeneratorToolStripMenuItem});
@ -2548,12 +2548,12 @@
this.Menu_Tools.Size = new System.Drawing.Size(48, 20);
this.Menu_Tools.Text = "Tools";
//
// Menu_OpenBoxUI
// Menu_ToggleBoxUI
//
this.Menu_OpenBoxUI.Name = "Menu_OpenBoxUI";
this.Menu_OpenBoxUI.Size = new System.Drawing.Size(182, 22);
this.Menu_OpenBoxUI.Text = "Toggle Box Interface";
this.Menu_OpenBoxUI.Click += new System.EventHandler(this.mainmenuWiden);
this.Menu_ToggleBoxUI.Name = "Menu_ToggleBoxUI";
this.Menu_ToggleBoxUI.Size = new System.Drawing.Size(182, 22);
this.Menu_ToggleBoxUI.Text = "Toggle Box Interface";
this.Menu_ToggleBoxUI.Click += new System.EventHandler(this.mainmenuWiden);
//
// Menu_BoxIO
//
@ -4184,7 +4184,7 @@
private System.Windows.Forms.ComboBox CB_EggLocation;
private System.Windows.Forms.Label Label_CharacteristicPrefix;
private System.Windows.Forms.ToolStripMenuItem Menu_Tools;
private System.Windows.Forms.ToolStripMenuItem Menu_OpenBoxUI;
private System.Windows.Forms.ToolStripMenuItem Menu_ToggleBoxUI;
private System.Windows.Forms.ToolStripMenuItem Menu_Options;
private System.Windows.Forms.ToolStripMenuItem Menu_Language;
private System.Windows.Forms.ToolStripComboBox CB_MainLanguage;

View file

@ -5940,6 +5940,11 @@ namespace PKHeX
{
string path = OpenPKX.FileName;
string ext = Path.GetExtension(path);
if (new FileInfo(path).Length > 0x10009C)
{
MessageBox.Show("Input file is too large.", "Alert"); return;
}
byte[] input = File.ReadAllBytes(path);
try
{
@ -6061,7 +6066,6 @@ namespace PKHeX
B_VerifyCHK.Enabled =
B_OUTHallofFame.Enabled = true;
B_VerifySHA.Enabled = false;
reportToolStripMenuItem.Enabled = true;
B_SwitchSAV.Enabled = false;
tabBoxMulti.Enabled = true;
C_BoxSelect.SelectedIndex = 0;
@ -6085,7 +6089,6 @@ namespace PKHeX
{
B_ExportSAV.Enabled = false;
B_SwitchSAV.Enabled = false;
reportToolStripMenuItem.Enabled = false;
B_OUTPasserby.Enabled = B_OUTHallofFame.Enabled = B_JPEG.Enabled = false;
if ((BitConverter.ToUInt32(input, 0x100) != 0x41534944) && (BitConverter.ToUInt32(input, 0x5234) != 0x6E69616D))
{
@ -6132,7 +6135,6 @@ namespace PKHeX
{
B_ExportSAV.Enabled = true;
B_SwitchSAV.Enabled = true;
reportToolStripMenuItem.Enabled = true;
savindex = detectSAVIndex(input);
opensave(input, path, ext);
}
@ -6202,6 +6204,7 @@ namespace PKHeX
MessageBox.Show(message, caption);
}
}
GC.Collect();
}
private void opensave(byte[] input, string path, string ext)
{
@ -6210,7 +6213,7 @@ namespace PKHeX
int newwidth = (this.Width * (54000 / 260)) / 100 + 2;
this.Width = newwidth;
}
Menu_OpenBoxUI.Visible = false;
Menu_ToggleBoxUI.Visible = false;
savefile = input;
savedited = false;
L_Save.Text = "SAV: " + Path.GetFileName(path);
@ -6246,6 +6249,8 @@ namespace PKHeX
B_SwitchSAV.Enabled = (hashValue1.SequenceEqual(realHash1) && hashValue2.SequenceEqual(realHash2));
getSAVOffsets();
Array.Copy(savefile, 0x5400 + 0x7F000 * savindex, cyberSAV, 0, cyberSAV.Length);
cybergadget = false;
}
private void openg5pkm()
{
@ -6936,6 +6941,11 @@ namespace PKHeX
}
string ext = Path.GetExtension(path);
FileInfo fi = new FileInfo(path);
if (fi.Length > 0x10009C)
{
MessageBox.Show("Input file is too large.", "Alert"); return;
}
byte[] input = File.ReadAllBytes(path);
try
{