private void button1_Click(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");
bool getValues = false;
foreach (string s in iniFile)
{
if (s.Equals("[" + romCode + "]"))
{
getValues = true;
continue;
}
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;
getValues = false;
break;
}
}
}
uint x = 0;
bool newSuccess = UInt32.TryParse(textBox1.Text, out x);
if (!newSuccess)
{
newSuccess = UInt32.TryParse(ToDecimal(textBox1.Text), out x);
}
if (x > 0xFF)
{
x = 0;
}
rom[((comboBox1.SelectedIndex + 1) * 12) + moveDataTableLocation] = (byte)(x);
File.WriteAllBytes(selectedROMPath, rom);
}
}