Example #1
0
        void mergeBox_ButtonPressed(object sender, EventArgs e)
        {
            openFileDialog1.Filter = openprojectfilter;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string projectPath = openFileDialog1.FileName;
                var    version     = EditorForm.GetProjectVersion(projectPath);
                var    mgb         = sender as MergeGroupBox;
                mgb.ProjectPath = projectPath;
                mgb.ComboBox.Items.Clear();
                mgb.ProjectVersion = version;
                switch (version)
                {
                case 1:
                    mgb.ComboBox.Items.Add(AvailableDifficulty.Base.ToString());
                    break;

                default:
                    var ad = EditorForm.GetDifficultyAvailable(Path.Combine(Path.GetDirectoryName(projectPath), Path.GetFileNameWithoutExtension(projectPath)));
                    foreach (AvailableDifficulty difficulty in EditorForm.DifficultyArray)
                    {
                        if (difficulty != AvailableDifficulty.None && (ad & difficulty) == difficulty)
                        {
                            mgb.ComboBox.Items.Add(difficulty);
                        }
                    }
                    break;
                }
                if (mgb.ComboBox.Items.Count > 0)
                {
                    mgb.ComboBox.SelectedIndex = 0;
                }
                else
                {
                    MessageBox.Show(Utility.Language["NoAvailableDifficulty"]);
                }
            }
            else
            {
                var mgb = sender as MergeGroupBox;
                mgb.ProjectPath = "";
                mgb.ComboBox.Items.Clear();
            }
            CheckEnable();
        }
Example #2
0
        public MergeInfo GetMergeInfo(AvailableDifficulty difficulty)
        {
            string projectPath    = "";
            AvailableDifficulty d = AvailableDifficulty.None;
            int version           = 0;

            switch (difficulty)
            {
            case AvailableDifficulty.Easy:
                projectPath = mergeGroupBox1.ProjectPath;
                d           = EditorForm.GetDifficultyFromString(mergeGroupBox1.ComboBox.SelectedItem.ToString());
                version     = mergeGroupBox1.ProjectVersion;
                break;

            case AvailableDifficulty.Normal:
                projectPath = mergeGroupBox2.ProjectPath;
                d           = EditorForm.GetDifficultyFromString(mergeGroupBox2.ComboBox.SelectedItem.ToString());
                version     = mergeGroupBox2.ProjectVersion;
                break;

            case AvailableDifficulty.Hard:
                projectPath = mergeGroupBox3.ProjectPath;
                d           = EditorForm.GetDifficultyFromString(mergeGroupBox3.ComboBox.SelectedItem.ToString());
                version     = mergeGroupBox3.ProjectVersion;
                break;

            case AvailableDifficulty.Extreme:
                projectPath = mergeGroupBox4.ProjectPath;
                d           = EditorForm.GetDifficultyFromString(mergeGroupBox4.ComboBox.SelectedItem.ToString());
                version     = mergeGroupBox4.ProjectVersion;
                break;

            case AvailableDifficulty.Base:
                projectPath = mergeGroupBox5.ProjectPath;
                d           = EditorForm.GetDifficultyFromString(mergeGroupBox5.ComboBox.SelectedItem.ToString());
                version     = mergeGroupBox5.ProjectVersion;
                break;

            case AvailableDifficulty.None:
                return(null);
            }
            return(new MergeInfo(projectPath, version, d));
        }