/// <summary>
/// Converts the data in the form into a condition, and closes the form
/// </summary>
public void Save()
{
// Tell the base condition form that we modifed the condition
base.Canceled = false;
// First param is always the python method name
List <string> Params = new List <string>();
Params.Add("object_stat");
// 1st param
if (ObjectSelect.SelectedIndex == 0)
{
Params.Add("kits");
}
else if (ObjectSelect.SelectedIndex == 1)
{
Params.Add("weapons");
}
else
{
Params.Add("vehicles");
}
// 2nd param
if (StatSelect.SelectedIndex == 0)
{
Params.Add("kills");
}
else if (StatSelect.SelectedIndex == 1)
{
Params.Add("rtime");
}
else if (StatSelect.SelectedIndex == 2)
{
Params.Add("roadKills");
}
else
{
Params.Add("deployed");
}
// Make sure roadKills is not selected on kits and weapons
if (Params.Last <string>() == "roadKills" && ObjectSelect.SelectedIndex != 2)
{
MessageBox.Show("Only Vehicles can use the \"Road Kills\" stat.", "Error");
ObjectSelect.Focus();
return;
}
// 3rd Param
KeyValuePair I = (KeyValuePair)TypeSelect.SelectedItem;
Params.Add(I.Key);
// 4th Param (optional)
if (ValueBox.Visible)
{
Params.Add(((int)ValueBox.Value).ToString());
}
// Are we creating a new ObjectStat?
if (Obj == null)
{
Obj = new ObjectStat(Params);
}
else
{
Obj.SetParams(Params);
}
// Close the form
this.Node.Tag = Obj;
MedalDataEditor.ChangesMade = true;
this.DialogResult = DialogResult.OK;
}