private void SaveTemplate(object sender, RoutedEventArgs e) { List <string> errors = new List <string>(); foreach (NumAttribute attribute in CharacterEngine.CharTemplate.Attributes.Values) { if (attribute.GetType() == typeof(NumAttribute)) { foreach (string error in CharacterEngine.ValidateAttribute(CharacterEngine.CharTemplate, (NumAttribute)attribute)) { errors.Add(error); } } } if (errors.Count == 0) { MainEngine.Template = CharacterEngine.CharTemplate; ObjectsFromRules newMenu = new ObjectsFromRules(); newMenu.Show(); this.Close(); } else { StringBuilder consolodatedErrors = new StringBuilder(); foreach (string error in errors) { consolodatedErrors.Append(error + "\n"); } MessageBoxResult errorMessage = MessageBox.Show(consolodatedErrors.ToString()); } }
private void SaveAttribute_Click(object sender, RoutedEventArgs e) { if (!CharacterEngine.CharTemplate.Attributes.ContainsKey(AttributeNameField.Text)) { switch (AttributeType.SelectedIndex) { case 0: //Text CharacterEngine.CharTemplate.Attributes.Add(AttributeNameField.Text, new TextAttribute(AttributeNameField.Text, "", 0, "")); break; case 1: //Number NumAttribute newAttribute = new NumAttribute(AttributeNameField.Text, "", 0, dependencies); string[] errors = CharacterEngine.ValidateAttribute(CharacterEngine.CharTemplate, newAttribute); if (errors.Length == 0) { CharacterEngine.CharTemplate.Attributes.Add(newAttribute.Name, newAttribute); } else { StringBuilder consolodatedErrors = new StringBuilder(); foreach (string error in errors) { consolodatedErrors.Append(error + "\n"); } MessageBoxResult errorMessage = MessageBox.Show(consolodatedErrors.ToString()); } break; case 2: //Bool CharacterEngine.CharTemplate.Attributes.Add(AttributeNameField.Text, new BoolAttribute(AttributeNameField.Text, "", 0)); break; } } else { AttributeNameField.Text = "Name Already In Use"; } }