Represents an award found in the medal data file as an object
상속: IAward
예제 #1
0
        /// <summary>
        /// Used by the parser to add found awards to the list
        /// </summary>
        /// <param name="A"></param>
        public static void AddAward(Award A)
        {
            switch (Award.GetType(A.Id))
            {
                case AwardType.Badge:
                    Badges.Add(A);
                    break;
                case AwardType.Medal:
                    Medals.Add(A);
                    break;
                case AwardType.Ribbon:
                    Ribbons.Add(A);
                    break;
            }

            Awards.Add(A.Id, A);
        }
예제 #2
0
        /// <summary>
        /// Used by the parser to add found awards to the list
        /// </summary>
        /// <param name="A">The Award Object To Add</param>
        public static void AddAward(Award A)
        {
            // Add award to individual award type collection
            switch (Award.GetType(A.Id))
            {
                case AwardType.Badge:
                    Badges.Add(A);
                    break;
                case AwardType.Medal:
                    Medals.Add(A);
                    break;
                case AwardType.Ribbon:
                    Ribbons.Add(A);
                    break;
            }

            // Add the award to the overall awards cache
            Awards.Add(A.Id, A);

            // Build the award tree here to Initially check for condition errors
            A.ToTree();
        }
예제 #3
0
        /// <summary>
        /// Used by the parser to add found awards to the list
        /// </summary>
        /// <param name="A">The Award Object To Add</param>
        public static void AddAward(Award A)
        {
            // Add award to individual award type collection
            switch (Award.GetType(A.Id))
            {
            case AwardType.Badge:
                Badges.Add(A);
                break;

            case AwardType.Medal:
                Medals.Add(A);
                break;

            case AwardType.Ribbon:
                Ribbons.Add(A);
                break;
            }

            // Add the award to the overall awards cache
            Awards.Add(A.Id, A);

            // Build the award tree here to Initially check for condition errors
            A.ToTree();
        }
        /// <summary>
        /// This method is called upon selecting a new Medal Data Profile.
        /// It loads the new medal data, and calls the parser to parse it.
        /// </summary>
        private void ProfileSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Make sure we have an index! Also make sure we didnt select the same profile again
            if (ProfileSelector.SelectedIndex == -1 || ProfileSelector.SelectedItem.ToString() == LastSelectedProfile)
            {
                return;
            }

            // Get current profile
            string Profile = ProfileSelector.SelectedItem.ToString();

            // Make sure the user wants to commit without saving changes
            if (ChangesMade && MessageBox.Show("Some changes have not been saved. Are you sure you want to continue?",
                                               "Confirm", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                ProfileSelector.SelectedIndex = Profiles.IndexOf(LastSelectedProfile.ToLower());
                return;
            }

            // Disable the form to prevent errors. Show loading screen
            this.Enabled = false;
            LoadingForm.ShowScreen(this);

            // Suppress repainting the TreeView until all the objects have been created.
            AwardConditionsTree.Nodes.Clear();
            AwardTree.BeginUpdate();

            // Remove old medal data if applicable
            for (int i = 0; i < 4; i++)
            {
                AwardTree.Nodes[i].Nodes.Clear();
                AwardTree.Nodes[i].ForeColor = Color.Black;
            }

            // Get Medal Data
            try
            {
                MedalDataParser.LoadMedalDataFile(Path.Combine(PythonPath, "medal_data_" + Profile + ".py"));
            }
            catch (Exception ex)
            {
                AwardTree.EndUpdate();
                MessageBox.Show(ex.Message, "Medal Data Parse Error");
                ProfileSelector.SelectedIndex = -1;
                this.Enabled = true;
                LoadingForm.CloseForm();
                return;
            }

            // Iterator for badges
            int itr = -1;

            // Add all awards to the corresponding Node
            foreach (Award A in AwardCache.GetBadges())
            {
                if (Award.GetBadgeLevel(A.Id) == BadgeLevel.Bronze)
                {
                    AwardTree.Nodes[0].Nodes.Add(A.Id, A.Name.Replace("Basic ", ""));
                    ++itr;
                }

                AwardTree.Nodes[0].Nodes[itr].Nodes.Add(A.Id, A.Name.Split(' ')[0]);
            }

            foreach (Award A in AwardCache.GetMedals())
            {
                AwardTree.Nodes[1].Nodes.Add(A.Id, A.Name);
            }

            foreach (Award A in AwardCache.GetRibbons())
            {
                AwardTree.Nodes[2].Nodes.Add(A.Id, A.Name);
            }

            foreach (Rank R in AwardCache.GetRanks())
            {
                AwardTree.Nodes[3].Nodes.Add(R.Id.ToString(), R.Name);
            }

            // Begin repainting the TreeView.
            AwardTree.CollapseAll();
            AwardTree.EndUpdate();

            // Reset current award data
            AwardNameBox.Text     = null;
            AwardTypeBox.Text     = null;
            AwardPictureBox.Image = null;

            // Process Active profile button
            if (Profile == ActiveProfile)
            {
                ActivateProfileBtn.Text            = "Current Server Profile";
                ActivateProfileBtn.BackgroundImage = Resources.check;
            }
            else
            {
                ActivateProfileBtn.Text            = "Set as Server Profile";
                ActivateProfileBtn.BackgroundImage = Resources.power;
            }

            // Apply inital highlighting of condition nodes
            ValidateConditions();

            // Enable form controls
            AwardTree.Enabled           = true;
            AwardConditionsTree.Enabled = true;
            DelProfileBtn.Enabled       = true;
            ActivateProfileBtn.Enabled  = true;
            SaveBtn.Enabled             = true;
            this.Enabled = true;
            LoadingForm.CloseForm();

            // Set this profile as the last selected profile
            LastSelectedProfile = Profile;
            ChangesMade         = false;
        }
        public MedalConditionForm(TreeNode Node)
        {
            InitializeComponent();

            this.Node = Node;
            this.Obj  = (MedalOrRankCondition)Node.Tag;
            List <string> Params = Obj.GetParams();
            int           I      = 0;
            int           Index  = 0;

            // Set default award requirement type
            if (Params[0] == "has_medal")
            {
                AwardType Type = Award.GetType(Params[1]);
                switch (Type)
                {
                case AwardType.Badge:
                    TypeSelect.SelectedIndex = 0;
                    foreach (Award A in AwardCache.GetBadges())
                    {
                        AwardSelect.Items.Add(new KeyValuePair(A.Id, A.Name));
                        if (A.Id == Params[1])
                        {
                            Index = I;
                        }
                        I++;
                    }
                    break;

                case AwardType.Medal:
                    TypeSelect.SelectedIndex = 1;
                    foreach (Award A in AwardCache.GetMedals())
                    {
                        AwardSelect.Items.Add(new KeyValuePair(A.Id, A.Name));
                        if (A.Id == Params[1])
                        {
                            Index = I;
                        }
                        I++;
                    }
                    break;

                case AwardType.Ribbon:
                    TypeSelect.SelectedIndex = 2;
                    foreach (Award A in AwardCache.GetRibbons())
                    {
                        AwardSelect.Items.Add(new KeyValuePair(A.Id, A.Name));
                        if (A.Id == Params[1])
                        {
                            Index = I;
                        }
                        I++;
                    }
                    break;
                }
            }
            else
            {
                TypeSelect.SelectedIndex = 3;
                foreach (Rank R in AwardCache.GetRanks())
                {
                    AwardSelect.Items.Add(new KeyValuePair(R.Id.ToString(), R.Name));
                    if (R.Id.ToString() == Params[1])
                    {
                        Index = I;
                    }
                    I++;
                }
            }

            // Add index change event
            AwardSelect.SelectedIndex        = Index;
            TypeSelect.SelectedIndexChanged += new EventHandler(TypeSelect_SelectedIndexChanged);
        }