예제 #1
0
파일: Main.cs 프로젝트: Glought/MultiMC
        void InstCopied(object sender, InstActionEventArgs e)
        {
            StopInstCopy();

            string instName = AskInstName("Copy instance");

            if (string.IsNullOrEmpty(instName))
                return;

            string newInstDir = Instance.GetValidDirName(instName,
                AppSettings.Main.InstanceDir);
            newInstDir = Path.Combine(AppSettings.Main.InstanceDir, newInstDir);

            DirCopyTask copyTask = new DirCopyTask(e.Inst.RootDir, newInstDir);
            StartModalTask(copyTask);

            Instance copiedInst = Instance.LoadInstance(newInstDir);
            copiedInst.Name = instName;
            copiedInst.Dispose();

            MainWindow.LoadInstances();
        }
예제 #2
0
파일: Main.cs 프로젝트: Glought/MultiMC
        void ImportExistingInstall()
        {
            SelectFolder:
            string path = MainWindow.ImportInstance();

            if (string.IsNullOrEmpty(path))
                return;

            if (!Directory.Exists(path))
            {
                MessageDialog.Show(MainWindow,
                    "The specified folder doesn't exist.", "Error");
                goto SelectFolder; // Gotos are cool.
            }

            if (!File.Exists(Path.Combine(path, "bin", "minecraft.jar")))
            {
                DialogResponse response = MessageDialog.Show(MainWindow,
                    "Couldn't find minecraft.jar. Do you really want to import this?",
                    "That doesn't look like Minecraft!", MessageButtons.YesNo);
                if (response != DialogResponse.Yes)
                    goto SelectFolder; // Again, gotos are cool.
            }

            string instName = AskInstName("Import .minecraft folder");

            if (string.IsNullOrEmpty(instName))
                return;

            // Create the new instance.
            Instance inst = new Instance(instName,
                Path.Combine(AppSettings.Main.InstanceDir,
                    Instance.GetValidDirName(instName,
                        AppSettings.Main.InstanceDir)));

            // Copy the .minecraft folder into the new instance.
            DirCopyTask dirCopy = new DirCopyTask(path, inst.MinecraftDir);
            StartModalTask(dirCopy, MainWindow);

            MainWindow.LoadInstances();
        }