/// <summary>
        /// Restores the condition / criteria back to default (vanilla)
        /// </summary>
        private void RestoreToDefaultMenuItem_Click(object sender, EventArgs e)
        {
            // Make sure we have an award selected
            if (SelectedAwardNode == null || SelectedAwardNode.Parent == null)
            {
                MessageBox.Show("Please select an award!");
                return;
            }

            // Delay or tree redraw
            AwardConditionsTree.BeginUpdate();

            // Clear all Nodes
            AwardConditionsTree.Nodes.Clear();

            // Parse award conditions into tree view
            IAward SAward = AwardCache.GetAward(SelectedAwardNode.Name);

            SAward.RestoreDefaultConditions();
            AwardConditionsTree.Nodes.Add(SAward.ToTree());

            // Revalidate
            ValidateConditions(SelectedAwardNode, SAward.GetCondition());

            // Conditions tree's are to be expanded at all times
            AwardConditionsTree.ExpandAll();

            // Redraw the tree
            AwardConditionsTree.EndUpdate();
        }
        /// <summary>
        /// An event called everytime a new award is selected...
        /// It repaints the current award info
        /// </summary>
        private void AwardTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // Set our award globally
            SelectedAwardNode = e.Node;

            // Only proccess child Nodes
            if (SelectedAwardNode.Nodes.Count == 0)
            {
                // Set Award Image
                SetAwardImage(SelectedAwardNode.Name);

                // Set award name and type
                switch (Award.GetType(SelectedAwardNode.Name))
                {
                case AwardType.Badge:
                    AwardTypeBox.Text = "Badge";
                    AwardNameBox.Text = Award.GetName(SelectedAwardNode.Name);
                    break;

                case AwardType.Medal:
                    AwardTypeBox.Text = "Medal";
                    AwardNameBox.Text = Award.GetName(SelectedAwardNode.Name);
                    break;

                case AwardType.Ribbon:
                    AwardTypeBox.Text = "Ribbon";
                    AwardNameBox.Text = Award.GetName(SelectedAwardNode.Name);
                    break;

                case AwardType.Rank:
                    AwardTypeBox.Text = "Rank";
                    AwardNameBox.Text = Rank.GetName(Int32.Parse(SelectedAwardNode.Name));
                    break;
                }

                // Delay or tree redraw
                AwardConditionsTree.BeginUpdate();

                // Clear all Nodes
                AwardConditionsTree.Nodes.Clear();

                // Parse award conditions into tree view
                SelectedAward = AwardCache.GetAward(SelectedAwardNode.Name);
                TreeNode Conds = SelectedAward.ToTree();
                if (Conds != null)
                {
                    AwardConditionsTree.Nodes.Add(Conds);
                }

                // Conditions tree's are to be expanded at all times
                AwardConditionsTree.ExpandAll();

                // Redraw the tree
                AwardConditionsTree.EndUpdate();
            }
        }
Пример #3
0
        /// <summary>
        /// An event called everytime a new award is selected...
        /// It repaints the current award info
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AwardTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode N = e.Node;

            // Only proccess child Nodes
            if (N.Nodes.Count == 0)
            {
                // Set Award Image
                SetAwardImage(N.Name);

                // Set award name and type
                AwardNameBox.Text = N.Text;
                switch (Award.GetType(N.Name))
                {
                    case AwardType.Badge:
                        AwardTypeBox.Text = "Badge";
                        break;
                    case AwardType.Medal:
                        AwardTypeBox.Text = "Medal";
                        break;
                    case AwardType.Ribbon:
                        AwardTypeBox.Text = "Ribbon";
                        break;
                    case AwardType.Rank:
                        AwardTypeBox.Text = "Rank";
                        break;
                }

                // Delay or tree redraw
                AwardConditionsTree.BeginUpdate();

                // Clear all Nodes
                AwardConditionsTree.Nodes.Clear();

                // Parse award conditions into tree view
                SelectedAward = AwardCache.GetAward(N.Name);
                AwardConditionsTree.Nodes.Add(SelectedAward.ToTree());

                // Conditions tree's are to be expanded at all times
                AwardConditionsTree.ExpandAll();

                // Redraw the tree
                AwardConditionsTree.EndUpdate();
            }
        }
        /// <summary>
        /// Brings up the Criteria Editor for the selected Award Condition Node
        /// </summary>
        public void EditCriteria()
        {
            // Make sure we have a node selected
            if (ConditionNode == null)
            {
                MessageBox.Show("Please select a criteria to edit.");
                return;
            }

            // Make sure its a child node
            if (ConditionNode.Parent == null && ConditionNode.Nodes.Count != 0)
            {
                return;
            }

            // Open correct condition editor form
            if (ConditionNode.Tag is ObjectStat)
            {
                Child = new ObjectStatForm(ConditionNode);
            }
            else if (ConditionNode.Tag is PlayerStat)
            {
                Child = new ScoreStatForm(ConditionNode);
            }
            else if (ConditionNode.Tag is MedalOrRankCondition)
            {
                Child = new MedalConditionForm(ConditionNode);
            }
            else if (ConditionNode.Tag is GlobalStatMultTimes)
            {
                Child = new GlobalStatMultTimesForm(ConditionNode);
            }
            else if (ConditionNode.Tag is ConditionList)
            {
                Child = new ConditionListForm(ConditionNode);
            }
            else
            {
                return;
            }

            if (Child.ShowDialog() == DialogResult.OK)
            {
                // Delay tree redraw
                AwardConditionsTree.BeginUpdate();

                // Set awards new conditions from the tree node tagged conditions
                SelectedAward.SetCondition(MedalDataParser.ParseNodeConditions(AwardConditionsTree.Nodes[0]));

                // Clear all current Nodes
                AwardConditionsTree.Nodes.Clear();

                // Reparse conditions
                AwardConditionsTree.Nodes.Add(SelectedAward.ToTree());

                // Validation highlighting
                ValidateConditions(SelectedAwardNode, SelectedAward.GetCondition());

                // Conditions tree's are to be expanded at all times
                AwardConditionsTree.ExpandAll();
                AwardConditionsTree.EndUpdate();
            }
        }