mirror of
https://github.com/AdAstra-LD/DS-Pokemon-Rom-Editor.git
synced 2026-05-12 06:54:33 -05:00
Make item standardization patch preserve existing items
This commit is contained in:
parent
d9746925aa
commit
bb5ef60e36
|
|
@ -62,7 +62,7 @@
|
|||
<HintPath>.\HelixToolkit.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
|
||||
<HintPath>..\packages\Microsoft.WindowsAPICodePack-Core.1.1.0.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
|
||||
|
|
@ -203,9 +203,6 @@
|
|||
<Compile Include="ROMFiles\ScriptFile.cs" />
|
||||
<Compile Include="ROMFiles\GameMatrix.cs" />
|
||||
<Compile Include="ROMFiles\EventFile.cs" />
|
||||
<Compile Include="DataGridViewDoubleBuffered.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LibNDSFormats\bytearrayoutputstream.cs" />
|
||||
<Compile Include="LibNDSFormats\convertir.cs" />
|
||||
<Compile Include="LibNDSFormats\EndianBinaryReader.cs" />
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
DS_Map/Main Window.Designer.cs
generated
12
DS_Map/Main Window.Designer.cs
generated
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
3
DS_Map/ROMToolboxDialog.Designer.cs
generated
3
DS_Map/ROMToolboxDialog.Designer.cs
generated
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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> { RomInfo.DirNames.scripts });
|
||||
DSUtils.TryUnpackNarcs(new List<RomInfo.DirNames> { 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<int, int> vanillaItemTable = new Dictionary<int, int>();
|
||||
|
||||
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<ScriptCommand> cmdList = new List<ScriptCommand> {
|
||||
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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -163,11 +163,6 @@ This patch is necessary to accomplish most ASM edits.
|
|||
upmAncykgSX9hgfNYHyTqg2kaiXFN87xo5nSrQ+kXic1kuVygUkD6d58CYZ1nPWgzlMB3EvmcL1i+AEb
|
||||
Ho2MhU9VbQAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="standardizePatchTextLBL.Text" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="expandedMatrixCB.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
|
|
|||
BIN
DS_Map/Resources/DLLs/ScintillaNET.dll
Normal file
BIN
DS_Map/Resources/DLLs/ScintillaNET.dll
Normal file
Binary file not shown.
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="jacobslusser.ScintillaNET" version="3.6.3" targetFramework="net48" />
|
||||
<package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.0" targetFramework="net48" />
|
||||
<package id="Microsoft.WindowsAPICodePack-Core" version="1.1.0.2" targetFramework="net48" />
|
||||
<package id="Microsoft.WindowsAPICodePack-Shell" version="1.1.0.0" targetFramework="net48" />
|
||||
<package id="System.Collections.Specialized" version="4.3.0" targetFramework="net48" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue
Block a user