// Create a new objective in the local data and add it to the list box private void btnNew_Click(object sender, EventArgs e) { ObjectiveXML newObjective = new ObjectiveXML(); // Set default name int offset = 1; string name = FixupNamePrefix("Objective" + FormatCount(listBoxObjectives.Items.Count + offset), true); while (FindObjectiveByName(name) != null) { offset++; name = FixupNamePrefix("Objective" + FormatCount(listBoxObjectives.Items.Count + offset), true); } newObjective.mObjectiveName = name; // Set default flags newObjective.setFlag(true, "Required"); newObjective.setFlag(true, "Player1"); // Set default description // fixme - encode? newObjective.mDescription = ""; // Set default hint newObjective.mHint = ""; // Set the default score newObjective.mScore = 0; // Assign objective ID AssignID(newObjective); // Add to data SimGlobals.getSimMain().ObjectivesData.mObjectives.Add(newObjective); // Pause painting listBoxObjectives.BeginUpdate(); // Add to list box listBoxObjectives.Items.Add(newObjective.mObjectiveName); // Assign list box selection to the new objective listBoxObjectives.SelectedIndex = listBoxObjectives.Items.IndexOf(newObjective.mObjectiveName); // Resume painting listBoxObjectives.EndUpdate(); ObjectivesChanged(); }
// When a check box is changed private void CheckBoxChanged(CheckBox chkBox, string flag) { ObjectiveXML objective = GetSelectedObjective(); if ((objective != null) && !mInternal) { objective.setFlag(chkBox.Checked, flag); } //ObjectivesChanged(); }