bool ValidateSkill() { string skillName = nameTextBox.Text.Trim(); string groupName = groupNameTextBox.Text.Trim(); int manaCost = (int)manaUpDown.Value; TimeSpan cooldown; bool isAssail = assailCheckBox.IsChecked.Value; bool opensDialog = dialogCheckBox.IsChecked.Value; bool doesNotLevel = improveCheckBox.IsChecked.Value; bool requiresDisarm = disarmCheckBox.IsChecked.Value; bool nameChanged = originalName == null || !string.Equals(originalName, skillName, StringComparison.OrdinalIgnoreCase); if (string.IsNullOrWhiteSpace(skillName)) { this.ShowMessageBox("Invalid Name", "Skill names must not be null or empty.", "This includes whitespace characters.", MessageBoxButton.OK, 420, 220); nameTextBox.Focus(); nameTextBox.SelectAll(); return(false); } if (nameChanged && SkillMetadataManager.Instance.ContainsSkill(skillName)) { this.ShowMessageBox("Duplicate Name", "A skill already exists with the same name.", "Skill names are case-insenstive.", MessageBoxButton.OK, 420, 220); nameTextBox.Focus(); nameTextBox.SelectAll(); return(false); } double cooldownSeconds; if (string.IsNullOrWhiteSpace(cooldownTextBox.Text.Trim())) { cooldown = TimeSpan.Zero; } else if (double.TryParse(cooldownTextBox.Text.Trim(), out cooldownSeconds) && cooldownSeconds >= 0) { cooldown = TimeSpan.FromSeconds(cooldownSeconds); } else if (!TimeSpanExtender.TryParse(cooldownTextBox.Text.Trim(), out cooldown) || cooldown < TimeSpan.Zero) { this.ShowMessageBox("Invalid Cooldown", "Cooldown must be a valid positive timespan value.", "You may use fractional units of days, hours, minutes, and seconds.\nYou may also leave it blank for zero cooldown.", MessageBoxButton.OK, 420, 240); cooldownTextBox.Focus(); cooldownTextBox.SelectAll(); return(false); } skill.Name = skillName; skill.GroupName = string.IsNullOrWhiteSpace(groupName) ? null : groupName; skill.Class = GetPlayerClass(); skill.ManaCost = manaCost; skill.Cooldown = cooldown; skill.IsAssail = isAssail; skill.OpensDialog = opensDialog; skill.CanImprove = !doesNotLevel; skill.RequiresDisarm = requiresDisarm; return(true); }
bool ValidateFlowerTarget() { var selectedMode = GetSelectedMode(); TimeSpan interval = TimeSpan.Zero; #region Check Target Mode if (selectedMode == TargetCoordinateUnits.None) { this.ShowMessageBox("Target Required", "Lyliac Plant requires a target.", "You must select a target mode from the dropdown list.", MessageBoxButton.OK); targetModeComboBox.Focus(); targetModeComboBox.IsDropDownOpen = true; return(false); } #endregion var characterName = characterComboBox.SelectedValue as string; if (selectedMode == TargetCoordinateUnits.Character && string.IsNullOrWhiteSpace(characterName)) { this.ShowMessageBox("Invalid Character", "Alternate character cannot be empty.", "If the character you are looking for does not show up\nclose this window and try again.", MessageBoxButton.OK, 440, 220); return(false); } if ((selectedMode == TargetCoordinateUnits.RelativeRadius || selectedMode == TargetCoordinateUnits.AbsoluteRadius) && innerRadiusUpDown.Value > outerRadiusUpDown.Value) { this.ShowMessageBox("Invalid Radius", "The inner radius must be less than or equal to the outer radius.", "You may use zero inner radius to include yourself, one to start from adjacent tiles", MessageBoxButton.OK, 440, 220); return(false); } if (intervalCheckBox.IsChecked.Value) { double intervalSeconds; if (string.IsNullOrWhiteSpace(intervalTextBox.Text.Trim())) { interval = TimeSpan.Zero; } else if (double.TryParse(intervalTextBox.Text.Trim(), out intervalSeconds) && intervalSeconds >= 0) { interval = TimeSpan.FromSeconds(intervalSeconds); } else if (!TimeSpanExtender.TryParse(intervalTextBox.Text.Trim(), out interval) || interval < TimeSpan.Zero) { this.ShowMessageBox("Invalid Interval", "Interval must be a valid positive timespan value.", "You may use fractional units of days, hours, minutes, and seconds.\nYou may also leave it blank for continuous.", MessageBoxButton.OK, 420, 240); intervalTextBox.Focus(); intervalTextBox.SelectAll(); return(false); } } if (!intervalCheckBox.IsChecked.Value && !manaThresholdCheckBox.IsChecked.Value) { this.ShowMessageBox("Missing Condition", "You must specify at least one condition to flower on.\nYou may use the time interval or mana conditions, or both.", "If you specify both, it will flower if either condition is reached.", MessageBoxButton.OK, 480, 240); return(false); } flowerQueueItem.Target.Units = selectedMode; if (selectedMode == TargetCoordinateUnits.Character) { flowerQueueItem.Target.CharacterName = characterName; } else { flowerQueueItem.Target.CharacterName = null; } flowerQueueItem.Target.Location = GetLocationForMode(selectedMode); flowerQueueItem.Target.Offset = new Point(offsetXUpDown.Value, offsetYUpDown.Value); if (selectedMode == TargetCoordinateUnits.AbsoluteRadius || selectedMode == TargetCoordinateUnits.RelativeRadius) { flowerQueueItem.Target.InnerRadius = (int)innerRadiusUpDown.Value; flowerQueueItem.Target.OuterRadius = (int)outerRadiusUpDown.Value; } else { flowerQueueItem.Target.InnerRadius = 0; flowerQueueItem.Target.OuterRadius = 0; } if (intervalCheckBox.IsChecked.Value) { flowerQueueItem.Interval = interval; } else { flowerQueueItem.Interval = null; } if (manaThresholdUpDown.IsEnabled && manaThresholdCheckBox.IsChecked.Value) { flowerQueueItem.ManaThreshold = (int)manaThresholdUpDown.Value; } else { flowerQueueItem.ManaThreshold = null; } return(true); }