Fixed command entries [ID typos] and section marker detection (----- @Script_# -----)

commands are now case insensitive
This commit is contained in:
AdAstra-LD
2021-02-08 14:32:15 +01:00
parent 4f97412809
commit 17707fcd68
6 changed files with 21 additions and 25 deletions

View File

@@ -4,7 +4,7 @@ namespace DSPRE
{
public partial class GivePokémonDialog : Form
{
public string command = "\nGivePokémon ";
public string command = "\nGivePokemon ";
public bool okSelected;
public GivePokémonDialog(string[] pokémonNames, string[] itemNames, string[] moveNames)
{

View File

@@ -5566,7 +5566,7 @@ namespace DSPRE {
if (f.okSelected) {
string firstLine = "SetVar 0x8004 0x" + f.itemComboBox.SelectedIndex.ToString("X");
string secondLine = "SetVar 0x8005 0x" + ((int)f.quantityNumericUpDown.Value).ToString("X");
string thirdLine = "CallStandard 0x7FC";
string thirdLine = "CommonScript 0x7FC";
currentScriptBox.Text = currentScriptBox.Text.Insert(currentScriptBox.SelectionStart, firstLine + "\r" + secondLine + "\r" + thirdLine);
updateCurrentBoxLineNumbers(null, null);

View File

@@ -47,14 +47,14 @@ namespace DSPRE.ROMFiles {
/* Get command id, which is always first in the description */
try {
id = PokeDatabase.ScriptEditor.movementsDictIDName.First(x => x.Value == nameParts[0]).Key;
id = PokeDatabase.ScriptEditor.movementsDictIDName.First(x => x.Value.Equals(nameParts[0], StringComparison.InvariantCultureIgnoreCase)).Key;
} catch (InvalidOperationException) {
try {
id = UInt16.Parse(nameParts[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
} catch (FormatException) {
string details;
if (wholeLine.Contains('@')) {
details = "Perhaps you forgot to End the Action above it...?";
if (wholeLine.Contains('@') && wholeLine.Contains('#')) {
details = "This probably means you forgot to \"End\" the Action above it.";
} else {
details = "Are you sure it's a proper Action Command?";
}

View File

@@ -31,11 +31,8 @@ namespace DSPRE.ROMFiles {
this.id = id;
this.commandParameters = commandParameters;
Dictionary<ushort, string> commandNamesDatabase;
commandNamesDatabase = RomInfo.scriptCommandNamesDict;
try {
name = commandNamesDatabase[id];
name = RomInfo.scriptCommandNamesDict[id];
} catch (KeyNotFoundException) {
name = id.ToString("X4");
}
@@ -53,7 +50,7 @@ namespace DSPRE.ROMFiles {
case 0x1C: // CompareLastResultJump
case 0x1D: // CompareLastResultCall
byte opcode = commandParameters[0][0];
this.name += " " + PokeDatabase.ScriptEditor.comparisonOperators[opcode] + " " + "Function_#" + (1 + (BitConverter.ToInt32(commandParameters[1], 0))).ToString("D");
this.name += " " + PokeDatabase.ScriptEditor.comparisonOperatorsDict[opcode] + " " + "Function_#" + (1 + (BitConverter.ToInt32(commandParameters[1], 0))).ToString("D");
break;
case 0x5E: // ApplyMovement
ushort flexID = BitConverter.ToUInt16(commandParameters[0], 0);
@@ -88,14 +85,15 @@ namespace DSPRE.ROMFiles {
/* Get command id, which is always first in the description */
try {
id = RomInfo.scriptCommandNamesDict.First(x => x.Value == nameParts[0]).Key;
id = RomInfo.scriptCommandNamesDict.First(x => x.Value.Equals(nameParts[0], StringComparison.InvariantCultureIgnoreCase)).Key;
} catch (InvalidOperationException) {
try {
id = UInt16.Parse(nameParts[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
} catch (FormatException) {
string details;
if (wholeLine.Contains('@')) {
details = "Perhaps you forgot to End the Script or Function above it...?";
if (wholeLine.Contains('@') && wholeLine.Contains('#')) {
details = "This probably means you forgot to \"End\" the Script or Function above it.";
details += Environment.NewLine + "Please, also note that only Functions can be terminated\nwith \"Return\".";
} else {
details = "Are you sure it's a proper Script Command?";
}
@@ -123,7 +121,7 @@ namespace DSPRE.ROMFiles {
for (int i = 0; i < paramLength; i++) {
Console.WriteLine("Parameter #" + i.ToString() + ": " + nameParts[i + 1]);
try {
ushort comparisonOperator = PokeDatabase.ScriptEditor.comparisonOperators.First(x => x.Value == nameParts[i + 1]).Key;
ushort comparisonOperator = PokeDatabase.ScriptEditor.comparisonOperatorsDict.First(x => x.Value.Equals(nameParts[i + 1], StringComparison.InvariantCultureIgnoreCase)).Key;
commandParameters.Add(new byte[] { (byte)comparisonOperator });
} catch { //Not a comparison
int indexOfSpecialCharacter = nameParts[i + 1].IndexOfAny(new char[] { 'x', '#' });

View File

@@ -650,15 +650,15 @@ namespace DSPRE.ROMFiles {
List<CommandContainer> ls = new List<CommandContainer>();
for (int i = 0; i < lineSource.Length; i++) {
if (lineSource[i].Contains('@')) { // Move on until script header is found
int positionOfScriptNumber = lineSource[i].IndexOf('#');
int positionOfScriptNumber = lineSource[i].IndexOf('#');
if (lineSource[i].Contains('@') && positionOfScriptNumber >= 0) { // Move on until script header is found
int scriptNumber = Int32.Parse(lineSource[i].Substring(positionOfScriptNumber + 1).Split()[0].Replace("-", ""));
i++;
while (lineSource[i].Length <= 0)
i++; //Skip all empty lines
if (lineSource[i].Contains("UseScript")) {
if (lineSource[i].IndexOf("UseScript", StringComparison.InvariantCultureIgnoreCase) >= 0) {
int useScriptNumber = Int16.Parse(lineSource[i].Substring(1 + lineSource[i].IndexOf('#')));
ls.Add(new CommandContainer(scriptNumber, useScriptNumber));
} else {
@@ -684,9 +684,8 @@ namespace DSPRE.ROMFiles {
List<ActionContainer> ls = new List<ActionContainer>();
for (int i = 0; i < lineSource.Length; i++) {
if (lineSource[i].Contains('@')) { // Move on until script header is found
int positionOfActionNumber = lineSource[i].IndexOf('#');
int positionOfActionNumber = lineSource[i].IndexOf('#');
if (lineSource[i].Contains('@') && positionOfActionNumber >= 0) { // Move on until script header is found
int actionNumber = Int32.Parse(lineSource[i].Substring(positionOfActionNumber + 1).Split()[0].Replace("-", ""));
i++;
@@ -710,7 +709,6 @@ namespace DSPRE.ROMFiles {
}
return ls;
}
public static string OverworldFlexDecode(ushort flexID) {
if (flexID > 255) {
return " " + "0x" + flexID.ToString("X4");

View File

@@ -658,7 +658,7 @@ namespace DSPRE.Resources {
[0x0068] = "WaitMoveForever",
[0x00FE] = "End"
};
public static Dictionary<ushort, string> comparisonOperators = new Dictionary<ushort, string>() {
public static Dictionary<ushort, string> comparisonOperatorsDict = new Dictionary<ushort, string>() {
[0] = "LOWER",
[1] = "EQUAL",
[2] = "GREATER",
@@ -906,9 +906,9 @@ namespace DSPRE.Resources {
[0x011A] = "CheckPokemonGender",
[0x011C] = "CheckElevatorFloor",
[0x001D] = "ElevatorBox",
[0x001E] = "SinnohDexSeen",
[0x001F] = "SinnohDexObtained",
[0x011D] = "ElevatorBox",
[0x011E] = "SinnohDexSeen",
[0x011F] = "SinnohDexObtained",
[0x0120] = "NationalDexSeen",
[0x0121] = "NationalDexObtained",
[0x0122] = "DummyNationalDexCheck",