diff --git a/pk3DS/Main.cs b/pk3DS/Main.cs index fb85abc..0767295 100644 --- a/pk3DS/Main.cs +++ b/pk3DS/Main.cs @@ -51,6 +51,7 @@ public Main() if (File.Exists("config.ini")) { string path = File.ReadAllText("config.ini"); + if (Directory.Exists("personal")) { Directory.Delete("personal", true); } // Clear data on form load. if (path.Length > 0) openQuick(path); } } @@ -161,6 +162,7 @@ private void openQuick(string path) else { // Check for ROMFS/EXEFS + RomFS = ExeFS = null; // Reset string[] folders = Directory.GetDirectories(path); int count = folders.Length; if (count != 2 && count != 1) return; // Only want exefs & romfs (can have exheader there too, it's not a folder) diff --git a/pk3DS/Subforms/Personal.Designer.cs b/pk3DS/Subforms/Personal.Designer.cs index fbc64c7..45e1bac 100644 --- a/pk3DS/Subforms/Personal.Designer.cs +++ b/pk3DS/Subforms/Personal.Designer.cs @@ -108,17 +108,27 @@ private void InitializeComponent() this.B_Randomize = new System.Windows.Forms.Button(); this.B_Dump = new System.Windows.Forms.Button(); this.B_Difficulty = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.CHK_TMHM = new System.Windows.Forms.CheckBox(); + this.CHK_Ability = new System.Windows.Forms.CheckBox(); + this.CHK_Stats = new System.Windows.Forms.CheckBox(); + this.NUD_StatDev = new System.Windows.Forms.NumericUpDown(); + this.L_StatDev = new System.Windows.Forms.Label(); + this.CHK_Item = new System.Windows.Forms.CheckBox(); + this.CHK_Type = new System.Windows.Forms.CheckBox(); this.TC_Pokemon.SuspendLayout(); this.TP_General.SuspendLayout(); this.TP_MoveTutors.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.PB_MonSprite)).BeginInit(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_StatDev)).BeginInit(); this.SuspendLayout(); // // L_Mode // this.L_Mode.AutoSize = true; this.L_Mode.ForeColor = System.Drawing.Color.Red; - this.L_Mode.Location = new System.Drawing.Point(400, 0); + this.L_Mode.Location = new System.Drawing.Point(371, 9); this.L_Mode.Name = "L_Mode"; this.L_Mode.Size = new System.Drawing.Size(64, 13); this.L_Mode.TabIndex = 1; @@ -147,9 +157,8 @@ private void InitializeComponent() // // TC_Pokemon // - this.TC_Pokemon.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.TC_Pokemon.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this.TC_Pokemon.Controls.Add(this.TP_General); this.TC_Pokemon.Controls.Add(this.TP_MoveTutors); this.TC_Pokemon.Location = new System.Drawing.Point(12, 40); @@ -948,7 +957,7 @@ private void InitializeComponent() // // B_Randomize // - this.B_Randomize.Location = new System.Drawing.Point(378, 35); + this.B_Randomize.Location = new System.Drawing.Point(463, 86); this.B_Randomize.Name = "B_Randomize"; this.B_Randomize.Size = new System.Drawing.Size(75, 23); this.B_Randomize.TabIndex = 417; @@ -968,7 +977,7 @@ private void InitializeComponent() // // B_Difficulty // - this.B_Difficulty.Location = new System.Drawing.Point(378, 12); + this.B_Difficulty.Location = new System.Drawing.Point(463, 62); this.B_Difficulty.Name = "B_Difficulty"; this.B_Difficulty.Size = new System.Drawing.Size(75, 23); this.B_Difficulty.TabIndex = 419; @@ -976,11 +985,110 @@ private void InitializeComponent() this.B_Difficulty.UseVisualStyleBackColor = true; this.B_Difficulty.Click += new System.EventHandler(this.B_Difficulty_Click); // + // groupBox1 + // + this.groupBox1.Controls.Add(this.CHK_Type); + this.groupBox1.Controls.Add(this.CHK_Item); + this.groupBox1.Controls.Add(this.L_StatDev); + this.groupBox1.Controls.Add(this.NUD_StatDev); + this.groupBox1.Controls.Add(this.CHK_Stats); + this.groupBox1.Controls.Add(this.CHK_Ability); + this.groupBox1.Controls.Add(this.CHK_TMHM); + this.groupBox1.Location = new System.Drawing.Point(463, 111); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(77, 290); + this.groupBox1.TabIndex = 420; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Options"; + // + // CHK_TMHM + // + this.CHK_TMHM.AutoSize = true; + this.CHK_TMHM.Checked = true; + this.CHK_TMHM.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_TMHM.Location = new System.Drawing.Point(6, 19); + this.CHK_TMHM.Name = "CHK_TMHM"; + this.CHK_TMHM.Size = new System.Drawing.Size(64, 17); + this.CHK_TMHM.TabIndex = 0; + this.CHK_TMHM.Text = "TM/HM"; + this.CHK_TMHM.UseVisualStyleBackColor = true; + // + // CHK_Ability + // + this.CHK_Ability.AutoSize = true; + this.CHK_Ability.Checked = true; + this.CHK_Ability.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_Ability.Location = new System.Drawing.Point(6, 34); + this.CHK_Ability.Name = "CHK_Ability"; + this.CHK_Ability.Size = new System.Drawing.Size(61, 17); + this.CHK_Ability.TabIndex = 1; + this.CHK_Ability.Text = "Abilities"; + this.CHK_Ability.UseVisualStyleBackColor = true; + // + // CHK_Stats + // + this.CHK_Stats.AutoSize = true; + this.CHK_Stats.Checked = true; + this.CHK_Stats.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_Stats.Location = new System.Drawing.Point(6, 97); + this.CHK_Stats.Name = "CHK_Stats"; + this.CHK_Stats.Size = new System.Drawing.Size(50, 17); + this.CHK_Stats.TabIndex = 2; + this.CHK_Stats.Text = "Stats"; + this.CHK_Stats.UseVisualStyleBackColor = true; + this.CHK_Stats.CheckedChanged += new System.EventHandler(this.CHK_Stats_CheckedChanged); + // + // NUD_StatDev + // + this.NUD_StatDev.Location = new System.Drawing.Point(25, 133); + this.NUD_StatDev.Name = "NUD_StatDev"; + this.NUD_StatDev.Size = new System.Drawing.Size(46, 20); + this.NUD_StatDev.TabIndex = 3; + this.NUD_StatDev.Value = new decimal(new int[] { + 25, + 0, + 0, + 0}); + // + // L_StatDev + // + this.L_StatDev.AutoSize = true; + this.L_StatDev.Location = new System.Drawing.Point(6, 117); + this.L_StatDev.Name = "L_StatDev"; + this.L_StatDev.Size = new System.Drawing.Size(67, 13); + this.L_StatDev.TabIndex = 4; + this.L_StatDev.Text = "Deviance(%)"; + // + // CHK_Item + // + this.CHK_Item.AutoSize = true; + this.CHK_Item.Checked = true; + this.CHK_Item.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_Item.Location = new System.Drawing.Point(6, 49); + this.CHK_Item.Name = "CHK_Item"; + this.CHK_Item.Size = new System.Drawing.Size(51, 17); + this.CHK_Item.TabIndex = 5; + this.CHK_Item.Text = "Items"; + this.CHK_Item.UseVisualStyleBackColor = true; + // + // CHK_Type + // + this.CHK_Type.AutoSize = true; + this.CHK_Type.Checked = true; + this.CHK_Type.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_Type.Location = new System.Drawing.Point(6, 64); + this.CHK_Type.Name = "CHK_Type"; + this.CHK_Type.Size = new System.Drawing.Size(55, 17); + this.CHK_Type.TabIndex = 6; + this.CHK_Type.Text = "Types"; + this.CHK_Type.UseVisualStyleBackColor = true; + // // Personal // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(469, 417); + this.ClientSize = new System.Drawing.Size(552, 417); + this.Controls.Add(this.groupBox1); this.Controls.Add(this.B_Difficulty); this.Controls.Add(this.B_Dump); this.Controls.Add(this.B_Randomize); @@ -990,8 +1098,8 @@ private void InitializeComponent() this.Controls.Add(this.L_Species_Precursor); this.Controls.Add(this.CB_Species); this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(485, 800); - this.MinimumSize = new System.Drawing.Size(485, 455); + this.MaximumSize = new System.Drawing.Size(568, 455); + this.MinimumSize = new System.Drawing.Size(568, 455); this.Name = "Personal"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Gen VI Personal.Garc Editor"; @@ -1002,6 +1110,9 @@ private void InitializeComponent() this.TP_MoveTutors.ResumeLayout(false); this.TP_MoveTutors.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.PB_MonSprite)).EndInit(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_StatDev)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1089,5 +1200,13 @@ private void InitializeComponent() private System.Windows.Forms.Button B_Randomize; private System.Windows.Forms.Button B_Dump; private System.Windows.Forms.Button B_Difficulty; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.CheckBox CHK_TMHM; + private System.Windows.Forms.CheckBox CHK_Ability; + private System.Windows.Forms.CheckBox CHK_Stats; + private System.Windows.Forms.NumericUpDown NUD_StatDev; + private System.Windows.Forms.Label L_StatDev; + private System.Windows.Forms.CheckBox CHK_Item; + private System.Windows.Forms.CheckBox CHK_Type; } } diff --git a/pk3DS/Subforms/Personal.cs b/pk3DS/Subforms/Personal.cs index 6f56bfd..1fcfcfd 100644 --- a/pk3DS/Subforms/Personal.cs +++ b/pk3DS/Subforms/Personal.cs @@ -85,19 +85,20 @@ private void Setup() ushort[] HMs = new ushort[0]; TMHM.getTMHMList(Main.oras, ref TMs, ref HMs); CLB_TMHM.Items.Clear(); + int hmcount = (Main.oras) ? 7 : 5; if (TMs.Length == 0) // No ExeFS to grab TMs from. { for (int i = 1; i <= 100; i++) CLB_TMHM.Items.Add("TM" + i.ToString("00")); - for (int i = 1; i <= 7; i++) + for (int i = 1; i <= hmcount; i++) CLB_TMHM.Items.Add("HM" + i.ToString("00")); } else // Use TMHM moves. { for (int i = 1; i <= 100; i++) CLB_TMHM.Items.Add(String.Format("TM{0} {1}", i.ToString("00"), moves[TMs[i - 1]])); - for (int i = 1; i <= 7; i++) + for (int i = 1; i <= hmcount; i++) CLB_TMHM.Items.Add(String.Format("HM{0} {1}", i.ToString("00"), moves[HMs[i - 1]])); } for (int i = 0; i < tutormoves.Length - 1; i++) @@ -105,10 +106,6 @@ private void Setup() if (mode == "XY") { - string[] temp_abilities = new string[abilities.Length - 3]; // 3 abilities added in ORAS - Array.Copy(abilities, temp_abilities, temp_abilities.Length); - abilities = temp_abilities; - string[] temp_items = new string[718]; // 719 items in XY Array.Copy(items, temp_items, temp_items.Length); items = temp_items; @@ -120,6 +117,10 @@ private void Setup() string[] temp_species = new string[799]; // 799 species in XY Array.Copy(species, temp_species, temp_species.Length); species = temp_species; + + CLB_OrasTutors.Visible = + CLB_OrasTutors.Enabled = + Lbl_OrasTutors.Visible = false; } else if (mode == "ORAS") { @@ -133,8 +134,8 @@ private void Setup() foreach (ushort tm in tutor4) CLB_OrasTutors.Items.Add(moves[tm]); - CLB_OrasTutors.Visible = true; - CLB_OrasTutors.Enabled = true; + CLB_OrasTutors.Visible = + CLB_OrasTutors.Enabled = Lbl_OrasTutors.Visible = true; } for (int i = 0; i < species.Length; i++) @@ -275,25 +276,23 @@ private void readEntry() ofs += tutor4.Length; } } - if (!dumping) + if (dumping) return; + int[] specForm = getSpecies(data, Main.oras, CB_Species.SelectedIndex); + string filename = "_" + specForm[0] + ((CB_Species.SelectedIndex > 721) ? "_" + (specForm[1] + 1) : ""); + Bitmap rawImg = (Bitmap)Resources.ResourceManager.GetObject(filename); + Bitmap bigImg = new Bitmap(rawImg.Width * 2, rawImg.Height * 2); + for (int x = 0; x < rawImg.Width; x++) { - int[] specForm = getSpecies(data, Main.oras, CB_Species.SelectedIndex); - string filename = "_" + specForm[0] + ((CB_Species.SelectedIndex > 721) ? "_" + (specForm[1] + 1) : ""); - Bitmap rawImg = (Bitmap)Resources.ResourceManager.GetObject(filename); - Bitmap bigImg = new Bitmap(rawImg.Width * 2, rawImg.Height * 2); - for (int x = 0; x < rawImg.Width; x++) + for (int y = 0; y < rawImg.Height; y++) { - for (int y = 0; y < rawImg.Height; y++) - { - Color c = rawImg.GetPixel(x, y); - bigImg.SetPixel(2 * x, 2 * y, c); - bigImg.SetPixel(2 * x + 1, 2 * y, c); - bigImg.SetPixel(2 * x, 2 * y + 1, c); - bigImg.SetPixel(2 * x + 1, 2 * y + 1, c); - } + Color c = rawImg.GetPixel(x, y); + bigImg.SetPixel(2 * x, 2 * y, c); + bigImg.SetPixel(2 * x + 1, 2 * y, c); + bigImg.SetPixel(2 * x, 2 * y + 1, c); + bigImg.SetPixel(2 * x + 1, 2 * y + 1, c); } - PB_MonSprite.Image = bigImg; } + PB_MonSprite.Image = bigImg; } private void saveEntry() { @@ -433,48 +432,55 @@ private void B_Randomize_Click(object sender, EventArgs e) CB_Species.SelectedIndex = i; // Get new Species // Fiddle with TM Learnsets - for (int t = 0; t < CLB_TMHM.Items.Count; t++) - CLB_TMHM.SetItemChecked(t, rnd.Next(0, 100) < TMPercent); + if (CHK_TMHM.Checked) + for (int t = 0; t < CLB_TMHM.Items.Count; t++) + CLB_TMHM.SetItemCheckState(t, rnd.Next(0, 100) < TMPercent ? CheckState.Checked : CheckState.Unchecked); // Abilities: - int[] abils = new int[3]; - for (int a = 0; a < 3; a++) // Get 3 New Abilities, none being Wonder Guard (25) - { int newabil = rnd.Next(1, abillen); while (newabil == 25) newabil = rnd.Next(1, abillen); abils[a] = newabil; } - CB_Ability1.SelectedIndex = rnd.Next(1, abillen); - CB_Ability2.SelectedIndex = rnd.Next(1, abillen); - CB_Ability3.SelectedIndex = rnd.Next(1, abillen); - + if (CHK_Ability.Checked) + { + ComboBox[] abils = {CB_Ability1, CB_Ability2, CB_Ability3}; + for (int a = 0; a < 3; a++) // Set 3 New Abilities, none being Wonder Guard (25) + { + int newabil = rnd.Next(1, abillen); + while (newabil == 25) + newabil = rnd.Next(1, abillen); + if (abils[a].SelectedIndex != 25) abils[a].SelectedIndex = newabil; + } + } // Fiddle with Base Stats, don't muck with Shedinja. - if (Convert.ToByte(byte_boxes[0].Text) == 1) - CB_Ability1.SelectedIndex = CB_Ability2.SelectedIndex = CB_Ability3.SelectedIndex = 25; - else - for (int z = 0; z < 6; z++) - byte_boxes[z].Text = - Math.Max( - 5, - rnd.Next - ( - Convert.ToByte(byte_boxes[z].Text) * 3 / 4, - Convert.ToByte(byte_boxes[z].Text) * 5 / 4) - ) - .ToString("000"); - + if (CHK_Stats.Checked) + { + if (Convert.ToByte(byte_boxes[0].Text) != 1) + for (int z = 0; z < 6; z++) + byte_boxes[z].Text = + Math.Max(5,rnd.Next( + Math.Min(255, (int) (Convert.ToByte(byte_boxes[z].Text)*(1 - NUD_StatDev.Value/100))), + Math.Min(255, (int) (Convert.ToByte(byte_boxes[z].Text)*(1 + NUD_StatDev.Value/100))) + )).ToString("000"); + } // EV yield stays the same... // Items - CB_HeldItem1.SelectedIndex = (CB_HeldItem1.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; - CB_HeldItem2.SelectedIndex = (CB_HeldItem2.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; - CB_HeldItem3.SelectedIndex = (CB_HeldItem3.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; + if (CHK_Item.Checked) + { + CB_HeldItem1.SelectedIndex = (CB_HeldItem1.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; + CB_HeldItem2.SelectedIndex = (CB_HeldItem2.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; + CB_HeldItem3.SelectedIndex = (CB_HeldItem3.SelectedIndex > 0) ? itemlist[rnd.Next(1, itemlen)] : 0; + } // Type - if (rnd.Next(0, 100) < 50) // 50% chance to have either Single or Dual Typing - CB_Type1.SelectedIndex = CB_Type2.SelectedIndex = rnd.Next(0, typelen); - else + if (CHK_Type.Checked) { - CB_Type1.SelectedIndex = rnd.Next(0, typelen); - CB_Type2.SelectedIndex = rnd.Next(0, typelen); + if (rnd.Next(0, 100) < 50) // 50% chance to have either Single or Dual Typing + CB_Type1.SelectedIndex = CB_Type2.SelectedIndex = rnd.Next(0, typelen); + else + { + CB_Type1.SelectedIndex = rnd.Next(0, typelen); + CB_Type2.SelectedIndex = rnd.Next(0, typelen); + } } } saveEntry(); @@ -533,10 +539,10 @@ internal static int[] getSpecies(byte[] data, bool oras, int PersonalEntry) { int FormCount = data[i * entrysize + 0x20] - 1; // Mons with no alt forms have a FormCount of 1. ushort altformpointer = BitConverter.ToUInt16(data, entrysize * i + 0x1C); - if (altformpointer > 0) - for (int j = 0; j < FormCount; j++) - if (altformpointer + j == PersonalEntry) - return new[] { i, j }; + if (altformpointer <= 0) continue; + for (int j = 0; j < FormCount; j++) + if (altformpointer + j == PersonalEntry) + return new[] { i, j }; } return new[] { -1, -1 }; @@ -552,12 +558,10 @@ internal static string[][] getFormList(byte[] data, bool oras, string[] species, { int FormCount = data[i * entrysize + 0x20]; // Mons with no alt forms have a FormCount of 1. FormList[i] = new string[FormCount]; - if (FormCount > 0) - { - FormList[i][0] = (forms[i] == "") ? species[i] : forms[i]; - for (int j = 1; j < FormCount; j++) - FormList[i][j] = forms[AltFormOfs++]; - } + if (FormCount <= 0) continue; + FormList[i][0] = (forms[i] == "") ? species[i] : forms[i]; + for (int j = 1; j < FormCount; j++) + FormList[i][j] = forms[AltFormOfs++]; } // Need to hardcode here: Unown, Arceus, Genesect, any others? // Unown @@ -574,7 +578,7 @@ internal static string[][] getFormList(byte[] data, bool oras, string[] species, return FormList; } - catch (Exception e) { Util.Error("Error while creating the Alternate Formes Listing.", "Please make sure that the Personal.dat & Forms text are as intended", "Error:" + Environment.NewLine + e.ToString()); return null; } + catch (Exception e) { Util.Error("Error while creating the Alternate Formes Listing.", "Please make sure that the Personal.dat & Forms text are as intended", "Error:" + Environment.NewLine + e); return null; } } internal static string[] getPersonalEntryList(byte[] data, bool oras, string[][] AltForms, string[] species) { @@ -616,5 +620,10 @@ internal static void setForms(int species, ComboBox cb, string[][] AltForms) } cb.SelectedIndex = 0; } + + private void CHK_Stats_CheckedChanged(object sender, EventArgs e) + { + L_StatDev.Visible = NUD_StatDev.Visible = CHK_Stats.Checked; + } } } \ No newline at end of file