diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj
index e0c33ab..29cf879 100644
--- a/DS_Map/DSPRE.csproj
+++ b/DS_Map/DSPRE.csproj
@@ -62,7 +62,7 @@
.\HelixToolkit.dll
- ..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll
+ ..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.2\lib\Microsoft.WindowsAPICodePack.dll
..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll
@@ -203,9 +203,6 @@
-
- Component
-
diff --git a/DS_Map/DataGridViewDoubleBuffered.cs b/DS_Map/DataGridViewDoubleBuffered.cs
deleted file mode 100644
index 3a9641e..0000000
--- a/DS_Map/DataGridViewDoubleBuffered.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// DataGridView with double buffering to speed up performance
-
-using System.Windows.Forms;
-
-namespace DSPRE
-{
- public class DataGridViewDoubleBuffered : DataGridView {
- public DataGridViewDoubleBuffered() {
- DoubleBuffered = true;
- }
- }
-}
\ No newline at end of file
diff --git a/DS_Map/Main Window.Designer.cs b/DS_Map/Main Window.Designer.cs
index 26f44b3..0e14815 100644
--- a/DS_Map/Main Window.Designer.cs
+++ b/DS_Map/Main Window.Designer.cs
@@ -181,11 +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.headersGridView = new System.Windows.Forms.DataGridView();
this.heightsTabPage = new System.Windows.Forms.TabPage();
- this.heightsGridView = new DSPRE.DataGridViewDoubleBuffered();
+ this.heightsGridView = new System.Windows.Forms.DataGridView();
this.mapFilesTabPage = new System.Windows.Forms.TabPage();
- this.mapFilesGridView = new DSPRE.DataGridViewDoubleBuffered();
+ this.mapFilesGridView = new System.Windows.Forms.DataGridView();
this.matrixNameTextBox = new System.Windows.Forms.TextBox();
this.heightUpDown = new System.Windows.Forms.NumericUpDown();
this.widthUpDown = new System.Windows.Forms.NumericUpDown();
@@ -10694,16 +10694,16 @@
private System.Windows.Forms.TabControl matrixTabControl;
private System.Windows.Forms.TabPage headersTabPage;
private System.Windows.Forms.TabPage heightsTabPage;
- private DSPRE.DataGridViewDoubleBuffered heightsGridView;
+ private System.Windows.Forms.DataGridView heightsGridView;
private System.Windows.Forms.TabPage mapFilesTabPage;
- private DSPRE.DataGridViewDoubleBuffered mapFilesGridView;
+ private System.Windows.Forms.DataGridView mapFilesGridView;
private System.Windows.Forms.TextBox matrixNameTextBox;
private System.Windows.Forms.NumericUpDown heightUpDown;
private System.Windows.Forms.NumericUpDown widthUpDown;
private System.Windows.Forms.Label widthLabel;
private System.Windows.Forms.ComboBox selectMatrixComboBox;
private System.Windows.Forms.Button saveMatrixButton;
- private DSPRE.DataGridViewDoubleBuffered headersGridView;
+ private System.Windows.Forms.DataGridView headersGridView;
private System.Windows.Forms.Button addHeadersButton;
private System.Windows.Forms.Button addHeightsButton;
private System.Windows.Forms.Button removeHeadersButton;
diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs
index ca109d6..2cbb3e3 100644
--- a/DS_Map/Main Window.cs
+++ b/DS_Map/Main Window.cs
@@ -4865,7 +4865,7 @@ namespace DSPRE {
}
/* Add event file numbers to box */
- int eventCount = Directory.GetFiles(RomInfo.gameDirs[DirNames.eventFiles].unpackedDir).Length;
+ int eventCount = RomInfo.GetEventFileCount();
int owSpriteCount = Directory.GetFiles(RomInfo.gameDirs[DirNames.OWSprites].unpackedDir).Length;
string[] trainerNames = GetTrainerNames();
RomInfo.ReadOWTable();
diff --git a/DS_Map/ROMToolboxDialog.Designer.cs b/DS_Map/ROMToolboxDialog.Designer.cs
index e588e1f..03e6446 100644
--- a/DS_Map/ROMToolboxDialog.Designer.cs
+++ b/DS_Map/ROMToolboxDialog.Designer.cs
@@ -284,7 +284,8 @@
this.standardizePatchTextLBL.Name = "standardizePatchTextLBL";
this.standardizePatchTextLBL.Size = new System.Drawing.Size(239, 78);
this.standardizePatchTextLBL.TabIndex = 2;
- this.standardizePatchTextLBL.Text = resources.GetString("standardizePatchTextLBL.Text");
+ this.standardizePatchTextLBL.Text = "Rearranges the GiveItem scripts to follow the default index order.\r\nAllows to con" +
+ "figure any item as a Ground Item in the Event Editor. ";
this.standardizePatchTextLBL.UseMnemonic = false;
//
// expandedMatrixCB
diff --git a/DS_Map/ROMToolboxDialog.cs b/DS_Map/ROMToolboxDialog.cs
index a412ecf..572695e 100644
--- a/DS_Map/ROMToolboxDialog.cs
+++ b/DS_Map/ROMToolboxDialog.cs
@@ -415,43 +415,87 @@ namespace DSPRE {
private void ApplyItemStandardizeButton_Click(object sender, EventArgs e) {
DialogResult d = MessageBox.Show("This process will apply the following changes:\n\n" +
- "- Item scripts will be rearranged to follow the natural, ascending index order.\n\n" +
- "- Consequently, every Item event already on the ground will be changed.",
+ "- Item scripts will be rearranged to follow the natural, ascending index order.\n\n",
"Confirm to proceed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (d == DialogResult.Yes) {
DSUtils.TryUnpackNarcs(new List { RomInfo.DirNames.scripts });
+ DSUtils.TryUnpackNarcs(new List { RomInfo.DirNames.eventFiles });
if (ROMToolboxDialog.flag_standardizedItems) {
AlreadyApplied();
- } else {
- ScriptFile itemScript = new ScriptFile(RomInfo.itemScriptFileNumber);
+ }
+
+ else {
+ // Load item script file data
+ ScriptFile itemScriptFile = new ScriptFile(RomInfo.itemScriptFileNumber);
+
+ // Create map for: script no. -> vanilla item
+ Dictionary vanillaItemTable = new Dictionary();
+
+ for (int i = 0; i < itemScriptFile.allScripts.Count - 1; i++) {
+
+ int itemID = BitConverter.ToInt16(itemScriptFile.allScripts[i].commands[0].cmdParams[1], 0);
+
+ vanillaItemTable.Add(1 + i, itemID);
+ };
+
+ // Parse all event files and fix instances of ground items according to the new order
+ for (int i = 0; i < RomInfo.GetEventFileCount(); i++) {
+
+ EventFile eventFile = new EventFile(i);
+
+ for (int j = 0; j < eventFile.overworlds.Count; j++) {
+
+ // If ow is marked as an item, or in the rare case it is not but script no. falls within item script range:
+ bool isItem = eventFile.overworlds[j].type == (ushort)Overworld.owType.ITEM
+ || (eventFile.overworlds[j].scriptNumber >= 7000
+ && eventFile.overworlds[j].scriptNumber <= 8000 );
+
+ if (isItem) {
+ int itemScriptID = eventFile.overworlds[j].scriptNumber - 6999;
+
+ eventFile.overworlds[j].scriptNumber = (ushort)(7000 + vanillaItemTable[itemScriptID]);
+ }
+ }
+
+ // Save event file
+ eventFile.SaveToFileDefaultDir(i, showSuccessMessage: false);
+ };
+
+ // Sort scripts in the Script File according to item indices
int itemCount = new TextArchive(RomInfo.itemNamesTextNumber).messages.Count;
- CommandContainer executeGive = new CommandContainer((uint)itemCount, itemScript.allScripts[itemScript.allScripts.Count - 1]);
- itemScript.allScripts.Clear();
+ CommandContainer executeGive = new CommandContainer((uint)itemCount, itemScriptFile.allScripts[itemScriptFile.allScripts.Count - 1]);
+
+ itemScriptFile.allScripts.Clear();
for (ushort i = 0; i < itemCount; i++) {
+
List cmdList = new List {
new ScriptCommand("SetVar 0x8008 " + i),
new ScriptCommand("SetVar 0x8009 0x1"),
new ScriptCommand("Jump Function_#1")
};
- itemScript.allScripts.Add(new CommandContainer((ushort)(i + 1), ScriptFile.containerTypes.Script, commandList: cmdList));
+ itemScriptFile.allScripts.Add(new CommandContainer((ushort)(i + 1), ScriptFile.containerTypes.Script, commandList: cmdList));
}
- itemScript.allScripts.Add(executeGive);
- itemScript.allFunctions[0].useScript = itemCount + 1;
+
+ itemScriptFile.allScripts.Add(executeGive);
+ itemScriptFile.allFunctions[0].useScript = itemCount + 1;
- itemScript.SaveToFileDefaultDir(RomInfo.itemScriptFileNumber, showSuccessMessage: false);
+ itemScriptFile.SaveToFileDefaultDir(RomInfo.itemScriptFileNumber, showSuccessMessage: false);
MessageBox.Show("Operation successful.", "Process completed.", MessageBoxButtons.OK, MessageBoxIcon.Information);
DisableStandardizeItemsPatch("Already applied");
+
itemNumbersCB.Visible = true;
ROMToolboxDialog.flag_standardizedItems = true;
}
- } else {
+ }
+
+ else {
MessageBox.Show("No changes have been made.", "Operation canceled", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
@@ -822,7 +866,5 @@ namespace DSPRE {
private void repointScrcmdButton_Click(object sender, EventArgs e) {
}
-
-
}
}
\ No newline at end of file
diff --git a/DS_Map/ROMToolboxDialog.resx b/DS_Map/ROMToolboxDialog.resx
index 5f97f12..1264b4f 100644
--- a/DS_Map/ROMToolboxDialog.resx
+++ b/DS_Map/ROMToolboxDialog.resx
@@ -163,11 +163,6 @@ This patch is necessary to accomplish most ASM edits.
upmAncykgSX9hgfNYHyTqg2kaiXFN87xo5nSrQ+kXic1kuVygUkD6d58CYZ1nPWgzlMB3EvmcL1i+AEb
Ho2MhU9VbQAAAABJRU5ErkJggg==
-
-
- Rearranges the GiveItem scripts to follow the default index order.
-Allows to configure any item as a Ground Item in the Event Editor.
-Inevitably, every Item that is already on the ground will change.
diff --git a/DS_Map/Resources/DLLs/ScintillaNET.dll b/DS_Map/Resources/DLLs/ScintillaNET.dll
new file mode 100644
index 0000000..b806ebb
Binary files /dev/null and b/DS_Map/Resources/DLLs/ScintillaNET.dll differ
diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs
index ad7071d..31821d6 100644
--- a/DS_Map/RomInfo.cs
+++ b/DS_Map/RomInfo.cs
@@ -720,6 +720,7 @@ namespace DSPRE {
public int GetEventCount() => Directory.GetFiles(gameDirs[DirNames.eventFiles].unpackedDir).Length;
public int GetScriptCount() => Directory.GetFiles(gameDirs[DirNames.scripts].unpackedDir).Length;
public int GetBuildingCount(bool interior) => Directory.GetFiles(GetBuildingModelsDirPath(interior)).Length;
+ public static int GetEventFileCount() => Directory.GetFiles(RomInfo.gameDirs[DirNames.eventFiles].unpackedDir).Length;
#endregion
#region System Methods
diff --git a/DS_Map/packages.config b/DS_Map/packages.config
index 88e99f6..6eae2b6 100644
--- a/DS_Map/packages.config
+++ b/DS_Map/packages.config
@@ -1,7 +1,7 @@
-
+
\ No newline at end of file