Restructured script stuff so it can be released for 1.13

This commit is contained in:
Mixone-FinallyHere 2025-06-09 15:28:18 +02:00
parent 058d0da38c
commit 1dd28e90c5
14 changed files with 1804 additions and 937 deletions

View File

@ -280,14 +280,16 @@
<Compile Include="ROMFiles\SafariZoneEncounterFile.cs" />
<Compile Include="ROMFiles\SafariZoneEncounterGroup.cs" />
<Compile Include="ROMFiles\SafariZoneObjectRequirement.cs" />
<Compile Include="ROMFiles\ScriptActionContainer.cs" />
<Compile Include="ROMFiles\ScriptCommandContainer.cs" />
<Compile Include="ROMFiles\ScriptFile.cs" />
<Compile Include="Script\LevelScriptTrigger.cs" />
<Compile Include="Script\MapScreenLoadTrigger.cs" />
<Compile Include="Script\ScriptAction.cs" />
<Compile Include="ROMFiles\LevelScriptTrigger.cs" />
<Compile Include="ROMFiles\MapScreenLoadTrigger.cs" />
<Compile Include="ROMFiles\ScriptAction.cs" />
<Compile Include="Script\ScriptCommandPosition.cs" />
<Compile Include="Script\ScriptLabeledSection.cs" />
<Compile Include="Script\ScriptParameter.cs" />
<Compile Include="Script\ScriptReference.cs" />
<Compile Include="ROMFiles\ScriptReference.cs" />
<Compile Include="ROMFiles\SpeciesFile.cs" />
<Compile Include="ROMFiles\TrainerFile.cs" />
<Compile Include="PatchToolboxDialog.cs">
@ -303,7 +305,7 @@
<DependentUpon>BuildingEditor.cs</DependentUpon>
</Compile>
<Compile Include="RomInfo.cs" />
<Compile Include="Script\ScriptCommand.cs" />
<Compile Include="ROMFiles\ScriptCommand.cs" />
<Compile Include="ScintillaUtils\HotKeyManager.cs" />
<Compile Include="ScintillaUtils\ScriptTooltip.cs">
<SubType>Form</SubType>
@ -312,7 +314,7 @@
<DependentUpon>ScriptTooltip.cs</DependentUpon>
</Compile>
<Compile Include="ScintillaUtils\SearchManager.cs" />
<Compile Include="Script\VariableValueTrigger.cs" />
<Compile Include="ROMFiles\VariableValueTrigger.cs" />
<Compile Include="Settings.cs" />
<Compile Include="SettingsWindow.cs">
<SubType>Form</SubType>

View File

@ -31,12 +31,28 @@ namespace DSPRE.Editors
{
this.selectScriptFileComboBox = new System.Windows.Forms.ComboBox();
this.label5 = new System.Windows.Forms.Label();
this.scriptEditorTabControl = new System.Windows.Forms.TabControl();
this.scriptsTabPage = new System.Windows.Forms.TabPage();
this.PanelSearchScripts = new System.Windows.Forms.Panel();
this.BtnNextFindScript = new System.Windows.Forms.Button();
this.BtnPrevFindScript = new System.Windows.Forms.Button();
this.BtnCloseFindScript = new System.Windows.Forms.Button();
this.panelFindScriptTextBox = new System.Windows.Forms.TextBox();
this.scintillaScriptsPanel = new System.Windows.Forms.Panel();
this.functionsTabPage = new System.Windows.Forms.TabPage();
this.PanelSearchFunctions = new System.Windows.Forms.Panel();
this.BtnNextFindFunc = new System.Windows.Forms.Button();
this.BtnPrevFindFunc = new System.Windows.Forms.Button();
this.BtnCloseFindFunc = new System.Windows.Forms.Button();
this.panelFindFunctionTextBox = new System.Windows.Forms.TextBox();
this.scintillaFunctionsPanel = new System.Windows.Forms.Panel();
this.actionsTabPage = new System.Windows.Forms.TabPage();
this.PanelSearchActions = new System.Windows.Forms.Panel();
this.BtnNextFindActions = new System.Windows.Forms.Button();
this.BtnPrevFindActions = new System.Windows.Forms.Button();
this.BtnCloseFindActions = new System.Windows.Forms.Button();
this.panelFindActionTextBox = new System.Windows.Forms.TextBox();
this.scintillaActionsPanel = new System.Windows.Forms.Panel();
this.addScriptFileButton = new System.Windows.Forms.Button();
this.removeScriptFileButton = new System.Windows.Forms.Button();
this.saveScriptFileButton = new System.Windows.Forms.Button();
@ -72,8 +88,13 @@ namespace DSPRE.Editors
this.scriptEditorNumberFormatHex = new System.Windows.Forms.RadioButton();
this.viewLevelScriptButton = new System.Windows.Forms.Button();
this.locateCurrentScriptFile = new System.Windows.Forms.Button();
this.scriptEditorTabControl.SuspendLayout();
this.scriptsTabPage.SuspendLayout();
this.PanelSearchScripts.SuspendLayout();
this.scintillaScriptsPanel.SuspendLayout();
this.functionsTabPage.SuspendLayout();
this.PanelSearchFunctions.SuspendLayout();
this.actionsTabPage.SuspendLayout();
this.PanelSearchActions.SuspendLayout();
this.groupBox8.SuspendLayout();
this.groupBox24.SuspendLayout();
this.ScriptNavigatorTabControl.SuspendLayout();
@ -102,6 +123,31 @@ namespace DSPRE.Editors
this.label5.TabIndex = 1;
this.label5.Text = "Script File";
//
// scriptEditorTabControl
//
this.scriptEditorTabControl.Controls.Add(this.scriptsTabPage);
this.scriptEditorTabControl.Controls.Add(this.functionsTabPage);
this.scriptEditorTabControl.Controls.Add(this.actionsTabPage);
this.scriptEditorTabControl.Location = new System.Drawing.Point(481, 22);
this.scriptEditorTabControl.Name = "scriptEditorTabControl";
this.scriptEditorTabControl.SelectedIndex = 0;
this.scriptEditorTabControl.Size = new System.Drawing.Size(692, 591);
this.scriptEditorTabControl.TabIndex = 18;
this.scriptEditorTabControl.SelectedIndexChanged += new System.EventHandler(this.scriptEditorTabControl_TabIndexChanged);
//
// scriptsTabPage
//
this.scriptsTabPage.Controls.Add(this.PanelSearchScripts);
this.scriptsTabPage.Controls.Add(this.scintillaScriptsPanel);
this.scriptsTabPage.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.scriptsTabPage.Location = new System.Drawing.Point(4, 22);
this.scriptsTabPage.Name = "scriptsTabPage";
this.scriptsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.scriptsTabPage.Size = new System.Drawing.Size(684, 565);
this.scriptsTabPage.TabIndex = 0;
this.scriptsTabPage.Text = "Scripts";
this.scriptsTabPage.UseVisualStyleBackColor = true;
//
// PanelSearchScripts
//
this.PanelSearchScripts.BackColor = System.Drawing.Color.White;
@ -110,7 +156,7 @@ namespace DSPRE.Editors
this.PanelSearchScripts.Controls.Add(this.BtnPrevFindScript);
this.PanelSearchScripts.Controls.Add(this.BtnCloseFindScript);
this.PanelSearchScripts.Controls.Add(this.panelFindScriptTextBox);
this.PanelSearchScripts.Location = new System.Drawing.Point(383, 3);
this.PanelSearchScripts.Location = new System.Drawing.Point(386, 3);
this.PanelSearchScripts.Name = "PanelSearchScripts";
this.PanelSearchScripts.Size = new System.Drawing.Size(292, 40);
this.PanelSearchScripts.TabIndex = 14;
@ -172,13 +218,193 @@ namespace DSPRE.Editors
//
// scintillaScriptsPanel
//
this.scintillaScriptsPanel.Controls.Add(this.PanelSearchScripts);
this.scintillaScriptsPanel.Location = new System.Drawing.Point(483, 50);
this.scintillaScriptsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.scintillaScriptsPanel.Location = new System.Drawing.Point(3, 3);
this.scintillaScriptsPanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.scintillaScriptsPanel.Name = "scintillaScriptsPanel";
this.scintillaScriptsPanel.Size = new System.Drawing.Size(678, 559);
this.scintillaScriptsPanel.TabIndex = 19;
//
// functionsTabPage
//
this.functionsTabPage.Controls.Add(this.PanelSearchFunctions);
this.functionsTabPage.Controls.Add(this.scintillaFunctionsPanel);
this.functionsTabPage.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.functionsTabPage.Location = new System.Drawing.Point(4, 22);
this.functionsTabPage.Name = "functionsTabPage";
this.functionsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.functionsTabPage.Size = new System.Drawing.Size(684, 565);
this.functionsTabPage.TabIndex = 1;
this.functionsTabPage.Text = "Functions";
this.functionsTabPage.UseVisualStyleBackColor = true;
//
// PanelSearchFunctions
//
this.PanelSearchFunctions.BackColor = System.Drawing.Color.White;
this.PanelSearchFunctions.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PanelSearchFunctions.Controls.Add(this.BtnNextFindFunc);
this.PanelSearchFunctions.Controls.Add(this.BtnPrevFindFunc);
this.PanelSearchFunctions.Controls.Add(this.BtnCloseFindFunc);
this.PanelSearchFunctions.Controls.Add(this.panelFindFunctionTextBox);
this.PanelSearchFunctions.Location = new System.Drawing.Point(386, 3);
this.PanelSearchFunctions.Name = "PanelSearchFunctions";
this.PanelSearchFunctions.Size = new System.Drawing.Size(292, 40);
this.PanelSearchFunctions.TabIndex = 16;
this.PanelSearchFunctions.Visible = false;
//
// BtnNextFindFunc
//
this.BtnNextFindFunc.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnNextFindFunc.ForeColor = System.Drawing.Color.White;
this.BtnNextFindFunc.Image = global::DSPRE.Properties.Resources.arrowdown;
this.BtnNextFindFunc.Location = new System.Drawing.Point(233, 4);
this.BtnNextFindFunc.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.BtnNextFindFunc.Name = "BtnNextFindFunc";
this.BtnNextFindFunc.Size = new System.Drawing.Size(25, 30);
this.BtnNextFindFunc.TabIndex = 36;
this.BtnNextFindFunc.Tag = "Find next (Enter)";
this.BtnNextFindFunc.UseVisualStyleBackColor = true;
this.BtnNextFindFunc.Click += new System.EventHandler(this.BtnNextFindFunc_Click);
//
// BtnPrevFindFunc
//
this.BtnPrevFindFunc.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnPrevFindFunc.ForeColor = System.Drawing.Color.White;
this.BtnPrevFindFunc.Image = global::DSPRE.Properties.Resources.arrowup;
this.BtnPrevFindFunc.Location = new System.Drawing.Point(205, 4);
this.BtnPrevFindFunc.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.BtnPrevFindFunc.Name = "BtnPrevFindFunc";
this.BtnPrevFindFunc.Size = new System.Drawing.Size(25, 30);
this.BtnPrevFindFunc.TabIndex = 35;
this.BtnPrevFindFunc.Tag = "Find previous (Shift+Enter)";
this.BtnPrevFindFunc.UseVisualStyleBackColor = true;
this.BtnPrevFindFunc.Click += new System.EventHandler(this.BtnPrevFindFunc_Click);
//
// BtnCloseFindFunc
//
this.BtnCloseFindFunc.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnCloseFindFunc.ForeColor = System.Drawing.Color.White;
this.BtnCloseFindFunc.Image = global::DSPRE.Properties.Resources.Cross;
this.BtnCloseFindFunc.Location = new System.Drawing.Point(261, 4);
this.BtnCloseFindFunc.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.BtnCloseFindFunc.Name = "BtnCloseFindFunc";
this.BtnCloseFindFunc.Size = new System.Drawing.Size(25, 30);
this.BtnCloseFindFunc.TabIndex = 37;
this.BtnCloseFindFunc.Tag = "Close (Esc)";
this.BtnCloseFindFunc.UseVisualStyleBackColor = true;
this.BtnCloseFindFunc.Click += new System.EventHandler(this.BtnCloseFindFunc_Click);
//
// panelFindFunctionTextBox
//
this.panelFindFunctionTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.panelFindFunctionTextBox.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.panelFindFunctionTextBox.Location = new System.Drawing.Point(10, 6);
this.panelFindFunctionTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panelFindFunctionTextBox.Name = "panelFindFunctionTextBox";
this.panelFindFunctionTextBox.Size = new System.Drawing.Size(189, 25);
this.panelFindFunctionTextBox.TabIndex = 34;
this.panelFindFunctionTextBox.TextChanged += new System.EventHandler(this.panelFindFunctionTextBox_TextChanged);
this.panelFindFunctionTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.functionTxtFind_KeyDown);
//
// scintillaFunctionsPanel
//
this.scintillaFunctionsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.scintillaFunctionsPanel.Location = new System.Drawing.Point(3, 3);
this.scintillaFunctionsPanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.scintillaFunctionsPanel.Name = "scintillaFunctionsPanel";
this.scintillaFunctionsPanel.Size = new System.Drawing.Size(678, 559);
this.scintillaFunctionsPanel.TabIndex = 20;
//
// actionsTabPage
//
this.actionsTabPage.Controls.Add(this.PanelSearchActions);
this.actionsTabPage.Controls.Add(this.scintillaActionsPanel);
this.actionsTabPage.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.actionsTabPage.Location = new System.Drawing.Point(4, 22);
this.actionsTabPage.Name = "actionsTabPage";
this.actionsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.actionsTabPage.Size = new System.Drawing.Size(684, 565);
this.actionsTabPage.TabIndex = 2;
this.actionsTabPage.Text = "Actions";
this.actionsTabPage.UseVisualStyleBackColor = true;
//
// PanelSearchActions
//
this.PanelSearchActions.BackColor = System.Drawing.Color.White;
this.PanelSearchActions.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.PanelSearchActions.Controls.Add(this.BtnNextFindActions);
this.PanelSearchActions.Controls.Add(this.BtnPrevFindActions);
this.PanelSearchActions.Controls.Add(this.BtnCloseFindActions);
this.PanelSearchActions.Controls.Add(this.panelFindActionTextBox);
this.PanelSearchActions.Location = new System.Drawing.Point(386, 3);
this.PanelSearchActions.Name = "PanelSearchActions";
this.PanelSearchActions.Size = new System.Drawing.Size(292, 40);
this.PanelSearchActions.TabIndex = 16;
this.PanelSearchActions.Visible = false;
//
// BtnNextFindActions
//
this.BtnNextFindActions.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnNextFindActions.ForeColor = System.Drawing.Color.White;
this.BtnNextFindActions.Image = global::DSPRE.Properties.Resources.arrowdown;
this.BtnNextFindActions.Location = new System.Drawing.Point(233, 4);
this.BtnNextFindActions.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.BtnNextFindActions.Name = "BtnNextFindActions";
this.BtnNextFindActions.Size = new System.Drawing.Size(25, 30);
this.BtnNextFindActions.TabIndex = 40;
this.BtnNextFindActions.Tag = "Find next (Enter)";
this.BtnNextFindActions.UseVisualStyleBackColor = true;
this.BtnNextFindActions.Click += new System.EventHandler(this.BtnNextFindActions_Click);
//
// BtnPrevFindActions
//
this.BtnPrevFindActions.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnPrevFindActions.ForeColor = System.Drawing.Color.White;
this.BtnPrevFindActions.Image = global::DSPRE.Properties.Resources.arrowup;
this.BtnPrevFindActions.Location = new System.Drawing.Point(205, 4);
this.BtnPrevFindActions.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.BtnPrevFindActions.Name = "BtnPrevFindActions";
this.BtnPrevFindActions.Size = new System.Drawing.Size(25, 30);
this.BtnPrevFindActions.TabIndex = 39;
this.BtnPrevFindActions.Tag = "Find previous (Shift+Enter)";
this.BtnPrevFindActions.UseVisualStyleBackColor = true;
this.BtnPrevFindActions.Click += new System.EventHandler(this.BtnPrevFindActions_Click);
//
// BtnCloseFindActions
//
this.BtnCloseFindActions.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnCloseFindActions.ForeColor = System.Drawing.Color.White;
this.BtnCloseFindActions.Image = global::DSPRE.Properties.Resources.Cross;
this.BtnCloseFindActions.Location = new System.Drawing.Point(261, 4);
this.BtnCloseFindActions.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.BtnCloseFindActions.Name = "BtnCloseFindActions";
this.BtnCloseFindActions.Size = new System.Drawing.Size(25, 30);
this.BtnCloseFindActions.TabIndex = 41;
this.BtnCloseFindActions.Tag = "Close (Esc)";
this.BtnCloseFindActions.UseVisualStyleBackColor = true;
this.BtnCloseFindActions.Click += new System.EventHandler(this.BtnCloseFindActions_Click);
//
// panelFindActionTextBox
//
this.panelFindActionTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.panelFindActionTextBox.Font = new System.Drawing.Font("Segoe UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.panelFindActionTextBox.Location = new System.Drawing.Point(10, 6);
this.panelFindActionTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panelFindActionTextBox.Name = "panelFindActionTextBox";
this.panelFindActionTextBox.Size = new System.Drawing.Size(189, 25);
this.panelFindActionTextBox.TabIndex = 38;
this.panelFindActionTextBox.TextChanged += new System.EventHandler(this.panelFindActionTextBox_TextChanged);
this.panelFindActionTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.actionTxtFind_KeyDown);
//
// scintillaActionsPanel
//
this.scintillaActionsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.scintillaActionsPanel.Location = new System.Drawing.Point(3, 3);
this.scintillaActionsPanel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.scintillaActionsPanel.Name = "scintillaActionsPanel";
this.scintillaActionsPanel.Size = new System.Drawing.Size(678, 559);
this.scintillaActionsPanel.TabIndex = 21;
//
// addScriptFileButton
//
this.addScriptFileButton.Image = global::DSPRE.Properties.Resources.addIcon;
@ -582,7 +808,6 @@ namespace DSPRE.Editors
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.scintillaScriptsPanel);
this.Controls.Add(this.locateCurrentScriptFile);
this.Controls.Add(this.groupBox24);
this.Controls.Add(this.viewLevelScriptButton);
@ -600,11 +825,19 @@ namespace DSPRE.Editors
this.Controls.Add(this.exportScriptFileButton);
this.Controls.Add(this.importScriptFileButton);
this.Controls.Add(this.groupBox8);
this.Controls.Add(this.scriptEditorTabControl);
this.Name = "ScriptEditor";
this.Size = new System.Drawing.Size(1177, 735);
this.scriptEditorTabControl.ResumeLayout(false);
this.scriptsTabPage.ResumeLayout(false);
this.PanelSearchScripts.ResumeLayout(false);
this.PanelSearchScripts.PerformLayout();
this.scintillaScriptsPanel.ResumeLayout(false);
this.functionsTabPage.ResumeLayout(false);
this.PanelSearchFunctions.ResumeLayout(false);
this.PanelSearchFunctions.PerformLayout();
this.actionsTabPage.ResumeLayout(false);
this.PanelSearchActions.ResumeLayout(false);
this.PanelSearchActions.PerformLayout();
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
this.groupBox24.ResumeLayout(false);
@ -625,12 +858,28 @@ namespace DSPRE.Editors
public System.Windows.Forms.ComboBox selectScriptFileComboBox;
private System.Windows.Forms.Label label5;
public System.Windows.Forms.TabControl scriptEditorTabControl;
private System.Windows.Forms.TabPage scriptsTabPage;
private System.Windows.Forms.Panel PanelSearchScripts;
private System.Windows.Forms.Button BtnNextFindScript;
private System.Windows.Forms.Button BtnPrevFindScript;
private System.Windows.Forms.Button BtnCloseFindScript;
private System.Windows.Forms.TextBox panelFindScriptTextBox;
private System.Windows.Forms.Panel scintillaScriptsPanel;
private System.Windows.Forms.TabPage functionsTabPage;
private System.Windows.Forms.Panel PanelSearchFunctions;
private System.Windows.Forms.Button BtnNextFindFunc;
private System.Windows.Forms.Button BtnPrevFindFunc;
private System.Windows.Forms.Button BtnCloseFindFunc;
private System.Windows.Forms.TextBox panelFindFunctionTextBox;
private System.Windows.Forms.Panel scintillaFunctionsPanel;
private System.Windows.Forms.TabPage actionsTabPage;
private System.Windows.Forms.Panel PanelSearchActions;
private System.Windows.Forms.Button BtnNextFindActions;
private System.Windows.Forms.Button BtnPrevFindActions;
private System.Windows.Forms.Button BtnCloseFindActions;
private System.Windows.Forms.TextBox panelFindActionTextBox;
private System.Windows.Forms.Panel scintillaActionsPanel;
private System.Windows.Forms.Button addScriptFileButton;
private System.Windows.Forms.Button removeScriptFileButton;
private System.Windows.Forms.Button saveScriptFileButton;

File diff suppressed because it is too large Load Diff

View File

@ -5494,12 +5494,14 @@ namespace DSPRE {
} else {
ScriptFile itemScript = new ScriptFile(RomInfo.itemScriptFileNumber);
owItemComboBox.Items.Clear();
//foreach (ScriptCommandContainer cont in itemScript.allScripts) {
// if (cont.commands.Count > 4) {
// continue;
// }
// owItemComboBox.Items.Add(BitConverter.ToUInt16(cont.commands[1].Parameters[1].RawData, 0) + "x " + itemNames[BitConverter.ToUInt16(cont.commands[0].Parameters[1].RawData, 0)]);
//}
foreach (ScriptCommandContainer cont in itemScript.allScripts)
{
if (cont.commands.Count > 4)
{
continue;
}
owItemComboBox.Items.Add(BitConverter.ToUInt16(cont.commands[1].cmdParams[1], 0) + "x " + itemNames[BitConverter.ToUInt16(cont.commands[0].cmdParams[1], 0)]);
}
}
/* Add ow movement list to box */

View File

@ -258,18 +258,18 @@ namespace DSPRE
public static bool CheckScriptsStandardizedItemNumbers()
{
ScriptFile itemScript = new ScriptFile(RomInfo.itemScriptFileNumber);
//if (itemScript.allScripts.Count - 1 < new TextArchive(RomInfo.itemNamesTextNumber).messages.Count)
//{
// return false;
//}
if (itemScript.allScripts.Count - 1 < new TextArchive(RomInfo.itemNamesTextNumber).messages.Count)
{
return false;
}
//for (ushort i = 0; i < itemScript.allScripts.Count - 1; i++)
//{
// if (BitConverter.ToUInt16(itemScript.allScripts[i].commands[0].Parameters[1].RawData, 0) != i || BitConverter.ToUInt16(itemScript.allScripts[i].commands[1].Parameters[1].RawData, 0) != 1)
// {
// return false;
// }
//}
for (ushort i = 0; i < itemScript.allScripts.Count - 1; i++)
{
if (BitConverter.ToUInt16(itemScript.allScripts[i].commands[0].cmdParams[1], 0) != i || BitConverter.ToUInt16(itemScript.allScripts[i].commands[1].cmdParams[1], 0) != 1)
{
return false;
}
}
return true;
}
@ -590,12 +590,13 @@ namespace DSPRE
ScriptFile itemScriptFile = new ScriptFile(RomInfo.itemScriptFileNumber);
// Create map for: script no. -> vanilla item
//int[] vanillaItemsArray = new int[itemScriptFile.allScripts.Count - 1];
//
//for (int i = 0; i < itemScriptFile.allScripts.Count - 1; i++)
//{
// vanillaItemsArray[i] = BitConverter.ToInt16(itemScriptFile.allScripts[i].commands[0].Parameters[1].RawData, 0);
//};
int[] vanillaItemsArray = new int[itemScriptFile.allScripts.Count - 1];
for (int i = 0; i < itemScriptFile.allScripts.Count - 1; i++)
{
vanillaItemsArray[i] = BitConverter.ToInt16(itemScriptFile.allScripts[i].commands[0].cmdParams[1], 0);
}
;
// Parse all event files and fix instances of ground items according to the new order
int cnt = Filesystem.GetEventFileCount();
@ -617,7 +618,7 @@ namespace DSPRE
if (isItem)
{
int itemScriptID = eventFile.overworlds[j].scriptNumber - (itemScrMin - 1);
//eventFile.overworlds[j].scriptNumber = (ushort)(itemScrMin + vanillaItemsArray[itemScriptID - 1]);
eventFile.overworlds[j].scriptNumber = (ushort)(itemScrMin + vanillaItemsArray[itemScriptID - 1]);
dirty = true;
}
}
@ -644,29 +645,29 @@ namespace DSPRE
using (DSUtils.EasyWriter ewr = new DSUtils.EasyWriter(ow9path, ow9offs))
{
//ewr.Write((ushort)(itemScrMin + vanillaItemsArray[itemScriptID - 1]));
ewr.Write((ushort)(itemScrMin + vanillaItemsArray[itemScriptID - 1]));
}
}
// Sort scripts in the Script File according to item indices
int itemCount = new TextArchive(RomInfo.itemNamesTextNumber).messages.Count;
//ScriptCommandContainer executeGive = new ScriptCommandContainer((uint)itemCount + 1, itemScriptFile.allScripts[itemScriptFile.allScripts.Count - 1]);
ScriptCommandContainer executeGive = new ScriptCommandContainer((uint)itemCount + 1, itemScriptFile.allScripts[itemScriptFile.allScripts.Count - 1]);
//itemScriptFile.allScripts.Clear();
itemScriptFile.allScripts.Clear();
//for (ushort i = 0; i < itemCount; i++)
//{
// List<ScriptCommand> cmdList = new List<ScriptCommand> {
// new ScriptCommand("SetVar 0x8008 " + i),
// new ScriptCommand("SetVar 0x8009 0x1"),
// new ScriptCommand("Jump Function_#1")
// };
//
// itemScriptFile.allScripts.Add(new ScriptCommandContainer((ushort)(i + 1), ScriptFile.ContainerTypes.Script, commandList: cmdList));
//}
//
//itemScriptFile.allScripts.Add(executeGive);
//itemScriptFile.allFunctions[0].usedScriptID = itemCount + 1;
for (ushort i = 0; i < itemCount; i++)
{
List<ScriptCommand> cmdList = new List<ScriptCommand> {
new ScriptCommand("SetVar 0x8008 " + i),
new ScriptCommand("SetVar 0x8009 0x1"),
new ScriptCommand("Jump Function_#1")
};
itemScriptFile.allScripts.Add(new ScriptCommandContainer((ushort)(i + 1), ScriptFile.ContainerTypes.Script, commandList: cmdList));
}
itemScriptFile.allScripts.Add(executeGive);
itemScriptFile.allFunctions[0].usedScriptID = itemCount + 1;
itemScriptFile.SaveToFileDefaultDir(RomInfo.itemScriptFileNumber, showSuccessMessage: false);
MessageBox.Show("Operation successful.", "Process completed.", MessageBoxButtons.OK, MessageBoxIcon.Information);

View File

@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace DSPRE.ROMFiles
{
public class ScriptActionContainer
{
public List<ScriptAction> commands;
public uint manualUserID;
public ScriptActionContainer(uint actionNumber, List<ScriptAction> commands = null)
{
manualUserID = actionNumber;
this.commands = commands;
}
}
}

View File

@ -17,17 +17,18 @@ namespace DSPRE.ROMFiles {
OW_DIRECTION,
FUNCTION_ID,
ACTION_ID,
CMD_NUMBER,
LABEL_REF
CMD_NUMBER
};
public ushort? id;
public List<ScriptParameter> Parameters { get; set; } = new List<ScriptParameter>();
public List<byte[]> cmdParams;
public string name;
// CHANGE: Update the constructor to use ScriptParameter
public ScriptCommand(ushort id, List<ScriptParameter> parameters) {
if (parameters is null) {
public ScriptCommand(ushort id, List<byte[]> parametersList)
{
if (parametersList is null)
{
this.id = null;
return;
}
@ -39,48 +40,48 @@ namespace DSPRE.ROMFiles {
switch (id) {
case 0x0016: // Jump
case 0x001A: // Call
name += $" {FormatParameter(parameters[0], ParamTypeEnum.FUNCTION_ID)}";
name += $" {FormatNumber(parametersList[0], ParamTypeEnum.FUNCTION_ID)}";
break;
case 0x0017: // JumpIfObjID
case 0x0018: // JumpIfEventID
name += $" {FormatParameter(parameters[0], ParamTypeEnum.OW_ID)} {FormatParameter(parameters[1])}";
name += $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_ID)} {FormatNumber(parametersList[1])}";
break;
case 0x0019: // JumpIfPlayerDir
name += $" {FormatParameter(parameters[0], ParamTypeEnum.OW_DIRECTION)} {FormatParameter(parameters[1], ParamTypeEnum.FUNCTION_ID)}";
name += $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_DIRECTION)} {FormatNumber(parametersList[1], ParamTypeEnum.FUNCTION_ID)}";
break;
case 0x001C: // JumpIf
case 0x001D: // CallIf
{
string number = FormatParameter(parameters[1], ParamTypeEnum.FUNCTION_ID);
string number = FormatNumber(parametersList[1], ParamTypeEnum.FUNCTION_ID);
// Access the byte value from the parameter's raw data
if (RomInfo.ScriptComparisonOperatorsDict.TryGetValue(parameters[0].RawData[0], out string v)) {
if (RomInfo.ScriptComparisonOperatorsDict.TryGetValue(parametersList[0][0], out string v)) {
name += $" {v} {number}";
} else {
name += $" {parameters[0].RawData[0]} {number}";
name += $" {parametersList[0][0]} {number}";
}
break;
}
case 0x005E: // Movement
name += $" {FormatParameter(parameters[0], ParamTypeEnum.OW_ID)} {FormatParameter(parameters[1], ParamTypeEnum.ACTION_ID)}";
name += $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_ID)} {FormatNumber(parametersList[1], ParamTypeEnum.ACTION_ID)}";
break;
case 0x006A: // GetOverworldPosition
name += FormatCmd_Overworld_TwoParams(parameters);
name += FormatCmd_Overworld_TwoParams(parametersList);
break;
case 0x0062: // Lock
case 0x0063: // Release
case 0x0064: // AddOW
case 0x0065: // RemoveOW
name += $" {FormatParameter(parameters[0], ParamTypeEnum.OW_ID)}";
name += $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_ID)}";
break;
case 0x006D: // SetOverworldMovement
name += FormatCmd_Overworld_Move(parameters);
name += FormatCmd_Overworld_Move(parametersList);
break;
case 0x00B0: // Warp [HGSS]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.HGSS)) {
name += FormatCmd_Warp(parameters);
name += FormatCmd_Warp(parametersList);
} else {
goto default;
}
@ -88,7 +89,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0152: // SetOverworldDefaultPosition [HGSS]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.HGSS)) {
name += FormatCmd_Overworld_TwoParams(parameters);
name += FormatCmd_Overworld_TwoParams(parametersList);
} else {
goto default;
}
@ -96,7 +97,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0153: // SetOverworldPosition [HGSS]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.HGSS)) {
name += FormatCmd_Overworld_3Coords_Dir(parameters);
name += FormatCmd_Overworld_3Coords_Dir(parametersList);
} else {
goto default;
}
@ -104,7 +105,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0154: // SetOverworldDefaultMovement [HGSS]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.HGSS)) {
name += FormatCmd_Overworld_Move(parameters);
name += FormatCmd_Overworld_Move(parametersList);
} else {
goto default;
}
@ -112,7 +113,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0155: // SetOverworldDefaultDirection [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.HGSS)) {
name += FormatCmd_Overworld_Dir(parameters);
name += FormatCmd_Overworld_Dir(parametersList);
} else {
goto default;
}
@ -120,7 +121,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0158: // SetOverworldDirection [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.HGSS)) {
name += FormatCmd_Overworld_Dir(parameters);
name += FormatCmd_Overworld_Dir(parametersList);
} else {
goto default;
}
@ -129,7 +130,7 @@ namespace DSPRE.ROMFiles {
case 0x00BE: // Warp [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.DP) || RomInfo.gameFamily.Equals(RomInfo.GameFamilies.Plat)) {
name += FormatCmd_Warp(parameters);
name += FormatCmd_Warp(parametersList);
} else {
goto default;
}
@ -137,7 +138,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0186: // SetOverworldDefaultPosition [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.DP) || RomInfo.gameFamily.Equals(RomInfo.GameFamilies.Plat)) {
name += FormatCmd_Overworld_TwoParams(parameters);
name += FormatCmd_Overworld_TwoParams(parametersList);
} else {
goto default;
}
@ -145,7 +146,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0187: // SetOverworldPosition [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.DP) || RomInfo.gameFamily.Equals(RomInfo.GameFamilies.Plat)) {
name += FormatCmd_Overworld_3Coords_Dir(parameters);
name += FormatCmd_Overworld_3Coords_Dir(parametersList);
} else {
goto default;
}
@ -153,7 +154,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0188: // SetOverworldDefaultMovement [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.DP) || RomInfo.gameFamily.Equals(RomInfo.GameFamilies.Plat)) {
name += FormatCmd_Overworld_Move(parameters);
name += FormatCmd_Overworld_Move(parametersList);
} else {
goto default;
}
@ -161,7 +162,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x0189: // SetOverworldDefaultDirection [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.DP) || RomInfo.gameFamily.Equals(RomInfo.GameFamilies.Plat)) {
name += FormatCmd_Overworld_Dir(parameters);
name += FormatCmd_Overworld_Dir(parametersList);
} else {
goto default;
}
@ -169,7 +170,7 @@ namespace DSPRE.ROMFiles {
break;
case 0x018C: // SetOverworldDirection [DPPt]
if (RomInfo.gameFamily.Equals(RomInfo.GameFamilies.DP) || RomInfo.gameFamily.Equals(RomInfo.GameFamilies.Plat)) {
name += FormatCmd_Overworld_Dir(parameters);
name += FormatCmd_Overworld_Dir(parametersList);
} else {
goto default;
}
@ -177,39 +178,39 @@ namespace DSPRE.ROMFiles {
break;
default:
for (int i = 0; i < parameters.Count; i++) {
name += $" {FormatParameter(parameters[i])}";
for (int i = 0; i < parametersList.Count; i++) {
name += $" {FormatNumber(parametersList[i])}";
}
break;
}
this.id = id;
this.Parameters = parameters;
this.cmdParams = parametersList;
}
private string FormatCmd_Warp(List<ScriptParameter> parameters) {
return $" {FormatParameter(parameters[0])} {FormatParameter(parameters[1])} {FormatParameter(parameters[2])} {FormatParameter(parameters[3])} {FormatParameter(parameters[4], ParamTypeEnum.OW_DIRECTION)}";
private string FormatCmd_Warp(List<byte[]> parametersList) {
return $" {FormatNumber(parametersList[0])} {FormatNumber(parametersList[1])} {FormatNumber(parametersList[2])} {FormatNumber(parametersList[3])} {FormatNumber(parametersList[4], ParamTypeEnum.OW_DIRECTION)}";
}
private string FormatCmd_Overworld_TwoParams(List<ScriptParameter> parameters) {
return $" {FormatParameter(parameters[0], ParamTypeEnum.OW_ID)} {FormatParameter(parameters[1])} {FormatParameter(parameters[2])}";
private string FormatCmd_Overworld_TwoParams(List<byte[]> parametersList) {
return $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_ID)} {FormatNumber(parametersList[1])} {FormatNumber(parametersList[2])}";
}
private string FormatCmd_Overworld_Move(List<ScriptParameter> parameters) {
return $" {FormatParameter(parameters[0], ParamTypeEnum.OW_ID)} {FormatParameter(parameters[1], ParamTypeEnum.OW_MOVEMENT_TYPE)}";
private string FormatCmd_Overworld_Move(List<byte[]> parametersList) {
return $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_ID)} {FormatNumber(parametersList[1], ParamTypeEnum.OW_MOVEMENT_TYPE)}";
}
private string FormatCmd_Overworld_3Coords_Dir(List<ScriptParameter> parameters) {
return $" {FormatParameter(parameters[0], ParamTypeEnum.OW_ID)} {FormatParameter(parameters[1])} {FormatParameter(parameters[2])} {FormatParameter(parameters[3])} {FormatParameter(parameters[4], ParamTypeEnum.OW_DIRECTION)}";
private string FormatCmd_Overworld_3Coords_Dir(List<byte[]> parametersList) {
return $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_ID)} {FormatNumber(parametersList[1])} {FormatNumber(parametersList[2])} {FormatNumber(parametersList[3])} {FormatNumber(parametersList[4], ParamTypeEnum.OW_DIRECTION)}";
}
private string FormatCmd_Overworld_Dir(List<ScriptParameter> parameters) {
return $" {FormatParameter(parameters[0], ParamTypeEnum.OW_ID)} {FormatParameter(parameters[1], ParamTypeEnum.OW_DIRECTION)}";
private string FormatCmd_Overworld_Dir(List<byte[]> parametersList) {
return $" {FormatNumber(parametersList[0], ParamTypeEnum.OW_ID)} {FormatNumber(parametersList[1], ParamTypeEnum.OW_DIRECTION)}";
}
public ScriptCommand(string wholeLine, int lineNumber = 0) {
name = wholeLine;
Parameters = new List<ScriptParameter>();
cmdParams = new List<byte[]>();
string[] nameParts = wholeLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // Separate command code from parameters
/* Get command id, which is always first in the description */
@ -244,7 +245,7 @@ namespace DSPRE.ROMFiles {
int firstParamValue = int.Parse(nameParts[1].PurgeSpecial(ScriptFile.specialChars), nameParts[1].GetNumberStyle());
byte firstParamSize = parametersSizeArr[1];
Parameters.Add(new ScriptParameter(firstParamValue.ToByteArrayChooseSize(firstParamSize)));
cmdParams.Add(firstParamValue.ToByteArrayChooseSize(firstParamSize));
paramsProcessed++;
int i = 2;
@ -306,8 +307,7 @@ namespace DSPRE.ROMFiles {
Console.WriteLine($"Parameter #{i}: {nameParts[i + 1]}");
if (RomInfo.ScriptComparisonOperatorsReverseDict.TryGetValue(nameParts[i + 1].ToLower(), out cmdID)) { //Check succeeds when command is like "asdfg LESS" or "asdfg DIFFERENT"
// Create parameter with byte array
Parameters.Add(new ScriptParameter(new byte[] { (byte)cmdID }));
cmdParams.Add(new byte[] { (byte)cmdID });
} else { //Not a comparison
/* Convert strings of parameters to the correct datatypes */
NumberStyles numStyle = nameParts[i + 1].GetNumberStyle();
@ -316,16 +316,6 @@ namespace DSPRE.ROMFiles {
int result = 0;
try {
// Check if this is a label reference
if (nameParts[i + 1].StartsWith("label") || nameParts[i + 1].StartsWith("script")) {
// This is a label reference
ScriptParameter labelParam = new ScriptParameter(0, nameParts[i + 1]) {
Type = ScriptParameter.ParameterType.RelativeJump
};
Parameters.Add(labelParam);
continue;
}
result = int.Parse(nameParts[i + 1], numStyle);
} catch {
if (string.IsNullOrWhiteSpace(nameParts[i + 1])) {
@ -352,8 +342,7 @@ namespace DSPRE.ROMFiles {
}
try {
byte[] paramData = result.ToByteArrayChooseSize(parametersSizeArr[i]);
Parameters.Add(new ScriptParameter(paramData));
cmdParams.Add(result.ToByteArrayChooseSize(parametersSizeArr[i]));
} catch (OverflowException) {
MessageBox.Show($"Argument {nameParts[i + 1]} at line {lineNumber} is not in the range [0, {Math.Pow(2, 8 * parametersSizeArr[i]) - 1}].", "Argument error", MessageBoxButtons.OK, MessageBoxIcon.Error);
id = null;
@ -369,10 +358,6 @@ namespace DSPRE.ROMFiles {
}
private string FormatNumber(byte[] par, ParamTypeEnum paramType = ParamTypeEnum.INTEGER) {
if (paramType == ParamTypeEnum.LABEL_REF && par.Length > 0) {
return FormatLabelReference(Encoding.ASCII.GetString(par));
}
//number acquisition
uint num;
if (par.Length == 0) {
@ -409,6 +394,9 @@ namespace DSPRE.ROMFiles {
case ParamTypeEnum.CMD_NUMBER:
return "CMD_" + prefix + num.ToString(formatOverride + '3');
case ParamTypeEnum.FUNCTION_ID:
return ScriptFile.ContainerTypes.Function.ToString() + "#" + num;
case ParamTypeEnum.ACTION_ID:
return ScriptFile.ContainerTypes.Action.ToString() + "#" + num;

View File

@ -0,0 +1,29 @@
using System.Collections.Generic;
namespace DSPRE.ROMFiles
{
public class ScriptCommandContainer
{
public List<ScriptCommand> commands;
public uint manualUserID;
public int usedScriptID; //useScript ID referenced by this Script/Function
public ScriptFile.ContainerTypes containerType;
internal static readonly string functionStart;
public ScriptCommandContainer(uint scriptNumber, ScriptFile.ContainerTypes containerType, int usedScriptID = -1, List<ScriptCommand> commandList = null)
{
manualUserID = scriptNumber;
this.usedScriptID = usedScriptID;
this.containerType = containerType;
commands = commandList;
}
public ScriptCommandContainer(uint newID, ScriptCommandContainer toCopy)
{
manualUserID = newID;
usedScriptID = toCopy.usedScriptID;
containerType = toCopy.containerType;
commands = new List<ScriptCommand>(toCopy.commands); //command parameters need to be copied recursively
}
}
}

File diff suppressed because it is too large Load Diff