From 31f9488cfbe54d3c4cd46b14f1a6edf067b3ed36 Mon Sep 17 00:00:00 2001 From: AdAstra-LD <76622070+AdAstra-LD@users.noreply.github.com> Date: Sun, 24 Oct 2021 22:57:59 +0200 Subject: [PATCH] Misc fixes [mostly Script Editor] [+] Fixed PokeRadar percentage labels [+] Removed Script Containers static KW [+] Script Editor now notifies when user is attempting to save an empty script [+] Script Editor got better at detecting problems with script/function/action labels [+] Improved detections of UseScripts [+] Added a few more Platinum script commands [+] Fixed ARM9 compression detection for DP roms --- DS_Map/DSUtils.cs | 2 +- DS_Map/Main Window.Designer.cs | 340 ++++++++++++++--------------- DS_Map/Main Window.cs | 58 ++--- DS_Map/Main Window.resx | 62 +++--- DS_Map/ROMFiles/ScriptCommand.cs | 10 +- DS_Map/ROMFiles/ScriptFile.cs | 127 +++++++---- DS_Map/ROMToolboxDialog.cs | 2 +- DS_Map/Resources/ScriptDatabase.cs | 3 + DS_Map/WildEditorDPPt.Designer.cs | 16 +- 9 files changed, 335 insertions(+), 285 deletions(-) diff --git a/DS_Map/DSUtils.cs b/DS_Map/DSUtils.cs index 83854f7..8cf7b3d 100644 --- a/DS_Map/DSUtils.cs +++ b/DS_Map/DSUtils.cs @@ -36,7 +36,7 @@ namespace DSPRE { return new FileInfo(RomInfo.arm9Path).Length <= 0xBC000; } public static bool CheckCompressionMark() { - return BitConverter.ToInt32(DSUtils.ARM9.ReadBytes(0xBB4, 4), 0) != 0; + return BitConverter.ToInt32( DSUtils.ARM9.ReadBytes((uint)(RomInfo.gameFamily == gFamEnum.DP ? 0xB7C : 0xBB4), 4), 0 ) != 0; } public static void EditSize(int increment) { FileStream arm = File.OpenWrite(RomInfo.arm9Path); diff --git a/DS_Map/Main Window.Designer.cs b/DS_Map/Main Window.Designer.cs index 51bbdd2..a1c2c68 100644 --- a/DS_Map/Main Window.Designer.cs +++ b/DS_Map/Main Window.Designer.cs @@ -30,7 +30,6 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainProgram)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -45,6 +44,7 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); this.mainTabControl = new System.Windows.Forms.TabControl(); this.headerEditorTabPage = new System.Windows.Forms.TabPage(); this.removeLastHeaderBTN = new System.Windows.Forms.Button(); @@ -181,8 +181,11 @@ this.matrixNameLabel = new System.Windows.Forms.Label(); this.matrixTabControl = new System.Windows.Forms.TabControl(); this.headersTabPage = new System.Windows.Forms.TabPage(); + this.headersGridView = new DSPRE.DataGridViewDoubleBuffered(); this.heightsTabPage = new System.Windows.Forms.TabPage(); + this.heightsGridView = new DSPRE.DataGridViewDoubleBuffered(); this.mapFilesTabPage = new System.Windows.Forms.TabPage(); + this.mapFilesGridView = new DSPRE.DataGridViewDoubleBuffered(); this.matrixNameTextBox = new System.Windows.Forms.TextBox(); this.heightUpDown = new System.Windows.Forms.NumericUpDown(); this.widthUpDown = new System.Windows.Forms.NumericUpDown(); @@ -809,9 +812,6 @@ this.spawnEditorToolStripButton = new System.Windows.Forms.ToolStripButton(); this.versionLabel = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.headersGridView = new DSPRE.DataGridViewDoubleBuffered(); - this.heightsGridView = new DSPRE.DataGridViewDoubleBuffered(); - this.mapFilesGridView = new DSPRE.DataGridViewDoubleBuffered(); this.mainTabControl.SuspendLayout(); this.headerEditorTabPage.SuspendLayout(); this.worldmapCoordsGroupBox.SuspendLayout(); @@ -843,8 +843,11 @@ this.matrixEditorTabPage.SuspendLayout(); this.matrixTabControl.SuspendLayout(); this.headersTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.headersGridView)).BeginInit(); this.heightsTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.heightsGridView)).BeginInit(); this.mapFilesTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.mapFilesGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.heightUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.widthUpDown)).BeginInit(); this.mapEditorTabPage.SuspendLayout(); @@ -1035,9 +1038,6 @@ this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.mainToolStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.headersGridView)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.heightsGridView)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.mapFilesGridView)).BeginInit(); this.SuspendLayout(); // // mainTabControl @@ -2660,6 +2660,59 @@ this.headersTabPage.Text = "Map Headers"; this.headersTabPage.UseVisualStyleBackColor = true; // + // headersGridView + // + this.headersGridView.AllowUserToAddRows = false; + this.headersGridView.AllowUserToDeleteRows = false; + this.headersGridView.AllowUserToResizeColumns = false; + this.headersGridView.AllowUserToResizeRows = false; + this.headersGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.Info; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.headersGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.headersGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle2.Format = "D4"; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.headersGridView.DefaultCellStyle = dataGridViewCellStyle2; + this.headersGridView.Location = new System.Drawing.Point(0, 0); + this.headersGridView.MultiSelect = false; + this.headersGridView.Name = "headersGridView"; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.headersGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3; + this.headersGridView.RowHeadersWidth = 50; + this.headersGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.headersGridView.RowsDefaultCellStyle = dataGridViewCellStyle4; + this.headersGridView.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.headersGridView.RowTemplate.Height = 18; + this.headersGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.headersGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.headersGridView.ShowCellErrors = false; + this.headersGridView.Size = new System.Drawing.Size(1032, 576); + this.headersGridView.TabIndex = 1; + this.headersGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.headersGridView_CellFormatting); + this.headersGridView.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.headersGridView_CellMouseDoubleClick); + this.headersGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.headersGridView_CellValueChanged); + this.headersGridView.SelectionChanged += new System.EventHandler(this.headersGridView_SelectionChanged); + // // heightsTabPage // this.heightsTabPage.Controls.Add(this.heightsGridView); @@ -2670,6 +2723,59 @@ this.heightsTabPage.Text = "Map Heights"; this.heightsTabPage.UseVisualStyleBackColor = true; // + // heightsGridView + // + this.heightsGridView.AllowUserToAddRows = false; + this.heightsGridView.AllowUserToDeleteRows = false; + this.heightsGridView.AllowUserToResizeColumns = false; + this.heightsGridView.AllowUserToResizeRows = false; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.heightsGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + this.heightsGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); + dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.heightsGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6; + this.heightsGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("Tahoma", 8.25F); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.Format = "D2"; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.heightsGridView.DefaultCellStyle = dataGridViewCellStyle7; + this.heightsGridView.Location = new System.Drawing.Point(0, 0); + this.heightsGridView.MultiSelect = false; + this.heightsGridView.Name = "heightsGridView"; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); + dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.heightsGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle8; + this.heightsGridView.RowHeadersWidth = 50; + this.heightsGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle9.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.heightsGridView.RowsDefaultCellStyle = dataGridViewCellStyle9; + this.heightsGridView.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.heightsGridView.RowTemplate.Height = 18; + this.heightsGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.heightsGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.heightsGridView.Size = new System.Drawing.Size(1032, 576); + this.heightsGridView.TabIndex = 2; + this.heightsGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.heightsGridView_CellFormatting); + this.heightsGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.heightsGridView_CellValueChanged); + this.heightsGridView.SelectionChanged += new System.EventHandler(this.heightsGridView_SelectionChanged); + // // mapFilesTabPage // this.mapFilesTabPage.Controls.Add(this.mapFilesGridView); @@ -2680,6 +2786,60 @@ this.mapFilesTabPage.Text = "Map Files"; this.mapFilesTabPage.UseVisualStyleBackColor = true; // + // mapFilesGridView + // + this.mapFilesGridView.AllowUserToAddRows = false; + this.mapFilesGridView.AllowUserToDeleteRows = false; + this.mapFilesGridView.AllowUserToResizeColumns = false; + this.mapFilesGridView.AllowUserToResizeRows = false; + dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.mapFilesGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; + this.mapFilesGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle11.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); + dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.mapFilesGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + this.mapFilesGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle12.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle12.Format = "D4"; + dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.mapFilesGridView.DefaultCellStyle = dataGridViewCellStyle12; + this.mapFilesGridView.Location = new System.Drawing.Point(0, 0); + this.mapFilesGridView.MultiSelect = false; + this.mapFilesGridView.Name = "mapFilesGridView"; + dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle13.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); + dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.mapFilesGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle13; + this.mapFilesGridView.RowHeadersWidth = 50; + this.mapFilesGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle14.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.mapFilesGridView.RowsDefaultCellStyle = dataGridViewCellStyle14; + this.mapFilesGridView.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.mapFilesGridView.RowTemplate.Height = 18; + this.mapFilesGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.mapFilesGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.mapFilesGridView.Size = new System.Drawing.Size(1032, 576); + this.mapFilesGridView.TabIndex = 2; + this.mapFilesGridView.CellContentDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.mapFilesGridView_CellMouseDoubleClick); + this.mapFilesGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.mapFilesGridView_CellFormatting); + this.mapFilesGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.mapFilesGridView_CellValueChanged); + this.mapFilesGridView.SelectionChanged += new System.EventHandler(this.mapFilesGridView_SelectionChanged); + // // matrixNameTextBox // this.matrixNameTextBox.Location = new System.Drawing.Point(13, 73); @@ -10107,166 +10267,6 @@ this.versionLabel.TabIndex = 9; this.versionLabel.Text = "ROM:"; // - // headersGridView - // - this.headersGridView.AllowUserToAddRows = false; - this.headersGridView.AllowUserToDeleteRows = false; - this.headersGridView.AllowUserToResizeColumns = false; - this.headersGridView.AllowUserToResizeRows = false; - this.headersGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.Info; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.headersGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; - this.headersGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle2.Format = "D4"; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.headersGridView.DefaultCellStyle = dataGridViewCellStyle2; - this.headersGridView.Location = new System.Drawing.Point(0, 0); - this.headersGridView.MultiSelect = false; - this.headersGridView.Name = "headersGridView"; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); - dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.headersGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3; - this.headersGridView.RowHeadersWidth = 50; - this.headersGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.headersGridView.RowsDefaultCellStyle = dataGridViewCellStyle4; - this.headersGridView.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.headersGridView.RowTemplate.Height = 18; - this.headersGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.headersGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; - this.headersGridView.ShowCellErrors = false; - this.headersGridView.Size = new System.Drawing.Size(1032, 576); - this.headersGridView.TabIndex = 1; - this.headersGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.headersGridView_CellFormatting); - this.headersGridView.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.headersGridView_CellMouseDoubleClick); - this.headersGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.headersGridView_CellValueChanged); - this.headersGridView.SelectionChanged += new System.EventHandler(this.headersGridView_SelectionChanged); - // - // heightsGridView - // - this.heightsGridView.AllowUserToAddRows = false; - this.heightsGridView.AllowUserToDeleteRows = false; - this.heightsGridView.AllowUserToResizeColumns = false; - this.heightsGridView.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.heightsGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; - this.heightsGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); - dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.heightsGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6; - this.heightsGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle7.Font = new System.Drawing.Font("Tahoma", 8.25F); - dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle7.Format = "D2"; - dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.heightsGridView.DefaultCellStyle = dataGridViewCellStyle7; - this.heightsGridView.Location = new System.Drawing.Point(0, 0); - this.heightsGridView.MultiSelect = false; - this.heightsGridView.Name = "heightsGridView"; - dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); - dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.heightsGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle8; - this.heightsGridView.RowHeadersWidth = 50; - this.heightsGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle9.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.heightsGridView.RowsDefaultCellStyle = dataGridViewCellStyle9; - this.heightsGridView.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.heightsGridView.RowTemplate.Height = 18; - this.heightsGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.heightsGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; - this.heightsGridView.Size = new System.Drawing.Size(1032, 576); - this.heightsGridView.TabIndex = 2; - this.heightsGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.heightsGridView_CellFormatting); - this.heightsGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.heightsGridView_CellValueChanged); - this.heightsGridView.SelectionChanged += new System.EventHandler(this.heightsGridView_SelectionChanged); - // - // mapFilesGridView - // - this.mapFilesGridView.AllowUserToAddRows = false; - this.mapFilesGridView.AllowUserToDeleteRows = false; - this.mapFilesGridView.AllowUserToResizeColumns = false; - this.mapFilesGridView.AllowUserToResizeRows = false; - dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.mapFilesGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; - this.mapFilesGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.mapFilesGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; - this.mapFilesGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle12.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle12.Format = "D4"; - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.mapFilesGridView.DefaultCellStyle = dataGridViewCellStyle12; - this.mapFilesGridView.Location = new System.Drawing.Point(0, 0); - this.mapFilesGridView.MultiSelect = false; - this.mapFilesGridView.Name = "mapFilesGridView"; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle13.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F); - dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.mapFilesGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle13; - this.mapFilesGridView.RowHeadersWidth = 50; - this.mapFilesGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.mapFilesGridView.RowsDefaultCellStyle = dataGridViewCellStyle14; - this.mapFilesGridView.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.mapFilesGridView.RowTemplate.Height = 18; - this.mapFilesGridView.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; - this.mapFilesGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; - this.mapFilesGridView.Size = new System.Drawing.Size(1032, 576); - this.mapFilesGridView.TabIndex = 2; - this.mapFilesGridView.CellContentDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.mapFilesGridView_CellMouseDoubleClick); - this.mapFilesGridView.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.mapFilesGridView_CellFormatting); - this.mapFilesGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.mapFilesGridView_CellValueChanged); - this.mapFilesGridView.SelectionChanged += new System.EventHandler(this.mapFilesGridView_SelectionChanged); - // // MainProgram // this.AllowDrop = true; @@ -10329,8 +10329,11 @@ this.matrixEditorTabPage.PerformLayout(); this.matrixTabControl.ResumeLayout(false); this.headersTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.headersGridView)).EndInit(); this.heightsTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.heightsGridView)).EndInit(); this.mapFilesTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.mapFilesGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.heightUpDown)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.widthUpDown)).EndInit(); this.mapEditorTabPage.ResumeLayout(false); @@ -10578,9 +10581,6 @@ this.statusStrip1.PerformLayout(); this.mainToolStrip.ResumeLayout(false); this.mainToolStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.headersGridView)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.heightsGridView)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.mapFilesGridView)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 6bac18e..c7f7f43 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -666,7 +666,7 @@ namespace DSPRE { MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d == DialogResult.Yes) { - DSUtils.ARM9.WriteBytes(new byte[4] { 0, 0, 0, 0 }, 0xBB4); + DSUtils.ARM9.WriteBytes( new byte[4] { 0, 0, 0, 0 }, (uint)(RomInfo.gameFamily == gFamEnum.DP ? 0xB7C : 0xBB4) ); } } @@ -5749,9 +5749,9 @@ namespace DSPRE { private Scintilla currentScintillaEditor; private SearchManager currentSearchManager; private void ScriptEditorSetClean() { - scriptsTabPage.Text = ScriptFile.ScriptKW + "s"; - functionsTabPage.Text = ScriptFile.FunctionKW + "s"; - actionsTabPage.Text = ScriptFile.ActionKW + "s"; + scriptsTabPage.Text = ScriptFile.containerTypes.Script.ToString() + "s"; + functionsTabPage.Text = ScriptFile.containerTypes.Function.ToString() + "s"; + actionsTabPage.Text = ScriptFile.containerTypes.Action.ToString() + "s"; scriptsDirty = functionsDirty = actionsDirty = false; } private void scriptEditorTabControl_TabIndexChanged(object sender, EventArgs e) { @@ -5774,7 +5774,7 @@ namespace DSPRE { secondaryKeyWords = String.Join(" ", RomInfo.ScriptComparisonOperatorsDict.Values) + " " + String.Join(" ", ScriptDatabase.specialOverworlds.Values) + - " " + ScriptFile.ScriptKW + " " + ScriptFile.FunctionKW + " " + ScriptFile.ActionKW + " " + "Overworld"; + " " + ScriptFile.containerTypes.Script.ToString() + " " + ScriptFile.containerTypes.Function.ToString() + " " + ScriptFile.containerTypes.Action.ToString() + " " + "Overworld"; secondaryKeyWords += " " + secondaryKeyWords.ToUpper() + " " + secondaryKeyWords.ToLower(); @@ -5977,17 +5977,17 @@ namespace DSPRE { private void OnTextChangedScript(object sender, EventArgs e) { ScriptTextArea.Margins[NUMBER_MARGIN].Width = ScriptTextArea.Lines.Count.ToString().Length * 13; scriptsDirty = true; - scriptsTabPage.Text = ScriptFile.ScriptKW + "s" + "*"; + scriptsTabPage.Text = ScriptFile.containerTypes.Script.ToString() + "s" + "*"; } private void OnTextChangedFunction(object sender, EventArgs e) { FunctionTextArea.Margins[NUMBER_MARGIN].Width = FunctionTextArea.Lines.Count.ToString().Length * 13; functionsDirty = true; - functionsTabPage.Text = ScriptFile.FunctionKW + "s" + "*"; + functionsTabPage.Text = ScriptFile.containerTypes.Function.ToString() + "s" + "*"; } private void OnTextChangedAction(object sender, EventArgs e) { ActionTextArea.Margins[NUMBER_MARGIN].Width = ActionTextArea.Lines.Count.ToString().Length * 13; actionsDirty = true; - actionsTabPage.Text = ScriptFile.ActionKW + "s" + "*"; + actionsTabPage.Text = ScriptFile.containerTypes.Action.ToString() + "s" + "*"; } @@ -6306,15 +6306,17 @@ namespace DSPRE { private void saveScriptFileButton_Click(object sender, EventArgs e) { /* Create new ScriptFile object */ int idToAssign = selectScriptFileComboBox.SelectedIndex; - ScriptFile userEdited = new ScriptFile(scriptLines: ScriptTextArea.Lines, FunctionTextArea.Lines, ActionTextArea.Lines, selectScriptFileComboBox.SelectedIndex); ; + ScriptFile userEdited = new ScriptFile(scriptLines: ScriptTextArea.Lines, FunctionTextArea.Lines, ActionTextArea.Lines, selectScriptFileComboBox.SelectedIndex); /* Write new scripts to file */ - if (userEdited.fileID != null) { //check if ScriptFile instance was created succesfully + if (userEdited.fileID == null) { + MessageBox.Show("This " + typeof(ScriptFile).Name + " couldn't be saved, due to a processing error.", "Can't save", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } else if (userEdited.fileID == int.MaxValue) { + MessageBox.Show("This " + typeof(ScriptFile).Name + " is couldn't be saved since it's empty.", "Can't save", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } else { //check if ScriptFile instance was created succesfully userEdited.SaveToFileDefaultDir(selectScriptFileComboBox.SelectedIndex); currentScriptFile = userEdited; ScriptEditorSetClean(); - } else { - MessageBox.Show("This " + typeof(ScriptFile).Name + " couldn't be saved, due to a processing error.", "Can't save", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } private void clearCurrentLevelScriptButton_Click(object sender, EventArgs e) { @@ -6402,11 +6404,11 @@ namespace DSPRE { ScriptFile file = new ScriptFile(i); if (scriptSearchCaseSensitiveCheckBox.Checked) { - results.AddRange(SearchInScripts(i, file.allScripts, ScriptFile.ScriptKW, (string s) => s.Contains(searchString))); - results.AddRange(SearchInScripts(i, file.allFunctions, ScriptFile.FunctionKW, (string s) => s.Contains(searchString))); + results.AddRange(SearchInScripts(i, file.allScripts, ScriptFile.containerTypes.Script.ToString(), (string s) => s.Contains(searchString))); + results.AddRange(SearchInScripts(i, file.allFunctions, ScriptFile.containerTypes.Function.ToString(), (string s) => s.Contains(searchString))); } else { - results.AddRange(SearchInScripts(i, file.allScripts, ScriptFile.ScriptKW, (string s) => s.IndexOf(searchString, StringComparison.InvariantCultureIgnoreCase) >= 0)); - results.AddRange(SearchInScripts(i, file.allFunctions, ScriptFile.FunctionKW, (string s) => s.IndexOf(searchString, StringComparison.InvariantCultureIgnoreCase) >= 0)); + results.AddRange(SearchInScripts(i, file.allScripts, ScriptFile.containerTypes.Script.ToString(), (string s) => s.IndexOf(searchString, StringComparison.InvariantCultureIgnoreCase) >= 0)); + results.AddRange(SearchInScripts(i, file.allFunctions, ScriptFile.containerTypes.Function.ToString(), (string s) => s.IndexOf(searchString, StringComparison.InvariantCultureIgnoreCase) >= 0)); } } catch { } searchProgressBar.Value = i; @@ -6444,23 +6446,23 @@ namespace DSPRE { } cmdSearched = cmdSearched.TrimEnd(); - if (split[3].StartsWith(ScriptFile.ScriptKW)) { + if (split[3].StartsWith(ScriptFile.containerTypes.Script.ToString())) { if (scriptEditorTabControl.SelectedTab != scriptsTabPage) { scriptEditorTabControl.SelectedTab = scriptsTabPage; } - scriptSearchManager.Find(true, false, ScriptFile.ScriptKW + " " + split[4].Replace(":", "")); + scriptSearchManager.Find(true, false, ScriptFile.containerTypes.Script.ToString() + " " + split[4].Replace(":", "")); scriptSearchManager.Find(true, false, cmdNameAndParams); - } else if (split[3].StartsWith(ScriptFile.FunctionKW)) { + } else if (split[3].StartsWith(ScriptFile.containerTypes.Function.ToString())) { if (scriptEditorTabControl.SelectedTab != functionsTabPage) { scriptEditorTabControl.SelectedTab = functionsTabPage; } - functionSearchManager.Find(true, false, ScriptFile.FunctionKW + " " + split[4].Replace(":", "")); + functionSearchManager.Find(true, false, ScriptFile.containerTypes.Function.ToString() + " " + split[4].Replace(":", "")); functionSearchManager.Find(true, false, cmdNameAndParams); - } else if (split[3].StartsWith(ScriptFile.ActionKW)) { + } else if (split[3].StartsWith(ScriptFile.containerTypes.Action.ToString())) { if (scriptEditorTabControl.SelectedTab != actionsTabPage) { scriptEditorTabControl.SelectedTab = actionsTabPage; } - actionSearchManager.Find(true, false, ScriptFile.ActionKW + " " + split[4].Replace(":", "")); + actionSearchManager.Find(true, false, ScriptFile.containerTypes.Action.ToString() + " " + split[4].Replace(":", "")); actionSearchManager.Find(true, false, cmdNameAndParams); } } @@ -6518,7 +6520,7 @@ namespace DSPRE { CommandContainer currentScript = currentScriptFile.allScripts[i]; /* Write header */ - string header = ScriptFile.ScriptKW + " " + (i + 1); + string header = ScriptFile.containerTypes.Script.ToString() + " " + (i + 1); buffer += header + ':' + Environment.NewLine; scriptsNavListbox.Items.Add(header); @@ -6544,7 +6546,7 @@ namespace DSPRE { CommandContainer currentFunction = currentScriptFile.allFunctions[i]; /* Write Heaader */ - string header = ScriptFile.FunctionKW + " " + (i + 1); + string header = ScriptFile.containerTypes.Function.ToString() + " " + (i + 1); buffer += header + ':' + Environment.NewLine; functionsNavListbox.Items.Add(header); @@ -6568,7 +6570,7 @@ namespace DSPRE { for (int i = 0; i < currentScriptFile.allActions.Count; i++) { ActionContainer currentAction = currentScriptFile.allActions[i]; - string header = ScriptFile.ActionKW + " " + (i + 1); + string header = ScriptFile.containerTypes.Action.ToString() + " " + (i + 1); buffer += header + ':' + Environment.NewLine; actionsNavListbox.Items.Add(header); @@ -6589,15 +6591,15 @@ namespace DSPRE { disableHandlers = false; } private void scriptsNavListbox_SelectedIndexChanged(object sender, EventArgs e) { - NavigatorGoTo((ListBox)sender, 0, scriptSearchManager, ScriptFile.ScriptKW); + NavigatorGoTo((ListBox)sender, 0, scriptSearchManager, ScriptFile.containerTypes.Script.ToString()); } private void functionsNavListbox_SelectedIndexChanged(object sender, EventArgs e) { - NavigatorGoTo((ListBox)sender, 1, functionSearchManager, ScriptFile.FunctionKW); + NavigatorGoTo((ListBox)sender, 1, functionSearchManager, ScriptFile.containerTypes.Function.ToString()); } private void actionsNavListbox_SelectedIndexChanged(object sender, EventArgs e) { - NavigatorGoTo((ListBox)sender, 2, actionSearchManager, ScriptFile.ActionKW); + NavigatorGoTo((ListBox)sender, 2, actionSearchManager, ScriptFile.containerTypes.Action.ToString()); } private void NavigatorGoTo(ListBox currentLB, int indexToSwitchTo, SearchManager entrusted, string keyword) { diff --git a/DS_Map/Main Window.resx b/DS_Map/Main Window.resx index 092750c..0924fe2 100644 --- a/DS_Map/Main Window.resx +++ b/DS_Map/Main Window.resx @@ -1958,7 +1958,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACM - EgAAAk1TRnQBSQFMAgEBCgEAAXwBFwF8ARcBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + EgAAAk1TRnQBSQFMAgEBCgEAAYwBFwGMARc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QJAfVDOCAgHprBA + 4ull8dObtgq/gtnn5UtDbaomKXak4CdSfYVItm8hOLI3EaCtVjpRre8UoUpxk7FSmR3NdqvLya+AIyH6 + EsICu5QDZNFbl0uQq2AroSh3MwHaTXcfoGDwFVKUSOKKx1rPEyMmCVG4FdjWGtlO8DgkArTbI2ESrKr9 + RII314pJQnQQ8bAKsHfOG8sj1uHnn4hwFPMmiAAB3v0kOvzoTZdT/CuAWhxuRcAnPIG7kIHJHlUbDZWS + xXn9BNw39cSLYByNENfihxDSwSLcRTHQzwS4EvjzSGuij0EjxGUSYGCR+cHbpnDAKAAQCRLsMgUzaIS4 + TMFpsAqkg0aIixeUiv8CJgH8hRtvc6Pd+TJpG4MZNEJcvKBUMIG+Rg/KOSgTYi0uwqESJ9pbgGX+hkB3 + vRuN4FDYgT14ByC4qep40k7QiPT17X3j4liXqvFCjRgF2A6Qn6AleKB5f/oTkFfLsZBvFP+X88IBJvDi + jofsgDG0V3VpEw9P/qRLrb/GB0LxVAJGenDwdPvZPDpt4+v7WPMCez1GgYy3OdNanunzTjxTtcn7ZUv0 + 1r9YNttvMYck4gmGe5sAAAAASUVORK5CYII= @@ -2358,7 +2358,7 @@ - 34 + 69 diff --git a/DS_Map/ROMFiles/ScriptCommand.cs b/DS_Map/ROMFiles/ScriptCommand.cs index 7a0a2e4..003b55e 100644 --- a/DS_Map/ROMFiles/ScriptCommand.cs +++ b/DS_Map/ROMFiles/ScriptCommand.cs @@ -53,27 +53,27 @@ namespace DSPRE.ROMFiles { switch (id) { case 0x16: // Jump case 0x1A: // Call - name += " " + FunctionKW + "#" + BitConverter.ToInt32(parametersList[0], 0).ToString("D"); + name += " " + containerTypes.Function.ToString() + "#" + BitConverter.ToInt32(parametersList[0], 0).ToString("D"); break; case 0x17: // JumpIfObjID case 0x18: // JumpIfEventID byte owid = parametersList[0][0]; name += " " + ScriptFile.OverworldFlexDecode(owid); - name += " " + FunctionKW + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); + name += " " + containerTypes.Function.ToString() + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); break; case 0x19: // JumpIfPlayerDir byte param = parametersList[0][0]; - name += " " + param.ToString("X") + " " + FunctionKW + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); + name += " " + param.ToString("X") + " " + containerTypes.Function.ToString() + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); break; case 0x1C: // JumpIf case 0x1D: // CallIf byte opcode = parametersList[0][0]; - name += " " + RomInfo.ScriptComparisonOperatorsDict[opcode] + " " + FunctionKW + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); + name += " " + RomInfo.ScriptComparisonOperatorsDict[opcode] + " " + containerTypes.Function.ToString() + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); break; case 0x5E: // Movement ushort flexID = BitConverter.ToUInt16(parametersList[0], 0); name += " " + ScriptFile.OverworldFlexDecode(flexID); - name += " " + ActionKW + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); + name += " " + containerTypes.Action.ToString() + "#" + BitConverter.ToInt32(parametersList[1], 0).ToString("D"); break; case 0x6A: // CheckOverworldPosition flexID = BitConverter.ToUInt16(parametersList[0], 0); diff --git a/DS_Map/ROMFiles/ScriptFile.cs b/DS_Map/ROMFiles/ScriptFile.cs index 901f358..4aaf8b1 100644 --- a/DS_Map/ROMFiles/ScriptFile.cs +++ b/DS_Map/ROMFiles/ScriptFile.cs @@ -15,13 +15,9 @@ namespace DSPRE.ROMFiles { public class ScriptFile: RomFile { #region Constants //this enum doesn't really make much sense now but it will, once scripts can be called and jumped to - public enum containerTypes { FUNCTION, MOVEMENT, SCRIPT }; + public enum containerTypes { Function, Action, Script }; #endregion #region Fields (3) - public static string ScriptKW = "Script"; - public static string FunctionKW = "Function"; - public static string ActionKW = "Action"; - public List allScripts = new List(); public List allFunctions = new List(); public List allActions = new List(); @@ -45,7 +41,7 @@ namespace DSPRE.ROMFiles { scrReader.BaseStream.Position -= 0x2; uint value = scrReader.ReadUInt32(); - if (value == 0) { + if (value == 0 && scriptOffsets.Count == 0) { isLevelScript = true; break; } else if (checker == 0xFD13) { @@ -58,8 +54,9 @@ namespace DSPRE.ROMFiles { } } } catch (EndOfStreamException) { - if (!isLevelScript) + if (!isLevelScript) { MessageBox.Show("Script File couldn't be read correctly.", "Unexpected EOF", MessageBoxButtons.OK, MessageBoxIcon.Error); // Now this may appear in a few level scripts that don't have a 4-byte aligned "00 00 00 00" + } } if (isLevelScript) { @@ -86,9 +83,9 @@ namespace DSPRE.ROMFiles { endScript = true; } } - allScripts.Add(new CommandContainer(current+1, containerTypes.SCRIPT, commandList: cmdList)); + allScripts.Add(new CommandContainer(current+1, containerTypes.Script, commandList: cmdList)); } else { - allScripts.Add(new CommandContainer(current+1, containerTypes.SCRIPT, useScript: index+1)); + allScripts.Add(new CommandContainer(current+1, containerTypes.Script, useScript: index+1)); } } @@ -110,9 +107,9 @@ namespace DSPRE.ROMFiles { endFunction = true; } } - allFunctions.Add(new CommandContainer(current+1, containerTypes.FUNCTION, commandList: cmdList)); + allFunctions.Add(new CommandContainer(current+1, containerTypes.Function, commandList: cmdList)); } else { - allFunctions.Add(new CommandContainer(current+1, containerTypes.FUNCTION, useScript: posInList +1)); + allFunctions.Add(new CommandContainer(current+1, containerTypes.Function, useScript: posInList +1)); } } @@ -151,26 +148,33 @@ namespace DSPRE.ROMFiles { //a script and a function Func, int, ushort?, bool> functionEndCondition = (source, x, id) => source[x].TrimEnd().Equals(RomInfo.ScriptCommandNamesDict[0x0002], StringComparison.InvariantCultureIgnoreCase) //End - || source[x].IndexOf(RomInfo.ScriptCommandNamesDict[0x0016] + " Function", StringComparison.InvariantCultureIgnoreCase) >= 0 //Jump Function_# + || source[x].IndexOf(RomInfo.ScriptCommandNamesDict[0x0016] + ' ' + containerTypes.Function.ToString(), StringComparison.InvariantCultureIgnoreCase) >= 0 //Jump Function_# || source[x].TrimEnd().Equals(RomInfo.ScriptCommandNamesDict[0x001B], StringComparison.InvariantCultureIgnoreCase) || ScriptDatabase.endCodes.Contains(id); //Return Func, int, ushort?, bool> scriptEndCondition = (source, x, id) => source[x].TrimEnd().Equals(RomInfo.ScriptCommandNamesDict[0x0002], StringComparison.InvariantCultureIgnoreCase) //End - || source[x].IndexOf(RomInfo.ScriptCommandNamesDict[0x0016] + " Function") >= 0 //Jump Function_# + || source[x].IndexOf(RomInfo.ScriptCommandNamesDict[0x0016] + ' ' + containerTypes.Function.ToString()) >= 0 //Jump Function_# || ScriptDatabase.endCodes.Contains(id); - allScripts = ReadCommandsFromLines(scriptLines, containerTypes.SCRIPT, scriptEndCondition); //Jump + whitespace - if (allScripts is null || allScripts.Count <= 0) + allScripts = ReadCommandsFromLines(scriptLines, containerTypes.Script, scriptEndCondition); //Jump + whitespace + if (allScripts is null) { return; + } + if (allScripts.Count <= 0) { + this.fileID = int.MaxValue; + return; + } - allFunctions = ReadCommandsFromLines(functionLines, containerTypes.FUNCTION, functionEndCondition); //Jump + whitespace - if (allFunctions is null) + allFunctions = ReadCommandsFromLines(functionLines, containerTypes.Function, functionEndCondition); //Jump + whitespace + if (allFunctions is null) { return; + } allActions = ReadActionsFromLines(actionLines); - if (allActions is null) + if (allActions is null) { return; + } this.fileID = fileID; } @@ -455,9 +459,9 @@ namespace DSPRE.ROMFiles { uint invokedID = BitConverter.ToUInt32(parameterList[parameterWithRelativeJump], 0); // Jump, Call if (commandID == 0x005E) - references.Add(new ScriptReference(cont.containerType, cont.manualUserID, containerTypes.MOVEMENT, invokedID, pos - 4)); + references.Add(new ScriptReference(cont.containerType, cont.manualUserID, containerTypes.Action, invokedID, pos - 4)); else { - references.Add(new ScriptReference(cont.containerType, cont.manualUserID, containerTypes.FUNCTION, invokedID, pos - 4)); + references.Add(new ScriptReference(cont.containerType, cont.manualUserID, containerTypes.Function, invokedID, pos - 4)); } } } @@ -467,17 +471,31 @@ namespace DSPRE.ROMFiles { List lineSourceL = RemoveEmptyLines(lineSource); try { int i = 0; + uint scriptNumber = 0; while (i < lineSourceL.Count) { - int positionOfScriptNumber; - if (!lineSourceL[i].Contains(':') || (positionOfScriptNumber = lineSourceL[i].IndexOfNumber()) < 0) { //Script #1 - i++; - continue; + if (scriptNumber == 0) { + int positionOfScriptNumber; + int positionOfScriptKeyword = lineSourceL[i].IndexOf(containerType.ToString(), StringComparison.InvariantCultureIgnoreCase); + + if (positionOfScriptKeyword > 0) { + MessageBox.Show("Unrecognized container keyword: \"" + lineSourceL[i] + '"', "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return null; + } else if (positionOfScriptKeyword < 0) { + i++; + continue; + } else { + if ((positionOfScriptNumber = lineSourceL[i].IndexOfNumber()) < positionOfScriptKeyword) { + MessageBox.Show("Unspecified Script/Function label.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return null; + } + } + scriptNumber = uint.Parse(lineSourceL[i++].Substring(positionOfScriptNumber).Split()[0].Replace(":", "")); } - uint scriptNumber = uint.Parse(lineSourceL[i++].Substring(positionOfScriptNumber).Split()[0].Replace(":", "")); if (lineSourceL[i].IndexOf("UseScript", StringComparison.InvariantCultureIgnoreCase) >= 0) { - int useScriptNumber = Int16.Parse(lineSourceL[i].Substring(1 + lineSourceL[i].IndexOf('#'))); + int useScriptNumber = short.Parse(lineSourceL[i].Substring(1 + lineSourceL[i].IndexOf('#'))); ls.Add(new CommandContainer(scriptNumber, containerType, useScriptNumber)); + i++; } else { /* Read script commands */ @@ -494,6 +512,7 @@ namespace DSPRE.ROMFiles { ls.Add(new CommandContainer(scriptNumber, containerType, commandList: cmdList)); } + scriptNumber = 0; } } catch (IndexOutOfRangeException) { } return ls; @@ -505,13 +524,26 @@ namespace DSPRE.ROMFiles { List lineSourceL = RemoveEmptyLines(lineSource); try { int i = 0; + uint actionNumber = 0; while (i < lineSourceL.Count) { - int positionOfActionNumber; - if (!lineSourceL[i].Contains(':') || (positionOfActionNumber = lineSourceL[i].IndexOfNumber()) < 0) { // Move on until action header is found - i++; - continue; + if (actionNumber == 0) { + int positionOfActionNumber; + int positionOfActionKeyword = lineSourceL[i].IndexOf(containerTypes.Action.ToString(), StringComparison.InvariantCultureIgnoreCase); + + if (positionOfActionKeyword > 0) { + MessageBox.Show("Unrecognized container keyword: \"" + lineSourceL[i] + '"', "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return null; + } else if (positionOfActionKeyword < 0) { + i++; + continue; + } else { + if ( (positionOfActionNumber = lineSourceL[i].IndexOfNumber()) < positionOfActionKeyword ) { + MessageBox.Show("Unspecified Action label.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return null; + } + } + actionNumber = uint.Parse(lineSourceL[i++].Substring(positionOfActionNumber).Split()[0].Replace(":", "")); } - uint actionNumber = uint.Parse(lineSourceL[i++].Substring(positionOfActionNumber).Split()[0].Replace(":", "")); List cmdList = new List(); /* Read script actions */ @@ -523,7 +555,8 @@ namespace DSPRE.ROMFiles { cmdList.Add(toAdd); } while (!lineSourceL[i++].Equals(RomInfo.ScriptActionNamesDict[0x00FE], StringComparison.InvariantCultureIgnoreCase)); - ls.Add(new ActionContainer(actionNumber, actionCommandsList: cmdList)); + ls.Add( new ActionContainer(actionNumber, actionCommandsList: cmdList) ); + actionNumber = 0; } } catch (IndexOutOfRangeException) { } return ls; @@ -531,9 +564,11 @@ namespace DSPRE.ROMFiles { private List RemoveEmptyLines(ScintillaNET.LineCollection lineSource) { List result = new List(); foreach (Line x in lineSource) { - string tr = x.Text.Trim(); - if (tr.Length > 0) { - result.Add(tr); + if (x.Length > 0) { + string tr = x.Text.Trim(); + if (tr.Length > 0) { + result.Add(tr); + } } } return result; @@ -584,8 +619,17 @@ namespace DSPRE.ROMFiles { /* If command calls a function/movement, store reference position */ AddReference(ref refList, (ushort)currentCmd.id, parameterList, (int)writer.BaseStream.Position, currentScript); } - } else { - scriptOffsets.Add((currentScript.manualUserID, scriptOffsets[currentScript.useScript - 1].offsetInFile)); // If script has UseScript, copy offset + } + } + + int scriptsCount = scriptOffsets.Count; + foreach (CommandContainer currentScript in allScripts) { + if (currentScript.useScript != -1) { + for (int i = 0; i < scriptsCount; i++) { + if (scriptOffsets[i].scriptID == currentScript.useScript) { + scriptOffsets.Add( (currentScript.manualUserID, scriptOffsets[i].offsetInFile) ); // If script has UseScript, copy offset + } + } } } @@ -630,8 +674,9 @@ namespace DSPRE.ROMFiles { /* Write script offsets to header */ writer.BaseStream.Position = 0x0; - for (int i = 0; i < scriptOffsets.Count; i++) + for (int i = 0; i < scriptOffsets.Count; i++) { writer.Write(scriptOffsets[i].offsetInFile - (uint)writer.BaseStream.Position - 0x4); + } SortedSet undeclaredFuncs = new SortedSet(); @@ -644,7 +689,7 @@ namespace DSPRE.ROMFiles { writer.BaseStream.Position = refList[i].invokedOffset; //place seek head on parameter that is supposed to store the jump address (uint actionID, uint offsetInFile) result; - if (refList[i].invokedType == containerTypes.MOVEMENT) { //isApplyMovement + if (refList[i].invokedType == containerTypes.Action) { //isApplyMovement result = actionOffsets.Find(x => x.actionID == refList[i].invokedID); if (result.Equals((0, 0))) @@ -668,7 +713,7 @@ namespace DSPRE.ROMFiles { } - //if (refList[i].callerType != containerTypes.FUNCTION || + //if (refList[i].callerType != containerTypes.Function || // (refList[i].callerType == refList[i].invokedType && refList[i].callerID == refList[i].invokedID) || // !uninvokedFuncs.Contains(refList[i].callerID)) { //remove reference if caller is a script, or if caller calls itself, or if caller is a function that's been invoked already // uninvokedFuncs.Remove(refList[i].invokedID); @@ -728,7 +773,7 @@ namespace DSPRE.ROMFiles { if (sr is null) { return false; } - if (sr.callerType == containerTypes.SCRIPT || (sr.callerType == containerTypes.FUNCTION && sr.callerID == sr.invokedID)) { + if (sr.callerType == containerTypes.Script || (sr.callerType == containerTypes.Function && sr.callerID == sr.invokedID)) { return true; } diff --git a/DS_Map/ROMToolboxDialog.cs b/DS_Map/ROMToolboxDialog.cs index 1283c47..fc3e993 100644 --- a/DS_Map/ROMToolboxDialog.cs +++ b/DS_Map/ROMToolboxDialog.cs @@ -522,7 +522,7 @@ namespace DSPRE { new ScriptCommand("Jump Function_#1") }; - itemScript.allScripts.Add(new CommandContainer((ushort)(i + 1), ScriptFile.containerTypes.SCRIPT, commandList: cmdList)); + itemScript.allScripts.Add(new CommandContainer((ushort)(i + 1), ScriptFile.containerTypes.Script, commandList: cmdList)); } itemScript.allScripts.Add(executeGive); itemScript.allFunctions[0].useScript = itemCount + 1; diff --git a/DS_Map/Resources/ScriptDatabase.cs b/DS_Map/Resources/ScriptDatabase.cs index 92a1760..a22c38e 100644 --- a/DS_Map/Resources/ScriptDatabase.cs +++ b/DS_Map/Resources/ScriptDatabase.cs @@ -1449,6 +1449,9 @@ namespace DSPRE.Resources { [0x0328] = "PortalEffect", //International release exclusive + [0x033C] = "TextItemLowercase", + [0x0346] = "TextCapitalize", + [0x0347] = "DisplayFloor" }; public static Dictionary PlatScrCmdParameters = new Dictionary() { diff --git a/DS_Map/WildEditorDPPt.Designer.cs b/DS_Map/WildEditorDPPt.Designer.cs index 01ddca5..947a516 100644 --- a/DS_Map/WildEditorDPPt.Designer.cs +++ b/DS_Map/WildEditorDPPt.Designer.cs @@ -459,11 +459,11 @@ // label42 // this.label42.AutoSize = true; - this.label42.Location = new System.Drawing.Point(535, 32); + this.label42.Location = new System.Drawing.Point(543, 32); this.label42.Name = "label42"; - this.label42.Size = new System.Drawing.Size(27, 13); + this.label42.Size = new System.Drawing.Size(21, 13); this.label42.TabIndex = 174; - this.label42.Text = "10%"; + this.label42.Text = "1%"; // // radarFourthComboBox // @@ -477,11 +477,11 @@ // label41 // this.label41.AutoSize = true; - this.label41.Location = new System.Drawing.Point(362, 32); + this.label41.Location = new System.Drawing.Point(370, 32); this.label41.Name = "label41"; - this.label41.Size = new System.Drawing.Size(27, 13); + this.label41.Size = new System.Drawing.Size(21, 13); this.label41.TabIndex = 172; - this.label41.Text = "10%"; + this.label41.Text = "1%"; // // radarThirdComboBox // @@ -495,7 +495,7 @@ // label40 // this.label40.AutoSize = true; - this.label40.Location = new System.Drawing.Point(188, 32); + this.label40.Location = new System.Drawing.Point(192, 32); this.label40.Name = "label40"; this.label40.Size = new System.Drawing.Size(27, 13); this.label40.TabIndex = 170; @@ -513,7 +513,7 @@ // label34 // this.label34.AutoSize = true; - this.label34.Location = new System.Drawing.Point(11, 32); + this.label34.Location = new System.Drawing.Point(15, 32); this.label34.Name = "label34"; this.label34.Size = new System.Drawing.Size(27, 13); this.label34.TabIndex = 168;