private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (selectedROMPath != null && !selectedROMPath.Equals(""))
{
byte[] rom = File.ReadAllBytes(selectedROMPath);
string romCode = GetROMCode();
string[] iniFile = File.ReadAllLines(System.Windows.Forms.Application.StartupPath + @"\Data\BattleScriptPro.ini");
Dictionary<byte, char> characterValues = ReadTableFile(System.Windows.Forms.Application.StartupPath + @"\Data\Table.ini");
bool getValues = false;
if (comboBox1.Items.Count == 0)
{
uint numberOfMoves = 0;
uint moveNamesLocation = 0;
foreach (string s in iniFile)
{
if (s.Equals("[" + romCode + "]"))
{
getValues = true;
continue;
}
if (s.Equals("[/" + romCode + "]"))
{
getValues = false;
break;
}
if (getValues)
{
if (s.StartsWith("MoveDataTable"))
{
uint value = 0;
bool success = UInt32.TryParse(s.Split('=')[1], out value);
if (!success)
{
success = UInt32.TryParse(ToDecimal(s.Split('=')[1]), out value);
if (!success)
{
MessageBox.Show("Error parsing the move keyword value from the main ini. Are you sure it is formatted correctly as a number?");
}
}
moveDataTableLocation = value;
}
else if (s.StartsWith("NumberOfMoves"))
{
uint value = 0;
bool success = UInt32.TryParse(s.Split('=')[1], out value);
if (!success)
{
success = UInt32.TryParse(ToDecimal(s.Split('=')[1]), out value);
if (!success)
{
MessageBox.Show("Error parsing the move keyword value from the main ini. Are you sure it is formatted correctly as a number?");
}
}
numberOfMoves = value;
}
else if (s.StartsWith("MoveNames"))
{
uint value = 0;
bool success = UInt32.TryParse(s.Split('=')[1], out value);
if (!success)
{
success = UInt32.TryParse(ToDecimal(s.Split('=')[1]), out value);
if (!success)
{
MessageBox.Show("Error parsing the move keyword value from the main ini. Are you sure it is formatted correctly as a number?");
}
}
moveNamesLocation = value;
}
}
}
for (uint i = 0; i < numberOfMoves; i++)
{
uint moveNameLocation = moveNamesLocation + ((i + 1) * 13);
string s = "";
for (int j = 0; j < 13; j++)
{
if ((rom[moveNameLocation + j] != 0xFF))
{
char temp = ';';
characterValues.TryGetValue(rom[moveNameLocation + j], out temp);
s += temp;
}
else
{
break;
}
}
comboBox1.Items.Add(s);
}
comboBox1.SelectedIndex = 0;
GetEffectID(rom);
}
else
{
GetEffectID(rom);
}
}
}