From cda607dba8be96f941dfcbed50313d075e22f1a1 Mon Sep 17 00:00:00 2001 From: OtakuGracie Date: Sat, 22 Jul 2023 00:08:48 -0400 Subject: [PATCH] Added ability to edit trainer pokemon ability and gender for HGSS --- DS_Map/DSPRE.csproj | 1 + DS_Map/Main Window.Designer.cs | 258 +++++++++++++++++++++++++++------ DS_Map/Main Window.cs | 190 +++++++++++++++++++----- DS_Map/Main Window.resx | 2 +- DS_Map/ROMFiles/TrainerFile.cs | 91 ++++++------ DS_Map/RomInfo.cs | 27 ++++ 6 files changed, 437 insertions(+), 132 deletions(-) diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj index 0650a53..60b2fb6 100644 --- a/DS_Map/DSPRE.csproj +++ b/DS_Map/DSPRE.csproj @@ -156,6 +156,7 @@ + Form diff --git a/DS_Map/Main Window.Designer.cs b/DS_Map/Main Window.Designer.cs index 21cc54c..32678d7 100644 --- a/DS_Map/Main Window.Designer.cs +++ b/DS_Map/Main Window.Designer.cs @@ -632,6 +632,8 @@ this.addTrainerButton = new System.Windows.Forms.Button(); this.groupBox28 = new System.Windows.Forms.GroupBox(); this.party6GroupBox = new System.Windows.Forms.GroupBox(); + this.partyAbility6ComboBox = new System.Windows.Forms.ComboBox(); + this.partyGender6ComboBox = new System.Windows.Forms.ComboBox(); this.partyPokemonItemPictureBox6 = new System.Windows.Forms.PictureBox(); this.label60 = new System.Windows.Forms.Label(); this.label61 = new System.Windows.Forms.Label(); @@ -648,6 +650,8 @@ this.partyPokemon6PictureBox = new System.Windows.Forms.PictureBox(); this.partyPokemon6ComboBox = new DSPRE.InputComboBox(); this.party5GroupBox = new System.Windows.Forms.GroupBox(); + this.partyAbility5ComboBox = new System.Windows.Forms.ComboBox(); + this.partyGender5ComboBox = new System.Windows.Forms.ComboBox(); this.partyPokemonItemPictureBox5 = new System.Windows.Forms.PictureBox(); this.label57 = new System.Windows.Forms.Label(); this.label58 = new System.Windows.Forms.Label(); @@ -664,6 +668,8 @@ this.partyPokemon5PictureBox = new System.Windows.Forms.PictureBox(); this.partyPokemon5ComboBox = new DSPRE.InputComboBox(); this.party4GroupBox = new System.Windows.Forms.GroupBox(); + this.partyAbility4ComboBox = new System.Windows.Forms.ComboBox(); + this.partyGender4ComboBox = new System.Windows.Forms.ComboBox(); this.partyPokemonItemPictureBox4 = new System.Windows.Forms.PictureBox(); this.label54 = new System.Windows.Forms.Label(); this.label55 = new System.Windows.Forms.Label(); @@ -680,6 +686,8 @@ this.partyPokemon4PictureBox = new System.Windows.Forms.PictureBox(); this.partyPokemon4ComboBox = new DSPRE.InputComboBox(); this.party3GroupBox = new System.Windows.Forms.GroupBox(); + this.partyAbility3ComboBox = new System.Windows.Forms.ComboBox(); + this.partyGender3ComboBox = new System.Windows.Forms.ComboBox(); this.partyPokemonItemPictureBox3 = new System.Windows.Forms.PictureBox(); this.label51 = new System.Windows.Forms.Label(); this.label52 = new System.Windows.Forms.Label(); @@ -696,6 +704,8 @@ this.partyPokemon3PictureBox = new System.Windows.Forms.PictureBox(); this.partyPokemon3ComboBox = new DSPRE.InputComboBox(); this.party2GroupBox = new System.Windows.Forms.GroupBox(); + this.partyAbility2ComboBox = new System.Windows.Forms.ComboBox(); + this.partyGender2ComboBox = new System.Windows.Forms.ComboBox(); this.partyPokemonItemPictureBox2 = new System.Windows.Forms.PictureBox(); this.label48 = new System.Windows.Forms.Label(); this.label49 = new System.Windows.Forms.Label(); @@ -712,6 +722,7 @@ this.partyPokemon2PictureBox = new System.Windows.Forms.PictureBox(); this.partyPokemon2ComboBox = new DSPRE.InputComboBox(); this.party1GroupBox = new System.Windows.Forms.GroupBox(); + this.partyAbility1ComboBox = new System.Windows.Forms.ComboBox(); this.partyPokemonItemPictureBox1 = new System.Windows.Forms.PictureBox(); this.label47 = new System.Windows.Forms.Label(); this.label46 = new System.Windows.Forms.Label(); @@ -884,6 +895,7 @@ this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry(); this.directoryEntry2 = new System.DirectoryServices.DirectoryEntry(); + this.partyGender1ComboBox = new System.Windows.Forms.ComboBox(); this.mainTabControl.SuspendLayout(); this.headerEditorTabPage.SuspendLayout(); this.worldmapCoordsGroupBox.SuspendLayout(); @@ -1151,7 +1163,7 @@ this.mainTabControl.Location = new System.Drawing.Point(11, 72); this.mainTabControl.Name = "mainTabControl"; this.mainTabControl.SelectedIndex = 0; - this.mainTabControl.Size = new System.Drawing.Size(1193, 646); + this.mainTabControl.Size = new System.Drawing.Size(1193, 730); this.mainTabControl.TabIndex = 5; this.mainTabControl.Visible = false; this.mainTabControl.SelectedIndexChanged += new System.EventHandler(this.mainTabControl_SelectedIndexChanged); @@ -1186,7 +1198,7 @@ this.headerEditorTabPage.Location = new System.Drawing.Point(4, 23); this.headerEditorTabPage.Name = "headerEditorTabPage"; this.headerEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.headerEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.headerEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.headerEditorTabPage.TabIndex = 0; this.headerEditorTabPage.Text = "Header Editor"; // @@ -2574,7 +2586,7 @@ this.matrixEditorTabPage.Location = new System.Drawing.Point(4, 23); this.matrixEditorTabPage.Name = "matrixEditorTabPage"; this.matrixEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.matrixEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.matrixEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.matrixEditorTabPage.TabIndex = 1; this.matrixEditorTabPage.Text = "Matrix Editor"; // @@ -2595,7 +2607,7 @@ this.setSpawnPointButton.Image = global::DSPRE.Properties.Resources.spawnCoordsMatrixeditorIcon; this.setSpawnPointButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.setSpawnPointButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.setSpawnPointButton.Location = new System.Drawing.Point(11, 521); + this.setSpawnPointButton.Location = new System.Drawing.Point(11, 605); this.setSpawnPointButton.Name = "setSpawnPointButton"; this.setSpawnPointButton.Size = new System.Drawing.Size(117, 43); this.setSpawnPointButton.TabIndex = 32; @@ -2767,7 +2779,7 @@ this.matrixTabControl.Multiline = true; this.matrixTabControl.Name = "matrixTabControl"; this.matrixTabControl.SelectedIndex = 0; - this.matrixTabControl.Size = new System.Drawing.Size(1040, 602); + this.matrixTabControl.Size = new System.Drawing.Size(1040, 686); this.matrixTabControl.TabIndex = 18; // // headersTabPage @@ -2776,7 +2788,7 @@ this.headersTabPage.Location = new System.Drawing.Point(4, 22); this.headersTabPage.Name = "headersTabPage"; this.headersTabPage.Padding = new System.Windows.Forms.Padding(3); - this.headersTabPage.Size = new System.Drawing.Size(1032, 576); + this.headersTabPage.Size = new System.Drawing.Size(1032, 660); this.headersTabPage.TabIndex = 1; this.headersTabPage.Text = "Map Headers"; this.headersTabPage.UseVisualStyleBackColor = true; @@ -2839,7 +2851,7 @@ this.heightsTabPage.Controls.Add(this.heightsGridView); this.heightsTabPage.Location = new System.Drawing.Point(4, 22); this.heightsTabPage.Name = "heightsTabPage"; - this.heightsTabPage.Size = new System.Drawing.Size(1032, 576); + this.heightsTabPage.Size = new System.Drawing.Size(1032, 660); this.heightsTabPage.TabIndex = 2; this.heightsTabPage.Text = "Map Heights"; this.heightsTabPage.UseVisualStyleBackColor = true; @@ -2902,7 +2914,7 @@ this.mapFilesTabPage.Controls.Add(this.mapFilesGridView); this.mapFilesTabPage.Location = new System.Drawing.Point(4, 22); this.mapFilesTabPage.Name = "mapFilesTabPage"; - this.mapFilesTabPage.Size = new System.Drawing.Size(1032, 576); + this.mapFilesTabPage.Size = new System.Drawing.Size(1032, 660); this.mapFilesTabPage.TabIndex = 3; this.mapFilesTabPage.Text = "Map Files"; this.mapFilesTabPage.UseVisualStyleBackColor = true; @@ -3042,7 +3054,7 @@ this.saveMatrixButton.Image = global::DSPRE.Properties.Resources.save_rom; this.saveMatrixButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.saveMatrixButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.saveMatrixButton.Location = new System.Drawing.Point(11, 566); + this.saveMatrixButton.Location = new System.Drawing.Point(11, 650); this.saveMatrixButton.Name = "saveMatrixButton"; this.saveMatrixButton.Size = new System.Drawing.Size(117, 43); this.saveMatrixButton.TabIndex = 22; @@ -3071,7 +3083,7 @@ this.mapEditorTabPage.Location = new System.Drawing.Point(4, 23); this.mapEditorTabPage.Name = "mapEditorTabPage"; this.mapEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.mapEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.mapEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.mapEditorTabPage.TabIndex = 2; this.mapEditorTabPage.Text = "Map Editor"; this.mapEditorTabPage.Enter += new System.EventHandler(this.mapEditorTabPage_Enter); @@ -4365,7 +4377,7 @@ this.radio3D.AutoSize = true; this.radio3D.Checked = true; this.radio3D.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.radio3D.Location = new System.Drawing.Point(1140, 542); + this.radio3D.Location = new System.Drawing.Point(1140, 626); this.radio3D.Name = "radio3D"; this.radio3D.Size = new System.Drawing.Size(31, 23); this.radio3D.TabIndex = 26; @@ -4380,7 +4392,7 @@ this.radio2D.Appearance = System.Windows.Forms.Appearance.Button; this.radio2D.AutoSize = true; this.radio2D.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.radio2D.Location = new System.Drawing.Point(1140, 566); + this.radio2D.Location = new System.Drawing.Point(1140, 650); this.radio2D.Name = "radio2D"; this.radio2D.Size = new System.Drawing.Size(31, 23); this.radio2D.TabIndex = 25; @@ -4395,7 +4407,7 @@ this.wireframeCheckBox.Appearance = System.Windows.Forms.Appearance.Button; this.wireframeCheckBox.AutoSize = true; this.wireframeCheckBox.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.wireframeCheckBox.Location = new System.Drawing.Point(1140, 590); + this.wireframeCheckBox.Location = new System.Drawing.Point(1140, 674); this.wireframeCheckBox.Name = "wireframeCheckBox"; this.wireframeCheckBox.Size = new System.Drawing.Size(31, 23); this.wireframeCheckBox.TabIndex = 27; @@ -4410,7 +4422,7 @@ this.nsbtxEditorTabPage.Location = new System.Drawing.Point(4, 23); this.nsbtxEditorTabPage.Name = "nsbtxEditorTabPage"; this.nsbtxEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.nsbtxEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.nsbtxEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.nsbtxEditorTabPage.TabIndex = 6; this.nsbtxEditorTabPage.Text = "NSBTX Editor"; this.nsbtxEditorTabPage.UseVisualStyleBackColor = true; @@ -4951,7 +4963,7 @@ this.eventEditorTabPage.Location = new System.Drawing.Point(4, 23); this.eventEditorTabPage.Name = "eventEditorTabPage"; this.eventEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.eventEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.eventEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.eventEditorTabPage.TabIndex = 3; this.eventEditorTabPage.Text = "Event Editor"; this.eventEditorTabPage.Enter += new System.EventHandler(this.eventEditorTabPage_Enter); @@ -6996,7 +7008,7 @@ this.scriptEditorTabPage.Location = new System.Drawing.Point(4, 23); this.scriptEditorTabPage.Name = "scriptEditorTabPage"; this.scriptEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.scriptEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.scriptEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.scriptEditorTabPage.TabIndex = 4; this.scriptEditorTabPage.Text = "Script Editor"; this.scriptEditorTabPage.UseVisualStyleBackColor = true; @@ -7735,7 +7747,7 @@ this.textEditorTabPage.Location = new System.Drawing.Point(4, 23); this.textEditorTabPage.Name = "textEditorTabPage"; this.textEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.textEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.textEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.textEditorTabPage.TabIndex = 5; this.textEditorTabPage.Text = "Text Editor"; this.textEditorTabPage.UseVisualStyleBackColor = true; @@ -8159,7 +8171,7 @@ this.cameraEditorTabPage.ImageIndex = 7; this.cameraEditorTabPage.Location = new System.Drawing.Point(4, 23); this.cameraEditorTabPage.Name = "cameraEditorTabPage"; - this.cameraEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.cameraEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.cameraEditorTabPage.TabIndex = 7; this.cameraEditorTabPage.Text = "Camera Editor"; this.cameraEditorTabPage.UseVisualStyleBackColor = true; @@ -8353,7 +8365,7 @@ this.trainerEditorTabPage.ImageIndex = 8; this.trainerEditorTabPage.Location = new System.Drawing.Point(4, 23); this.trainerEditorTabPage.Name = "trainerEditorTabPage"; - this.trainerEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.trainerEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.trainerEditorTabPage.TabIndex = 8; this.trainerEditorTabPage.Text = "Trainer Editor"; this.trainerEditorTabPage.UseVisualStyleBackColor = true; @@ -8520,13 +8532,15 @@ this.groupBox28.Controls.Add(this.party1GroupBox); this.groupBox28.Location = new System.Drawing.Point(439, 75); this.groupBox28.Name = "groupBox28"; - this.groupBox28.Size = new System.Drawing.Size(731, 534); + this.groupBox28.Size = new System.Drawing.Size(731, 625); this.groupBox28.TabIndex = 32; this.groupBox28.TabStop = false; this.groupBox28.Text = "Party"; // // party6GroupBox // + this.party6GroupBox.Controls.Add(this.partyAbility6ComboBox); + this.party6GroupBox.Controls.Add(this.partyGender6ComboBox); this.party6GroupBox.Controls.Add(this.partyPokemonItemPictureBox6); this.party6GroupBox.Controls.Add(this.label60); this.party6GroupBox.Controls.Add(this.label61); @@ -8539,13 +8553,35 @@ this.party6GroupBox.Controls.Add(this.partyPokemon6PictureBox); this.party6GroupBox.Controls.Add(this.partyPokemon6ComboBox); this.party6GroupBox.Enabled = false; - this.party6GroupBox.Location = new System.Drawing.Point(371, 355); + this.party6GroupBox.Location = new System.Drawing.Point(371, 418); this.party6GroupBox.Name = "party6GroupBox"; - this.party6GroupBox.Size = new System.Drawing.Size(343, 162); + this.party6GroupBox.Size = new System.Drawing.Size(343, 189); this.party6GroupBox.TabIndex = 13; this.party6GroupBox.TabStop = false; this.party6GroupBox.Text = "Pokemon 6"; // + // partyAbility6ComboBox + // + this.partyAbility6ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyAbility6ComboBox.FormattingEnabled = true; + this.partyAbility6ComboBox.Location = new System.Drawing.Point(15, 157); + this.partyAbility6ComboBox.Name = "partyAbility6ComboBox"; + this.partyAbility6ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyAbility6ComboBox.TabIndex = 19; + // + // partyGender6ComboBox + // + this.partyGender6ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyGender6ComboBox.FormattingEnabled = true; + this.partyGender6ComboBox.Items.AddRange(new object[] { + "Default Gender", + "Force Male", + "Force Female"}); + this.partyGender6ComboBox.Location = new System.Drawing.Point(154, 157); + this.partyGender6ComboBox.Name = "partyGender6ComboBox"; + this.partyGender6ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyGender6ComboBox.TabIndex = 15; + // // partyPokemonItemPictureBox6 // this.partyPokemonItemPictureBox6.Image = global::DSPRE.Properties.Resources.IconItem; @@ -8648,7 +8684,7 @@ // this.partyIV6UpDown.Location = new System.Drawing.Point(48, 98); this.partyIV6UpDown.Maximum = new decimal(new int[] { - 65535, + 255, 0, 0, 0}); @@ -8719,6 +8755,8 @@ // // party5GroupBox // + this.party5GroupBox.Controls.Add(this.partyAbility5ComboBox); + this.party5GroupBox.Controls.Add(this.partyGender5ComboBox); this.party5GroupBox.Controls.Add(this.partyPokemonItemPictureBox5); this.party5GroupBox.Controls.Add(this.label57); this.party5GroupBox.Controls.Add(this.label58); @@ -8731,13 +8769,35 @@ this.party5GroupBox.Controls.Add(this.partyPokemon5PictureBox); this.party5GroupBox.Controls.Add(this.partyPokemon5ComboBox); this.party5GroupBox.Enabled = false; - this.party5GroupBox.Location = new System.Drawing.Point(16, 355); + this.party5GroupBox.Location = new System.Drawing.Point(16, 418); this.party5GroupBox.Name = "party5GroupBox"; - this.party5GroupBox.Size = new System.Drawing.Size(343, 162); + this.party5GroupBox.Size = new System.Drawing.Size(343, 189); this.party5GroupBox.TabIndex = 12; this.party5GroupBox.TabStop = false; this.party5GroupBox.Text = "Pokemon 5"; // + // partyAbility5ComboBox + // + this.partyAbility5ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyAbility5ComboBox.FormattingEnabled = true; + this.partyAbility5ComboBox.Location = new System.Drawing.Point(15, 157); + this.partyAbility5ComboBox.Name = "partyAbility5ComboBox"; + this.partyAbility5ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyAbility5ComboBox.TabIndex = 18; + // + // partyGender5ComboBox + // + this.partyGender5ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyGender5ComboBox.FormattingEnabled = true; + this.partyGender5ComboBox.Items.AddRange(new object[] { + "Default Gender", + "Force Male", + "Force Female"}); + this.partyGender5ComboBox.Location = new System.Drawing.Point(156, 157); + this.partyGender5ComboBox.Name = "partyGender5ComboBox"; + this.partyGender5ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyGender5ComboBox.TabIndex = 14; + // // partyPokemonItemPictureBox5 // this.partyPokemonItemPictureBox5.Image = global::DSPRE.Properties.Resources.IconItem; @@ -8840,7 +8900,7 @@ // this.partyIV5UpDown.Location = new System.Drawing.Point(48, 98); this.partyIV5UpDown.Maximum = new decimal(new int[] { - 65535, + 255, 0, 0, 0}); @@ -8911,6 +8971,8 @@ // // party4GroupBox // + this.party4GroupBox.Controls.Add(this.partyAbility4ComboBox); + this.party4GroupBox.Controls.Add(this.partyGender4ComboBox); this.party4GroupBox.Controls.Add(this.partyPokemonItemPictureBox4); this.party4GroupBox.Controls.Add(this.label54); this.party4GroupBox.Controls.Add(this.label55); @@ -8923,13 +8985,35 @@ this.party4GroupBox.Controls.Add(this.partyPokemon4PictureBox); this.party4GroupBox.Controls.Add(this.partyPokemon4ComboBox); this.party4GroupBox.Enabled = false; - this.party4GroupBox.Location = new System.Drawing.Point(371, 189); + this.party4GroupBox.Location = new System.Drawing.Point(371, 225); this.party4GroupBox.Name = "party4GroupBox"; - this.party4GroupBox.Size = new System.Drawing.Size(343, 162); + this.party4GroupBox.Size = new System.Drawing.Size(343, 185); this.party4GroupBox.TabIndex = 11; this.party4GroupBox.TabStop = false; this.party4GroupBox.Text = "Pokemon 4"; // + // partyAbility4ComboBox + // + this.partyAbility4ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyAbility4ComboBox.FormattingEnabled = true; + this.partyAbility4ComboBox.Location = new System.Drawing.Point(15, 157); + this.partyAbility4ComboBox.Name = "partyAbility4ComboBox"; + this.partyAbility4ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyAbility4ComboBox.TabIndex = 17; + // + // partyGender4ComboBox + // + this.partyGender4ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyGender4ComboBox.FormattingEnabled = true; + this.partyGender4ComboBox.Items.AddRange(new object[] { + "Default Gender", + "Force Male", + "Force Female"}); + this.partyGender4ComboBox.Location = new System.Drawing.Point(154, 157); + this.partyGender4ComboBox.Name = "partyGender4ComboBox"; + this.partyGender4ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyGender4ComboBox.TabIndex = 16; + // // partyPokemonItemPictureBox4 // this.partyPokemonItemPictureBox4.Image = global::DSPRE.Properties.Resources.IconItem; @@ -9032,7 +9116,7 @@ // this.partyIV4UpDown.Location = new System.Drawing.Point(48, 98); this.partyIV4UpDown.Maximum = new decimal(new int[] { - 65535, + 255, 0, 0, 0}); @@ -9103,6 +9187,8 @@ // // party3GroupBox // + this.party3GroupBox.Controls.Add(this.partyAbility3ComboBox); + this.party3GroupBox.Controls.Add(this.partyGender3ComboBox); this.party3GroupBox.Controls.Add(this.partyPokemonItemPictureBox3); this.party3GroupBox.Controls.Add(this.label51); this.party3GroupBox.Controls.Add(this.label52); @@ -9115,13 +9201,35 @@ this.party3GroupBox.Controls.Add(this.partyPokemon3PictureBox); this.party3GroupBox.Controls.Add(this.partyPokemon3ComboBox); this.party3GroupBox.Enabled = false; - this.party3GroupBox.Location = new System.Drawing.Point(16, 189); + this.party3GroupBox.Location = new System.Drawing.Point(16, 225); this.party3GroupBox.Name = "party3GroupBox"; - this.party3GroupBox.Size = new System.Drawing.Size(343, 162); + this.party3GroupBox.Size = new System.Drawing.Size(343, 187); this.party3GroupBox.TabIndex = 10; this.party3GroupBox.TabStop = false; this.party3GroupBox.Text = "Pokemon 3"; // + // partyAbility3ComboBox + // + this.partyAbility3ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyAbility3ComboBox.FormattingEnabled = true; + this.partyAbility3ComboBox.Location = new System.Drawing.Point(15, 157); + this.partyAbility3ComboBox.Name = "partyAbility3ComboBox"; + this.partyAbility3ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyAbility3ComboBox.TabIndex = 14; + // + // partyGender3ComboBox + // + this.partyGender3ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyGender3ComboBox.FormattingEnabled = true; + this.partyGender3ComboBox.Items.AddRange(new object[] { + "Default Gender", + "Force Male", + "Force Female"}); + this.partyGender3ComboBox.Location = new System.Drawing.Point(156, 157); + this.partyGender3ComboBox.Name = "partyGender3ComboBox"; + this.partyGender3ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyGender3ComboBox.TabIndex = 13; + // // partyPokemonItemPictureBox3 // this.partyPokemonItemPictureBox3.Image = global::DSPRE.Properties.Resources.IconItem; @@ -9224,7 +9332,7 @@ // this.partyIV3UpDown.Location = new System.Drawing.Point(48, 98); this.partyIV3UpDown.Maximum = new decimal(new int[] { - 65535, + 255, 0, 0, 0}); @@ -9295,6 +9403,8 @@ // // party2GroupBox // + this.party2GroupBox.Controls.Add(this.partyAbility2ComboBox); + this.party2GroupBox.Controls.Add(this.partyGender2ComboBox); this.party2GroupBox.Controls.Add(this.partyPokemonItemPictureBox2); this.party2GroupBox.Controls.Add(this.label48); this.party2GroupBox.Controls.Add(this.label49); @@ -9309,11 +9419,33 @@ this.party2GroupBox.Enabled = false; this.party2GroupBox.Location = new System.Drawing.Point(371, 23); this.party2GroupBox.Name = "party2GroupBox"; - this.party2GroupBox.Size = new System.Drawing.Size(343, 162); + this.party2GroupBox.Size = new System.Drawing.Size(343, 196); this.party2GroupBox.TabIndex = 10; this.party2GroupBox.TabStop = false; this.party2GroupBox.Text = "Pokemon 2"; // + // partyAbility2ComboBox + // + this.partyAbility2ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyAbility2ComboBox.FormattingEnabled = true; + this.partyAbility2ComboBox.Location = new System.Drawing.Point(15, 162); + this.partyAbility2ComboBox.Name = "partyAbility2ComboBox"; + this.partyAbility2ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyAbility2ComboBox.TabIndex = 18; + // + // partyGender2ComboBox + // + this.partyGender2ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyGender2ComboBox.FormattingEnabled = true; + this.partyGender2ComboBox.Items.AddRange(new object[] { + "Default Gender", + "Force Male", + "Force Female"}); + this.partyGender2ComboBox.Location = new System.Drawing.Point(154, 162); + this.partyGender2ComboBox.Name = "partyGender2ComboBox"; + this.partyGender2ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyGender2ComboBox.TabIndex = 17; + // // partyPokemonItemPictureBox2 // this.partyPokemonItemPictureBox2.Image = global::DSPRE.Properties.Resources.IconItem; @@ -9416,7 +9548,7 @@ // this.partyIV2UpDown.Location = new System.Drawing.Point(48, 98); this.partyIV2UpDown.Maximum = new decimal(new int[] { - 65535, + 255, 0, 0, 0}); @@ -9487,6 +9619,8 @@ // // party1GroupBox // + this.party1GroupBox.Controls.Add(this.partyAbility1ComboBox); + this.party1GroupBox.Controls.Add(this.partyGender1ComboBox); this.party1GroupBox.Controls.Add(this.partyPokemonItemPictureBox1); this.party1GroupBox.Controls.Add(this.label47); this.party1GroupBox.Controls.Add(this.label46); @@ -9501,11 +9635,20 @@ this.party1GroupBox.Enabled = false; this.party1GroupBox.Location = new System.Drawing.Point(16, 23); this.party1GroupBox.Name = "party1GroupBox"; - this.party1GroupBox.Size = new System.Drawing.Size(343, 162); + this.party1GroupBox.Size = new System.Drawing.Size(343, 196); this.party1GroupBox.TabIndex = 0; this.party1GroupBox.TabStop = false; this.party1GroupBox.Text = "Pokemon 1"; // + // partyAbility1ComboBox + // + this.partyAbility1ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyAbility1ComboBox.FormattingEnabled = true; + this.partyAbility1ComboBox.Location = new System.Drawing.Point(15, 162); + this.partyAbility1ComboBox.Name = "partyAbility1ComboBox"; + this.partyAbility1ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyAbility1ComboBox.TabIndex = 13; + // // partyPokemonItemPictureBox1 // this.partyPokemonItemPictureBox1.Image = global::DSPRE.Properties.Resources.IconItem; @@ -9608,7 +9751,7 @@ // this.partyIV1UpDown.Location = new System.Drawing.Point(48, 98); this.partyIV1UpDown.Maximum = new decimal(new int[] { - 65535, + 255, 0, 0, 0}); @@ -10136,7 +10279,7 @@ this.tableEditorTabPage.Location = new System.Drawing.Point(4, 23); this.tableEditorTabPage.Name = "tableEditorTabPage"; this.tableEditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.tableEditorTabPage.Size = new System.Drawing.Size(1185, 619); + this.tableEditorTabPage.Size = new System.Drawing.Size(1185, 703); this.tableEditorTabPage.TabIndex = 9; this.tableEditorTabPage.Text = "Table Editor"; this.tableEditorTabPage.UseVisualStyleBackColor = true; @@ -10650,8 +10793,8 @@ this.menuStrip1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, - this.menuViewToolStripMenuItem, this.aboutToolStripMenuItem, + this.menuViewToolStripMenuItem, this.aboutToolStripMenuItem1}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; @@ -10905,14 +11048,14 @@ // essentialToolStripMenuItem // this.essentialToolStripMenuItem.Name = "essentialToolStripMenuItem"; - this.essentialToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.essentialToolStripMenuItem.Size = new System.Drawing.Size(127, 22); this.essentialToolStripMenuItem.Text = "Essential"; this.essentialToolStripMenuItem.MouseDown += new System.Windows.Forms.MouseEventHandler(this.simpleToolStripMenuItem_MouseDown); // // simpleToolStripMenuItem // this.simpleToolStripMenuItem.Name = "simpleToolStripMenuItem"; - this.simpleToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.simpleToolStripMenuItem.Size = new System.Drawing.Size(127, 22); this.simpleToolStripMenuItem.Text = "Simple"; this.simpleToolStripMenuItem.MouseDown += new System.Windows.Forms.MouseEventHandler(this.simpleToolStripMenuItem_MouseDown); // @@ -10921,14 +11064,14 @@ this.advancedStripMenuItem.Checked = true; this.advancedStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.advancedStripMenuItem.Name = "advancedStripMenuItem"; - this.advancedStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.advancedStripMenuItem.Size = new System.Drawing.Size(127, 22); this.advancedStripMenuItem.Text = "Advanced"; this.advancedStripMenuItem.MouseDown += new System.Windows.Forms.MouseEventHandler(this.simpleToolStripMenuItem_MouseDown); // // fullViewToolStripMenuItem // this.fullViewToolStripMenuItem.Name = "fullViewToolStripMenuItem"; - this.fullViewToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.fullViewToolStripMenuItem.Size = new System.Drawing.Size(127, 22); this.fullViewToolStripMenuItem.Text = "Complete"; this.fullViewToolStripMenuItem.MouseDown += new System.Windows.Forms.MouseEventHandler(this.simpleToolStripMenuItem_MouseDown); // @@ -10945,7 +11088,7 @@ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.statusLabel, this.toolStripProgressBar}); - this.statusStrip1.Location = new System.Drawing.Point(0, 721); + this.statusStrip1.Location = new System.Drawing.Point(0, 805); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(1214, 22); this.statusStrip1.TabIndex = 13; @@ -11308,12 +11451,25 @@ // this.openFileDialog1.FileName = "openFileDialog1"; // + // partyGender1ComboBox + // + this.partyGender1ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.partyGender1ComboBox.FormattingEnabled = true; + this.partyGender1ComboBox.Items.AddRange(new object[] { + "Default Gender", + "Force Male", + "Force Female"}); + this.partyGender1ComboBox.Location = new System.Drawing.Point(156, 162); + this.partyGender1ComboBox.Name = "partyGender1ComboBox"; + this.partyGender1ComboBox.Size = new System.Drawing.Size(121, 21); + this.partyGender1ComboBox.TabIndex = 12; + // // MainProgram // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1214, 743); + this.ClientSize = new System.Drawing.Size(1214, 827); this.Controls.Add(this.versionLabel); this.Controls.Add(this.languageLabel); this.Controls.Add(this.gameIcon); @@ -11327,7 +11483,7 @@ this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; this.Name = "MainProgram"; - this.Text = "DS Pokémon Rom Editor Reloaded 1.9.3 (Nømura, AdAstra/LD3005)"; + this.Text = "DS Pokémon Rom Editor Reloaded 1.9.2 (Nømura, AdAstra/LD3005)"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainProgram_FormClosing); this.mainTabControl.ResumeLayout(false); this.headerEditorTabPage.ResumeLayout(false); @@ -12492,6 +12648,18 @@ private System.Windows.Forms.Button glbExportButton; private System.Windows.Forms.Button sortOWsByIDAscButton; private System.Windows.Forms.Button sortOWsByIDDescButton; + private System.Windows.Forms.ComboBox partyGender6ComboBox; + private System.Windows.Forms.ComboBox partyGender5ComboBox; + private System.Windows.Forms.ComboBox partyGender4ComboBox; + private System.Windows.Forms.ComboBox partyGender3ComboBox; + private System.Windows.Forms.ComboBox partyGender2ComboBox; + private System.Windows.Forms.ComboBox partyAbility1ComboBox; + private System.Windows.Forms.ComboBox partyAbility6ComboBox; + private System.Windows.Forms.ComboBox partyAbility5ComboBox; + private System.Windows.Forms.ComboBox partyAbility4ComboBox; + private System.Windows.Forms.ComboBox partyAbility3ComboBox; + private System.Windows.Forms.ComboBox partyAbility2ComboBox; + private System.Windows.Forms.ComboBox partyGender1ComboBox; } } diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 6280125..d0cafc6 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -1192,8 +1192,6 @@ namespace DSPRE { flagVal += (byte)Math.Pow(2, 5); if (flag6CheckBox.Checked) flagVal += (byte)Math.Pow(2, 6); - //if (flag7CheckBox.Checked) - // flagVal += (byte)Math.Pow(2, 7); } currentHeader.flags = flagVal; } @@ -1297,7 +1295,6 @@ namespace DSPRE { flag4CheckBox.Checked = ba[4]; flag5CheckBox.Checked = ba[5]; flag6CheckBox.Checked = ba[6]; - //flag6CheckBox.Checked = ba[7]; } } private void eventsTabControl_SelectedIndexChanged(object sender, EventArgs e) { @@ -1792,9 +1789,6 @@ namespace DSPRE { case gFamEnum.HGSS: HeaderHGSS ch = (HeaderHGSS)currentHeader; ch.locationType = (byte)areaSettingsComboBox.SelectedIndex; - //areaImageLabel.Text = "Area icon"; - //areaIconComboBox.Enabled = true; - //areaIconPictureBox.Visible = true; break; } } @@ -2551,13 +2545,7 @@ namespace DSPRE { if (gameFamily.Equals(gFamEnum.DP)) { foreach (ushort r in result) { HeaderDP hdp; - - ////Dynamic headers patch unsupported in DP - //if (ROMToolboxDialog.flag_DynamicHeadersPatchApplied || ROMToolboxDialog.CheckFilesDynamicHeadersPatchApplied()) { - // hdp = (HeaderDP)MapHeader.LoadFromFile(RomInfo.gameDirs[DirNames.dynamicHeaders].unpackedDir + "\\" + r.ToString("D4"), r, 0); - //} else { - hdp = (HeaderDP)MapHeader.LoadFromARM9(r); - //} + hdp = (HeaderDP)MapHeader.LoadFromARM9(r); if (hdp.locationName != 0) { headerID = hdp.ID; @@ -2947,6 +2935,16 @@ namespace DSPRE { #region Variables & Constants public const int mapEditorSquareSize = 19; + /* Trainer Editor */ + + private const int POKEMON_NUM_POSSIBLE_ABILITIES = 2; + private const int TRAINER_PARTY_POKEMON_GENDER_DEFAULT_INDEX = 0; + public const int TRAINER_PARTY_POKEMON_GENDER_MALE_INDEX = 1; + public const int TRAINER_PARTY_POKEMON_GENDER_FEMALE_INDEX = 2; + + public const int TRAINER_PARTY_POKEMON_ABILITY_SLOT1_INDEX = 0; + public const int TRAINER_PARTY_POKEMON_ABILITY_SLOT2_INDEX = 1; + /* Map Rotation vars */ public bool lRot; public bool rRot; @@ -4698,6 +4696,8 @@ namespace DSPRE { public Rectangle eventMatrixRectangle; #endregion + + #region Subroutines private void itemsSelectorHelpBtn_Click(object sender, EventArgs e) { MessageBox.Show("This selector allows you to pick a preset Ground Item script from the game data.\n" + @@ -6903,14 +6903,12 @@ namespace DSPRE { } private void InitBookmarkMargin(Scintilla textArea) { - //TextArea.SetFoldMarginColor(true, IntToColor(BACK_COLOR)); var margin = textArea.Margins[BOOKMARK_MARGIN]; margin.Width = 20; margin.Sensitive = true; margin.Type = MarginType.Symbol; margin.Mask = (1 << BOOKMARK_MARKER); - //margin.Cursor = MarginCursor.Arrow; var marker = textArea.Markers[BOOKMARK_MARKER]; marker.Symbol = MarkerSymbol.Circle; @@ -6983,20 +6981,12 @@ namespace DSPRE { #region Main Menu Commands - //private void selectLineToolStripMenuItem_Click(object sender, EventArgs e) { - // Line line = TextArea.Lines[TextArea.CurrentLine]; - // TextArea.SetSelection(line.Position + line.Length, line.Position); - //} private void scriptEditorWordWrapCheckbox_CheckedChanged(object sender, EventArgs e) { ScriptTextArea.WrapMode = scriptEditorWordWrapCheckbox.Checked ? ScintillaNET.WrapMode.Word : ScintillaNET.WrapMode.None; FunctionTextArea.WrapMode = scriptEditorWordWrapCheckbox.Checked ? ScintillaNET.WrapMode.Word : ScintillaNET.WrapMode.None; ActionTextArea.WrapMode = scriptEditorWordWrapCheckbox.Checked ? ScintillaNET.WrapMode.Word : ScintillaNET.WrapMode.None; } - //private void indentGuidesCheckbox_CheckedChanged(object sender, EventArgs e) { - // ScriptTextArea.IndentationGuides = scriptEditorIndentGuidesCheckbox.Checked ? IndentView.LookBoth : IndentView.None; - // FunctionTextArea.IndentationGuides = scriptEditorIndentGuidesCheckbox.Checked ? IndentView.LookBoth : IndentView.None; - // ActionTextArea.IndentationGuides = scriptEditorIndentGuidesCheckbox.Checked ? IndentView.LookBoth : IndentView.None; - //} + private void viewWhiteSpacesButton_Click(object sender, EventArgs e) { ScriptTextArea.ViewWhitespace = scriptEditorWhitespacesCheckbox.Checked ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible; @@ -8170,7 +8160,6 @@ namespace DSPRE { if (matchingPalette == null) { statusLabelError("Couldn't find a palette to match " + '"' + findThis + '"', severe: false); } else { - //palettesListBox.SelectedIndex = 0; palettesListBox.SelectedItem = matchingPalette; statusLabelMessage("Ready"); } @@ -8453,7 +8442,6 @@ namespace DSPRE { SaveCameraTable(DSUtils.GetOverlayPath(RomInfo.cameraTblOverlayNumber), overlayCameraTblOffset); } private void cameraEditorDataGridView_CellValidated(object sender, DataGridViewCellEventArgs e) { - //cameraEditorDataGridView.Columns[0].ValueType = typeof(int); currentCameraTable[e.RowIndex][e.ColumnIndex] = cameraEditorDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; cameraEditorDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = currentCameraTable[e.RowIndex][e.ColumnIndex]; } @@ -8538,12 +8526,18 @@ namespace DSPRE { private List partyItemsComboboxList = new List(); private List partyMovesGroupboxList = new List(); private List partyLevelUpdownList = new List(); + private List partyGenderComboBoxList = new List(); + private List partyAbilityComboBoxList = new List(); private List partyIVUpdownList = new List(); private List partyBallUpdownList = new List(); private List partyGroupboxList = new List(); private List partyPokemonPictureBoxList = new List(); private List partyPokemonItemIconList = new List(); + string[] abilityNames; + + private Tuple[] pokemonSpeciesAbilities; + TrainerFile currentTrainerFile; PaletteBase trainerPal; ImageBase trainerTile; @@ -8591,9 +8585,13 @@ namespace DSPRE { DirNames.trainerParty, DirNames.trainerGraphics, DirNames.textArchives, - DirNames.monIcons + DirNames.monIcons, + DirNames.speciesData }); + int numPokemonSpecies = Directory.GetFiles(RomInfo.gameDirs[DirNames.speciesData].unpackedDir, "*").Count(); + pokemonSpeciesAbilities = new Tuple[numPokemonSpecies]; + RomInfo.SetMonIconsPalTableAddress(); partyPokemonComboboxList.Clear(); @@ -8620,6 +8618,22 @@ namespace DSPRE { partyLevelUpdownList.Add(partyLevel5UpDown); partyLevelUpdownList.Add(partyLevel6UpDown); + partyGenderComboBoxList.Clear(); + partyGenderComboBoxList.Add(partyGender1ComboBox); + partyGenderComboBoxList.Add(partyGender2ComboBox); + partyGenderComboBoxList.Add(partyGender3ComboBox); + partyGenderComboBoxList.Add(partyGender4ComboBox); + partyGenderComboBoxList.Add(partyGender5ComboBox); + partyGenderComboBoxList.Add(partyGender6ComboBox); + + partyAbilityComboBoxList.Clear(); + partyAbilityComboBoxList.Add(partyAbility1ComboBox); + partyAbilityComboBoxList.Add(partyAbility2ComboBox); + partyAbilityComboBoxList.Add(partyAbility3ComboBox); + partyAbilityComboBoxList.Add(partyAbility4ComboBox); + partyAbilityComboBoxList.Add(partyAbility5ComboBox); + partyAbilityComboBoxList.Add(partyAbility6ComboBox); + partyIVUpdownList.Clear(); partyIVUpdownList.Add(partyIV1UpDown); partyIVUpdownList.Add(partyIV2UpDown); @@ -8683,11 +8697,15 @@ namespace DSPRE { trainerClassListBox.Items.Add("[" + i.ToString("D3") + "]" + " " + classNames[i]); } + string[] itemNames = RomInfo.GetItemNames(); string[] pokeNames = RomInfo.GetPokemonNames(); string[] moveNames = RomInfo.GetAttackNames(); + abilityNames = RomInfo.GetAbilityNames(); - foreach(Control c in trainerItemsGroupBox.Controls) { + pokemonSpeciesAbilities = getPokemonAbilities(numPokemonSpecies); + + foreach (Control c in trainerItemsGroupBox.Controls) { if (c is ComboBox) { (c as ComboBox).DataSource = new BindingSource(itemNames, string.Empty); } @@ -8774,6 +8792,30 @@ namespace DSPRE { partyIVUpdownList[i].Value = currentTrainerFile.party[i].difficulty; partyBallUpdownList[i].Value = currentTrainerFile.party[i].ballSeals; + setTrainerPartyPokemonAbilities(i); + + if (gameFamily == gFamEnum.HGSS) + { + if (currentTrainerFile.party[i].genderAndAbilityFlags.HasFlag(PartyPokemon.GenderAndAbilityFlags.FORCE_MALE)) + partyGenderComboBoxList[i].SelectedIndex = TRAINER_PARTY_POKEMON_GENDER_MALE_INDEX; + else if (currentTrainerFile.party[i].genderAndAbilityFlags.HasFlag(PartyPokemon.GenderAndAbilityFlags.FORCE_FEMALE)) + partyGenderComboBoxList[i].SelectedIndex = TRAINER_PARTY_POKEMON_GENDER_FEMALE_INDEX; + else + partyGenderComboBoxList[i].SelectedIndex = TRAINER_PARTY_POKEMON_GENDER_DEFAULT_INDEX; + + if (currentTrainerFile.party[i].genderAndAbilityFlags.HasFlag(PartyPokemon.GenderAndAbilityFlags.ABILITY_SLOT2)) + partyAbilityComboBoxList[i].SelectedIndex = TRAINER_PARTY_POKEMON_ABILITY_SLOT2_INDEX; + else + partyAbilityComboBoxList[i].SelectedIndex = TRAINER_PARTY_POKEMON_ABILITY_SLOT1_INDEX; + } + else + { + partyGenderComboBoxList[i].SelectedIndex = TRAINER_PARTY_POKEMON_GENDER_DEFAULT_INDEX; + partyGenderComboBoxList[i].Enabled = false; + } + + + if (currentTrainerFile.party[i].moves == null) { for (int j = 0; j < Party.MOVES_PER_POKE; j++) { (partyMovesGroupboxList[i].Controls[j] as ComboBox).SelectedIndex = 0; @@ -8857,30 +8899,42 @@ namespace DSPRE { } catch (FormatException) { return Properties.Resources.IconPokeball; } - // default: - //partyPokemonPictureBoxList[partyPos].Image = cb.SelectedIndex > 0 ? (Image)Properties.PokePics.ResourceManager.GetObject(FixPokenameString(PokeDatabase.System.pokeNames[(ushort)cb.SelectedIndex])) : global::DSPRE.Properties.Resources.IconPokeball; } private void partyPokemon1ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ShowPartyPokemonPic(0); + + //event handler is called before currentTrainerFile is set, need to null check to avoid null object reference + if (currentTrainerFile != null) + setTrainerPartyPokemonAbilities(0); } private void partyPokemon2ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ShowPartyPokemonPic(1); + if (currentTrainerFile != null) + setTrainerPartyPokemonAbilities(1); } private void partyPokemon3ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ShowPartyPokemonPic(2); + if (currentTrainerFile != null) + setTrainerPartyPokemonAbilities(2); } private void partyPokemon4ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ShowPartyPokemonPic(3); + if (currentTrainerFile != null) + setTrainerPartyPokemonAbilities(3); } private void partyPokemon5ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ShowPartyPokemonPic(4); + if (currentTrainerFile != null) + setTrainerPartyPokemonAbilities(4); } private void partyPokemon6ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ShowPartyPokemonPic(5); + if (currentTrainerFile != null) + setTrainerPartyPokemonAbilities(5); } private void showTrainerEditorItemPic(byte partyPos) { @@ -8928,11 +8982,6 @@ namespace DSPRE { for (int i = Math.Min(currentTrainerFile.trp.partyCount, (int)partyCountUpDown.Value); i < TrainerFile.POKE_IN_PARTY; i++) { currentTrainerFile.party[i] = new PartyPokemon(currentTrainerFile.trp.chooseItems, currentTrainerFile.trp.chooseMoves); } - - //if (!disableHandlers) { - // RefreshTrainerPartyGUI(); - // RefreshTrainerPropertiesGUI(); - //} } private void trainerMovesCheckBox_CheckedChanged(object sender, EventArgs e) { @@ -9002,7 +9051,32 @@ namespace DSPRE { currentTrainerFile.party[i].heldItem = (ushort)partyItemsComboboxList[i].SelectedIndex; } - currentTrainerFile.party[i].difficulty = (ushort)partyIVUpdownList[i].Value; + currentTrainerFile.party[i].difficulty = (byte)partyIVUpdownList[i].Value; + + /* this is a bit weird but if gender is set to anything other than default without setting the ability_slot1 flag it will be slot 2 + * so setting the force_female flag but not ability_slot1 flag means the pokemon will be female with ability set to slot 2 (or slot 1 if there is no second ability) + * in order to set gender to not default with ability 1 you must have the ability_slot1 flag set + * gender is never set using this bitfield in the base games but it does work + */ + + switch (partyGenderComboBoxList[i].SelectedIndex) + { + case TRAINER_PARTY_POKEMON_GENDER_DEFAULT_INDEX: + currentTrainerFile.party[i].genderAndAbilityFlags = PartyPokemon.GenderAndAbilityFlags.NO_FLAGS; + break; + case TRAINER_PARTY_POKEMON_GENDER_MALE_INDEX: + currentTrainerFile.party[i].genderAndAbilityFlags = PartyPokemon.GenderAndAbilityFlags.FORCE_MALE; + break; + case TRAINER_PARTY_POKEMON_GENDER_FEMALE_INDEX: + currentTrainerFile.party[i].genderAndAbilityFlags = PartyPokemon.GenderAndAbilityFlags.FORCE_FEMALE; + break; + } + + if (partyAbilityComboBoxList[i].SelectedIndex == TRAINER_PARTY_POKEMON_ABILITY_SLOT2_INDEX) + currentTrainerFile.party[i].genderAndAbilityFlags |= PartyPokemon.GenderAndAbilityFlags.ABILITY_SLOT2; + else + currentTrainerFile.party[i].genderAndAbilityFlags |= PartyPokemon.GenderAndAbilityFlags.ABILITY_SLOT1; + currentTrainerFile.party[i].ballSeals = (ushort)partyBallUpdownList[i].Value; } @@ -9244,7 +9318,6 @@ namespace DSPRE { } disableHandlers = false; - //trainerClassListBox_SelectedIndexChanged(null, null); if ( gameFamily.Equals(gFamEnum.HGSS) && tableEditorIsReady ) { pbEffectsTrainerCombobox.Items[selectedTrClass] = trainerClassListBox.Items[selectedTrClass]; for (int i = 0; i < vsTrainerEffectsList.Count; i++) { @@ -9259,6 +9332,49 @@ namespace DSPRE { private void trClassFramePreviewUpDown_ValueChanged(object sender, EventArgs e) { UpdateTrainerClassPic(trainerClassPicBox, (int)((NumericUpDown)sender).Value); } + + private Tuple[] getPokemonAbilities(int numPokemonSpecies) + { + SpeciesFile species; + var pokemonSpeciesAbilities = new Tuple[numPokemonSpecies]; + + + for (int i = 0; i < numPokemonSpecies; i++) + { + species = new SpeciesFile(new FileStream(RomInfo.gameDirs[DirNames.speciesData].unpackedDir + "\\" + i.ToString("D4"), FileMode.Open)); + pokemonSpeciesAbilities[i] = new Tuple(species.Ability1, species.Ability2); + } + + return pokemonSpeciesAbilities; + } + + private (string ability1, string ability2) getPokemonAbilityNames(int pokemonID) + { + return (abilityNames[pokemonSpeciesAbilities[pokemonID].Item1], + abilityNames[pokemonSpeciesAbilities[pokemonID].Item2]); + } + + private void setTrainerPartyPokemonAbilities(int partyPokemonPosition) + { + + (string ability1, string ability2) currentPartyPokemonAbilities = getPokemonAbilityNames(partyPokemonComboboxList[partyPokemonPosition].SelectedIndex); + partyAbilityComboBoxList[partyPokemonPosition].Items.Clear(); + partyAbilityComboBoxList[partyPokemonPosition].Items.Add(currentPartyPokemonAbilities.ability1); + + //if the name " -" is returned for ability 2 then there is no ability 2 + if (!currentPartyPokemonAbilities.ability2.Equals(" -") && gameFamily == gFamEnum.HGSS) + { + partyAbilityComboBoxList[partyPokemonPosition].Items.Add(currentPartyPokemonAbilities.ability2); + partyAbilityComboBoxList[partyPokemonPosition].Enabled = true; + } + else + { + partyAbilityComboBoxList[partyPokemonPosition].Enabled = false; + } + + partyAbilityComboBoxList[partyPokemonPosition].SelectedIndex = TRAINER_PARTY_POKEMON_ABILITY_SLOT1_INDEX; + } + #endregion #region Table Editor diff --git a/DS_Map/Main Window.resx b/DS_Map/Main Window.resx index 0c4bbdb..c59e08a 100644 --- a/DS_Map/Main Window.resx +++ b/DS_Map/Main Window.resx @@ -956,7 +956,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACM - EgAAAk1TRnQBSQFMAgEBCgEAAegBGgHoARoBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + EgAAAk1TRnQBSQFMAgEBCgEAAUgBGwFIARsBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/DS_Map/ROMFiles/TrainerFile.cs b/DS_Map/ROMFiles/TrainerFile.cs index b1a7c5a..ab1891d 100644 --- a/DS_Map/ROMFiles/TrainerFile.cs +++ b/DS_Map/ROMFiles/TrainerFile.cs @@ -1,7 +1,9 @@ -using System; +using ScintillaNET; +using System; using System.Collections; using System.IO; using System.Windows.Forms; +using static DSPRE.ROMFiles.PartyPokemon; namespace DSPRE.ROMFiles { public class PartyPokemon : RomFile { @@ -15,37 +17,39 @@ namespace DSPRE.ROMFiles { public ushort? pokeID = null; public ushort formID = 0; public ushort level = 0; - public ushort difficulty = 0; + public byte difficulty = 0; + public GenderAndAbilityFlags genderAndAbilityFlags; public ushort ballSeals = 0; public ushort? heldItem = null; public ushort[] moves = null; + + public enum GenderAndAbilityFlags + { + NO_FLAGS = 0, + FORCE_MALE = 0x1, + FORCE_FEMALE = 0x2, + ABILITY_SLOT1 = 0x10, + ABILITY_SLOT2 = 0x20 + } #endregion #region Constructor - public PartyPokemon(bool hasItems = false, bool hasMoves = false) { - UpdateItemsAndMoves(hasItems, hasMoves); + public PartyPokemon(bool chooseItems = false, bool chooseMoves = false) { + UpdateItemsAndMoves(chooseItems, chooseMoves); } - public PartyPokemon(ushort difficulty, ushort Level, ushort pokeNum, ushort ballSealConfig, ushort? heldItem = null, ushort[] moves = null) { + public PartyPokemon(byte difficulty, GenderAndAbilityFlags genderAndAbilityFlags, ushort Level, ushort pokeNum, ushort ballSealConfig, ushort? heldItem = null, ushort[] moves = null) { pokeID = pokeNum; level = Level; this.difficulty = difficulty; + this.genderAndAbilityFlags = genderAndAbilityFlags; ballSeals = ballSealConfig; this.heldItem = heldItem; this.moves = moves; } - public PartyPokemon(ushort difficulty, ushort Level, ushort pokeNum, ushort? heldItem = null, ushort[] moves = null) - { - // Simply adding a new constructor for Diamond and Pearl since they dont have ball seal config - pokeID = pokeNum; - level = Level; - this.difficulty = difficulty; - this.heldItem = heldItem; - this.moves = moves; - } - public PartyPokemon(ushort difficulty, ushort Level, ushort pokeNum, ushort formNum, ushort ballSealConfig, ushort? heldItem = null, ushort[] moves = null) : - this(difficulty, Level, pokeNum, ballSealConfig, heldItem, moves) { + public PartyPokemon(byte difficulty, GenderAndAbilityFlags genderAndAbilityFlags, ushort Level, ushort pokeNum, ushort formNum, ushort ballSealConfig, ushort? heldItem = null, ushort[] moves = null) : + this(difficulty, genderAndAbilityFlags, Level, pokeNum, ballSealConfig, heldItem, moves) { formID = formNum; } @@ -53,6 +57,7 @@ namespace DSPRE.ROMFiles { MemoryStream newData = new MemoryStream(); using (BinaryWriter writer = new BinaryWriter(newData)) { writer.Write(difficulty); + writer.Write((byte)genderAndAbilityFlags); writer.Write(level); writer.Write(pokeID ?? 0); @@ -65,16 +70,15 @@ namespace DSPRE.ROMFiles { writer.Write(move); } } - if(RomInfo.gameFamily == RomInfo.gFamEnum.HGSS || RomInfo.gameFamily == RomInfo.gFamEnum.Plat) - writer.Write(ballSeals); // Diamond and Pearl apparently dont save ball capsule data in enemy trainer pokedata!!! + writer.Write(ballSeals); } return newData.ToArray(); } - public void UpdateItemsAndMoves(bool hasItems = false, bool hasMoves = false) { - if (hasItems) { + public void UpdateItemsAndMoves(bool chooseItems = false, bool chooseMoves = false) { + if (chooseItems) { this.heldItem = 0; } - if (hasMoves) { + if (chooseMoves) { this.moves = new ushort[4]; } } @@ -118,8 +122,8 @@ namespace DSPRE.ROMFiles { trainerID = ID; using (BinaryReader reader = new BinaryReader(trainerPropertiesStream)) { byte flags = reader.ReadByte(); - chooseMoves = ((flags >> 0) & 1) != 0; - chooseItems = ((flags >> 1) & 1) != 0; + chooseMoves = (flags & 1) != 0; + chooseItems = (flags & 2) != 0; trainerClass = reader.ReadByte(); trDataUnknown = reader.ReadByte(); @@ -201,19 +205,20 @@ namespace DSPRE.ROMFiles { trp.partyCount = (byte)((flags & 28) >> 2); } - int divisor = 8; + int dividend = 8; if (trp.chooseMoves) { - divisor += Party.MOVES_PER_POKE * sizeof(ushort); + dividend += Party.MOVES_PER_POKE * sizeof(ushort); } if (trp.chooseItems) { - divisor += sizeof(ushort); + dividend += sizeof(ushort); } - int endval = Math.Min((int)(partyData.Length - 1 / divisor), trp.partyCount); + int endval = Math.Min((int)(partyData.Length - 1 / dividend), trp.partyCount); this.content = new PartyPokemon[maxPoke]; for (int i = 0; i < endval; i++) { - ushort unknown1 = reader.ReadUInt16(); + byte difficulty = reader.ReadByte(); + GenderAndAbilityFlags genderAndAbilityFlags = (GenderAndAbilityFlags)reader.ReadByte(); ushort level = reader.ReadUInt16(); ushort monFull = reader.ReadUInt16(); @@ -234,11 +239,7 @@ namespace DSPRE.ROMFiles { } } - if (RomInfo.gameFamily == RomInfo.gFamEnum.HGSS || RomInfo.gameFamily == RomInfo.gFamEnum.Plat) { - content[i] = new PartyPokemon(unknown1, level, pokemon, form_no, reader.ReadUInt16(), heldItem, moves); - } else { - content[i] = new PartyPokemon(unknown1, level, pokemon, form_no, heldItem, moves); // Diamond and Pearl apparently dont save ball capsule data in enemy trainer pokedata!!! - } + content[i] = new PartyPokemon(difficulty, genderAndAbilityFlags, level, pokemon, form_no, reader.ReadUInt16(), heldItem, moves); } for (int i = endval; i < maxPoke; i++) { content[i] = new PartyPokemon(); @@ -262,7 +263,12 @@ namespace DSPRE.ROMFiles { return "Empty"; } else { string buffer = ""; - byte nonEmptyCtr = CountNonEmptyMons(); + byte nonEmptyCtr = 0; + foreach(PartyPokemon p in this.content) { + if (!p.CheckEmpty()) { + nonEmptyCtr++; + } + } buffer += nonEmptyCtr + " Poke "; if (this.trp.chooseMoves) { buffer += ", moves "; @@ -273,18 +279,6 @@ namespace DSPRE.ROMFiles { return buffer; } } - - public byte CountNonEmptyMons() { - byte nonEmptyCtr = 0; - foreach (PartyPokemon p in this.content) { - if (!p.CheckEmpty()) { - nonEmptyCtr++; - } - } - - return nonEmptyCtr; - } - public override byte[] ToByteArray() { MemoryStream newData = new MemoryStream(); using (BinaryWriter writer = new BinaryWriter(newData)) { @@ -308,7 +302,6 @@ namespace DSPRE.ROMFiles { public class TrainerFile : RomFile { public const int POKE_IN_PARTY = 6; public static readonly string NAME_NOT_FOUND = "NAME READ ERROR"; - public static int maxNameLen = 7; #region Fields public string name; @@ -335,6 +328,7 @@ namespace DSPRE.ROMFiles { MemoryStream newData = new MemoryStream(); using (BinaryWriter writer = new BinaryWriter(newData)) { writer.Write(name); + byte[] trDat = trp.ToByteArray(); writer.Write((byte)trDat.Length); writer.Write(trDat); @@ -348,8 +342,7 @@ namespace DSPRE.ROMFiles { public void SaveToFileExplorePath(string suggestedFileName, bool showSuccessMessage = true) { SaveToFileExplorePath("Gen IV Trainer File", "trf", suggestedFileName, showSuccessMessage); - } - + } #endregion } diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index 849a898..603b4b0 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -56,6 +56,7 @@ namespace DSPRE { public static uint monIconPalTableAddress { get; private set; } public static int nullEncounterID { get; private set; } + public static int abilityNamesTextNumber { get; private set; } public static int attackNamesTextNumber { get; private set; } public static int[] pokemonNamesTextNumbers { get; private set; } public static int itemNamesTextNumber { get; private set; } @@ -109,6 +110,8 @@ namespace DSPRE { German } public enum DirNames : byte { + speciesData, + synthOverlay, dynamicHeaders, @@ -169,6 +172,7 @@ namespace DSPRE { SetHeaderTableOffset(); SetNullEncounterID(); + SetAbilityNamesTextNumber(); SetAttackNamesTextNumber(); SetPokemonNamesTextNumber(); SetItemNamesTextNumber(); @@ -759,6 +763,25 @@ namespace DSPRE { break; } } + + private void SetAbilityNamesTextNumber() + { + switch (gameFamily) + { + case gFamEnum.DP: + abilityNamesTextNumber = 552; + break; + case gFamEnum.Plat: + abilityNamesTextNumber = 610; + break; + case gFamEnum.HGSS: + abilityNamesTextNumber = 720; + break; + default: + break; + } + } + private void SetAttackNamesTextNumber() { switch (gameFamily) { case gFamEnum.DP: @@ -862,6 +885,7 @@ namespace DSPRE { return itemNames.messages.GetRange(startIndex, count == null ? itemNames.messages.Count-1 : (int)count).ToArray(); } public static string[] GetPokemonNames() => new TextArchive(pokemonNamesTextNumbers[0]).messages.ToArray(); + public static string[] GetAbilityNames() => new TextArchive(abilityNamesTextNumber).messages.ToArray(); public static string[] GetAttackNames() => new TextArchive(attackNamesTextNumber).messages.ToArray(); public int GetAreaDataCount() => Directory.GetFiles(gameDirs[DirNames.areaData].unpackedDir).Length; public int GetMapTexturesCount() => Directory.GetFiles(gameDirs[DirNames.mapTextures].unpackedDir).Length; @@ -948,6 +972,7 @@ namespace DSPRE { suffix = "_release"; packedDirsDict = new Dictionary() { + [DirNames.speciesData] = @"data\poketool\personal\personal.narc", [DirNames.synthOverlay] = @"data\data\weather_sys.narc", [DirNames.textArchives] = @"data\msgdata\msg.narc", @@ -976,6 +1001,7 @@ namespace DSPRE { break; case gFamEnum.Plat: packedDirsDict = new Dictionary() { + [DirNames.speciesData] = @"data\poketool\personal\pl_personal.narc", [DirNames.synthOverlay] = @"data\data\weather_sys.narc", [DirNames.dynamicHeaders] = @"data\debug\cb_edit\d_test.narc", @@ -1006,6 +1032,7 @@ namespace DSPRE { break; case gFamEnum.HGSS: packedDirsDict = new Dictionary() { + [DirNames.speciesData] = @"data\a\0\0\2", [DirNames.synthOverlay] = @"data\a\0\2\8", [DirNames.dynamicHeaders] = @"data\a\0\5\0",