Exemple #1
0
        private async void StepGenerateMaps(int choise, List <MapEntry> maps)
        {
            switch (choise)
            {
            case 0:     // download
                _originalMapStep.Visible = false;
                _creationMapsStep        = new CreationMapsStep {
                    Parent = panel1
                };

                await _creationMapsStep.ExecuteAction(choise, maps);

                //Global.Maps.AddRange(maps);
                foreach (MapEntry map in maps)
                {
                    Global.Maps[map.Index] = map;
                }

                MapsManager.SaveMaps();
                CloseSafe();
                break;

            case 1:     // generate classic
            {
                _originalMapStep.Visible = false;


                FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
                folderBrowserDialog.Description = "Select Ultima Online directory";
                while (true)
                {
                    DialogResult result = folderBrowserDialog.ShowDialog();
                    if (result == DialogResult.Cancel)
                    {
                        Process.GetCurrentProcess().Kill();
                    }
                    else if (result == DialogResult.OK)
                    {
                        DirectoryInfo info = new DirectoryInfo(folderBrowserDialog.SelectedPath);
                        if (info.Exists && info.EnumerateFiles().Where(s => (s.Name.Contains("map") || s.Name.Contains("facet")) && (s.Extension == ".uop" || s.Extension == ".mul" || s.Extension == ".dds")).Count() > 0)
                        {
                            Global.UOPath = folderBrowserDialog.SelectedPath;
                            break;
                        }

                        MessageBox.Show("Wrong directory selected.");
                    }
                }

                _creationMapsStep = new CreationMapsStep {
                    Parent = panel1
                };

                await _creationMapsStep.ExecuteAction(choise, maps);

                foreach (MapEntry map in maps)
                {
                    Global.Maps[map.Index] = map;
                }
                MapsManager.SaveMaps();
                CloseSafe();
            }
            break;

            case 2:     // generate custom
            {
                _customMapStep.Visible = false;

                FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
                folderBrowserDialog.Description = "Select Ultima Online directory";

                while (true)
                {
                    DialogResult result = folderBrowserDialog.ShowDialog();
                    if (result == DialogResult.Cancel)
                    {
                        Process.GetCurrentProcess().Kill();
                    }
                    else if (result == DialogResult.OK)
                    {
                        DirectoryInfo info = new DirectoryInfo(folderBrowserDialog.SelectedPath);
                        if (info.Exists && info.EnumerateFiles().Where(s => (s.Name.Contains("map") || s.Name.Contains("facet")) && (s.Extension == ".uop" || s.Extension == ".mul" || s.Extension == ".dds")).Count() > 0)
                        {
                            Global.UOPath = folderBrowserDialog.SelectedPath;
                            break;
                        }

                        MessageBox.Show("Wrong directory selected.");
                    }
                }

                _creationMapsStep = new CreationMapsStep {
                    Parent = panel1
                };


                await _creationMapsStep.ExecuteAction(choise, maps);

                foreach (MapEntry map in maps)
                {
                    Global.Maps[map.Index] = map;
                }
                MapsManager.SaveMaps();
                CloseSafe();
            }
            break;

            case 3:     // back
                if (panel1.Contains(_originalMapStep))
                {
                    panel1.Controls.Remove(_originalMapStep);
                }
                else if (panel1.Contains(_customMapStep))
                {
                    panel1.Controls.Remove(_customMapStep);
                }

                _kindClientStep.Visible = true;
                break;
            }
        }