From 6cdfea8abc32bfae1799a1d1c7a74f8a4ac97cbb Mon Sep 17 00:00:00 2001 From: AdAstra-LD Date: Mon, 8 Feb 2021 12:03:20 +0100 Subject: [PATCH] fixed bugs with bgs importer also minor ui changes [command database window] --- DS_Map/Main Window.cs | 1 + DS_Map/ROMFiles/MapFile.cs | 10 +- DS_Map/Resources/CommandsDatabase.Designer.cs | 108 +++++++++--------- DS_Map/Resources/CommandsDatabase.cs | 1 - DS_Map/Resources/CommandsDatabase.resx | 12 -- 5 files changed, 59 insertions(+), 73 deletions(-) diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 97b49b9..bdf58f1 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -3643,6 +3643,7 @@ namespace DSPRE { currentMapFile.ImportSoundPlates(new FileStream(it.FileName, FileMode.Open)); MessageBox.Show("BackGround Sound data imported successfully!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); + BGSSizeTXT.Text = currentMapFile.bgs.Length.ToString() + "B"; } private void soundPlatesExportButton_Click(object sender, EventArgs e) { diff --git a/DS_Map/ROMFiles/MapFile.cs b/DS_Map/ROMFiles/MapFile.cs index e20c8f0..0354c41 100644 --- a/DS_Map/ROMFiles/MapFile.cs +++ b/DS_Map/ROMFiles/MapFile.cs @@ -73,10 +73,10 @@ namespace DSPRE.ROMFiles { MessageBox.Show("The header section of this map's BackGround Sound data is corrupted.", "BGS Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - ushort bgsSectionLength = reader.ReadUInt16(); + ushort bgsDataLength = reader.ReadUInt16(); - reader.BaseStream.Position -= 4; - ImportSoundPlates(new MemoryStream(reader.ReadBytes(bgsSectionLength + 4))); + reader.BaseStream.Position -= 4; //go back so that the signature "1234" + size can be read and stored + ImportSoundPlates(new MemoryStream(reader.ReadBytes(bgsDataLength + 4))); } /* Read permission data */ @@ -213,9 +213,7 @@ namespace DSPRE.ROMFiles { writer.Write(bdhc.Length); /* Write soundplate section for HG/SS */ - if (gameVersion == "HG" || gameVersion == "SS") { - writer.Write((ushort)0x1234); - writer.Write((ushort)bgs.Length); + if (gameVersion == "HG" || gameVersion == "SS") { writer.Write(bgs); } diff --git a/DS_Map/Resources/CommandsDatabase.Designer.cs b/DS_Map/Resources/CommandsDatabase.Designer.cs index 169f6e4..206bf24 100644 --- a/DS_Map/Resources/CommandsDatabase.Designer.cs +++ b/DS_Map/Resources/CommandsDatabase.Designer.cs @@ -24,12 +24,8 @@ namespace DSPRE.Resources { /// the contents of this method with the code editor. /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.scriptcmdDataGridView = new System.Windows.Forms.DataGridView(); - this.CommandID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.CommandName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ParamsCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Params = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.cmdSearchTextBox = new System.Windows.Forms.TextBox(); this.startSearchButton = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); @@ -37,6 +33,10 @@ namespace DSPRE.Resources { this.matchCB = new System.Windows.Forms.RadioButton(); this.containsCB = new System.Windows.Forms.RadioButton(); this.startsWithCB = new System.Windows.Forms.RadioButton(); + this.CommandID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.CommandName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ParamsCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Params = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.scriptcmdDataGridView)).BeginInit(); this.criteriaGroupBox.SuspendLayout(); this.SuspendLayout(); @@ -58,49 +58,6 @@ namespace DSPRE.Resources { this.scriptcmdDataGridView.Size = new System.Drawing.Size(501, 602); this.scriptcmdDataGridView.TabIndex = 0; // - // CommandID - // - this.CommandID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - dataGridViewCellStyle3.Format = "X4"; - this.CommandID.DefaultCellStyle = dataGridViewCellStyle3; - this.CommandID.FillWeight = 30F; - this.CommandID.HeaderText = "Command ID"; - this.CommandID.MaxInputLength = 10; - this.CommandID.Name = "CommandID"; - this.CommandID.ReadOnly = true; - this.CommandID.Width = 70; - // - // CommandName - // - this.CommandName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; - this.CommandName.FillWeight = 60F; - this.CommandName.HeaderText = "Command Name"; - this.CommandName.MaxInputLength = 200; - this.CommandName.MinimumWidth = 90; - this.CommandName.Name = "CommandName"; - this.CommandName.ReadOnly = true; - this.CommandName.Width = 101; - // - // ParamsCount - // - this.ParamsCount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.ParamsCount.FillWeight = 110F; - this.ParamsCount.HeaderText = "Parameter Count"; - this.ParamsCount.MaxInputLength = 10; - this.ParamsCount.MinimumWidth = 20; - this.ParamsCount.Name = "ParamsCount"; - this.ParamsCount.ReadOnly = true; - // - // Params - // - this.Params.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.Params.FillWeight = 190F; - this.Params.HeaderText = "Parameters"; - this.Params.MaxInputLength = 200; - this.Params.MinimumWidth = 85; - this.Params.Name = "Params"; - this.Params.ReadOnly = true; - // // cmdSearchTextBox // this.cmdSearchTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); @@ -180,7 +137,50 @@ namespace DSPRE.Resources { this.startsWithCB.Text = "Starts with"; this.startsWithCB.UseVisualStyleBackColor = true; // - // ScriptCommands + // CommandID + // + this.CommandID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + dataGridViewCellStyle1.Format = "X4"; + this.CommandID.DefaultCellStyle = dataGridViewCellStyle1; + this.CommandID.FillWeight = 30F; + this.CommandID.HeaderText = "Command ID"; + this.CommandID.MaxInputLength = 10; + this.CommandID.Name = "CommandID"; + this.CommandID.ReadOnly = true; + this.CommandID.Width = 70; + // + // CommandName + // + this.CommandName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.CommandName.FillWeight = 60F; + this.CommandName.HeaderText = "Command Name"; + this.CommandName.MaxInputLength = 200; + this.CommandName.MinimumWidth = 90; + this.CommandName.Name = "CommandName"; + this.CommandName.ReadOnly = true; + this.CommandName.Width = 101; + // + // ParamsCount + // + this.ParamsCount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ParamsCount.FillWeight = 90F; + this.ParamsCount.HeaderText = "Parameter Count"; + this.ParamsCount.MaxInputLength = 10; + this.ParamsCount.MinimumWidth = 20; + this.ParamsCount.Name = "ParamsCount"; + this.ParamsCount.ReadOnly = true; + // + // Params + // + this.Params.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Params.FillWeight = 190F; + this.Params.HeaderText = "Parameters"; + this.Params.MaxInputLength = 200; + this.Params.MinimumWidth = 85; + this.Params.Name = "Params"; + this.Params.ReadOnly = true; + // + // CommandsDatabase // this.AutoSize = true; this.ClientSize = new System.Drawing.Size(536, 676); @@ -190,7 +190,7 @@ namespace DSPRE.Resources { this.Controls.Add(this.cmdSearchTextBox); this.Controls.Add(this.scriptcmdDataGridView); this.DoubleBuffered = true; - this.Name = "ScriptCommands"; + this.Name = "CommandsDatabase"; this.Text = "Script Commands Database"; ((System.ComponentModel.ISupportInitialize)(this.scriptcmdDataGridView)).EndInit(); this.criteriaGroupBox.ResumeLayout(false); @@ -206,13 +206,13 @@ namespace DSPRE.Resources { private System.Windows.Forms.TextBox cmdSearchTextBox; private System.Windows.Forms.Button startSearchButton; private System.Windows.Forms.Label label1; - private System.Windows.Forms.DataGridViewTextBoxColumn CommandID; - private System.Windows.Forms.DataGridViewTextBoxColumn CommandName; - private System.Windows.Forms.DataGridViewTextBoxColumn ParamsCount; - private System.Windows.Forms.DataGridViewTextBoxColumn Params; private System.Windows.Forms.GroupBox criteriaGroupBox; private System.Windows.Forms.RadioButton matchCB; private System.Windows.Forms.RadioButton containsCB; private System.Windows.Forms.RadioButton startsWithCB; + private System.Windows.Forms.DataGridViewTextBoxColumn CommandID; + private System.Windows.Forms.DataGridViewTextBoxColumn CommandName; + private System.Windows.Forms.DataGridViewTextBoxColumn ParamsCount; + private System.Windows.Forms.DataGridViewTextBoxColumn Params; } } \ No newline at end of file diff --git a/DS_Map/Resources/CommandsDatabase.cs b/DS_Map/Resources/CommandsDatabase.cs index fa35bf2..88334b0 100644 --- a/DS_Map/Resources/CommandsDatabase.cs +++ b/DS_Map/Resources/CommandsDatabase.cs @@ -84,6 +84,5 @@ namespace DSPRE.Resources { startSearchButton_Click(null, null); } } - } } diff --git a/DS_Map/Resources/CommandsDatabase.resx b/DS_Map/Resources/CommandsDatabase.resx index d941c23..8e66095 100644 --- a/DS_Map/Resources/CommandsDatabase.resx +++ b/DS_Map/Resources/CommandsDatabase.resx @@ -129,18 +129,6 @@ True - - True - - - True - - - True - - - True - 35