private void SaveButton_Click(object sender, EventArgs e)
{
// Make sure we have something in the maplist!
if (String.IsNullOrWhiteSpace(MapListBox.Text))
{
MessageBox.Show("You must at least have 1 map before saving the maplist!", "User Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Append the prefix to each map line
BF2Mod Mod = MainForm.SelectedMod;
// Clear out old Junk, and add new
Mod.MapList.Entries.Clear();
for (int i = 0; i < MapListBox.Lines.Length; i++)
{
// Validate that the line was not tampered with
if(!Mod.MapList.AddFromString(MapListBox.Lines[i]))
{
MessageBox.Show(
"Error parsing map entry on line " + i + ". Operation aborted.",
"Save Error", MessageBoxButtons.OK, MessageBoxIcon.Warning
);
}
}
// Save and close
Mod.MapList.SaveToFile(Mod.MaplistFilePath);
this.Close();
}