Example #1
0
        /// <summary>
        /// Set the planned level to the given one, lowering it if it's higher than the targetted one.
        /// When the skill is not planned already, the prerequisites are automatically added.
        /// Note this method won't remove entries other entries depend of.
        /// </summary>
        /// <param name="skill">The skill we want to plan</param>
        /// <param name="level">The level we want to train to</param>
        /// <param name="priority">The priority.</param>
        /// <param name="noteForNewEntries">The reason we want to train this skill</param>
        public void PlanTo(StaticSkill skill, long level, int priority, string noteForNewEntries)
        {
            int plannedLevel = GetPlannedLevel(skill);

            if (level == plannedLevel)
            {
                return;
            }

            using (SuspendingEvents())
            {
                // We may either have to add or remove entries. First, we assume we have to add ones
                if (level > plannedLevel)
                {
                    List <StaticSkillLevel> skillsToAdd = new List <StaticSkillLevel> {
                        new StaticSkillLevel(skill, level)
                    };

                    // None added ? Then return
                    IPlanOperation operation = TryAddSet(skillsToAdd, noteForNewEntries);
                    operation.PerformAddition(priority);
                }
                else
                {
                    level = Math.Max(level, GetMinimumLevel(skill));

                    // If we reach this point, then we have to remove entries
                    for (int i = 5; i > level; i--)
                    {
                        PlanEntry entry = GetEntry(skill, i);
                        if (entry == null)
                        {
                            continue;
                        }

                        RemoveCore(Items.IndexOf(entry));
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Click on the Next/OK button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void nextButton_Click(object sender, EventArgs e)
        {
            // Are we on the first page ? Then it's "Next >".
            if (nextButton.DialogResult == DialogResult.None)
            {
                rootMultiPanel.SelectedPage = uselessPrereqsSuppressionPage;
                return;
            }

            // Then we're on the last page and the button is now "OK"
            if (m_operation.Type == PlanOperations.Addition)
            {
                m_operation.PerformAddition((int)priorityNumericBox.Value);
            }
            else
            {
                m_operation.PerformSuppression(uselessPrereqsCheckbox.Checked);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }