コード例 #1
0
ファイル: ZipForm.cs プロジェクト: yassin889/BTDToolbox
        public void Compile()
        {
            if (!IsGameRunning(gameName))
            {
                this.Text        = "Compiling " + CurrentProjectVariables.ProjectName;
                Filename_TB.Text = ReturnJetName(gameName);

                if (gameName == "BTDB")
                {
                    if (rememberedPassword != null && rememberedPassword != "")
                    {
                        password = rememberedPassword;
                        Serializer.SaveSettings();
                        CurrentProjectVariables.JetPassword = password;
                        ProjectHandler.SaveProject();
                    }

                    if (password == null || password.Length <= 0)
                    {
                        var getpas = new Get_BTDB_Password();
                        getpas.launch       = launch;
                        getpas.isExtracting = false;
                        getpas.projName     = projName;
                        getpas.destPath     = destPath;
                        getpas.Show();
                        this.Close();
                    }
                    else
                    {
                        backgroundThread = new Thread(Compile_OnThread);
                        backgroundThread.Start();
                    }
                }
                else
                {
                    backgroundThread = new Thread(Compile_OnThread);
                    backgroundThread.Start();
                }
            }
            else
            {
                ConsoleHandler.force_append_Notice("Game is currently running. Please close the game and try again...");
                this.Close();
            }
        }
コード例 #2
0
ファイル: ZipForm.cs プロジェクト: yassin889/BTDToolbox
        public void Extract()
        {
            bool rememberPass = Get_BTDB_Password.rememberPass;

            this.Text        = "Extracting..";
            Filename_TB.Text = ReturnJetName(gameName);

            if (existingJetFile == "")
            {
                if (sourcePath == null || sourcePath == "")
                {
                    sourcePath = Environment.CurrentDirectory + "\\Backups\\" + gameName + "_Original.jet";
                }
            }
            else
            {
                sourcePath = existingJetFile;
            }

            if (File.Exists(sourcePath))
            {
                if (projName == "" || projName == null)
                {
                    projName = CurrentProjectVariables.ProjectName;
                }
                //check password
                if (File.Exists(sourcePath) && gameName == "BTDB")
                {
                    this.Hide();
                    bool badPass = Bad_JetPass(sourcePath, password);

                    if (badPass == true)
                    {
                        DialogResult res = MessageBox.Show("You entered the wrong password. Would you like to try again?", "Wrong Password!", MessageBoxButtons.OKCancel);
                        if (res == DialogResult.OK)
                        {
                            var getpas = new Get_BTDB_Password();
                            getpas.projName     = projName;
                            getpas.isExtracting = true;

                            if (rememberPass == true)
                            {
                                Get_BTDB_Password.rememberPass = true;
                            }
                            else
                            {
                                Get_BTDB_Password.rememberPass = false;
                            }
                            getpas.Show();
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        this.Show();
                        if (rememberedPassword != null && rememberedPassword != "")
                        {
                            password = rememberedPassword;
                            Serializer.SaveSettings();
                        }
                        backgroundThread = new Thread(Extract_OnThread);
                        backgroundThread.Start();
                    }
                }
                else
                {
                    backgroundThread = new Thread(Extract_OnThread);
                    backgroundThread.Start();
                }
            }
            else
            {
                ConsoleHandler.append("ERROR!!! Failed to find file to extract");
                if (isGamePathValid(gameName))
                {
                    ConsoleHandler.append("Generating new backup...");
                    CreateBackup(gameName);
                    ConsoleHandler.append("Creating project from backup...");
                    backgroundThread = new Thread(Extract_OnThread);
                    backgroundThread.Start();
                }
                else
                {
                    ConsoleHandler.append("ERROR!!! Failed to validate game path. Please browse for " + Get_EXE_Name(gameName));
                    browseForExe(gameName);
                    if (isGamePathValid(gameName))
                    {
                        this.Show();
                        backgroundThread = new Thread(Extract_OnThread);
                        backgroundThread.Start();
                    }
                    else
                    {
                        ConsoleHandler.append("There was an issue... Please try again...");
                        this.Close();
                    }
                }
            }
        }
コード例 #3
0
        private void SubmitModName()
        {
            if (CustomName_RadioButton.Checked)
            {
                ConsoleHandler.append("You chose the project name: " + ProjectName_TextBox.Text);
            }
            else
            {
                ConsoleHandler.append("You chose a random project name");
            }
            if (isRenaming == true)
            {
                this.Hide();
                RenameProject();
                this.Close();
                return;
            }

            bool   writeProj = true;
            string projName  = ReturnName(ProjectName_TextBox.Text, gameName);
            string projdir   = "";

            if (Guard.IsStringValid(customFolder))
            {
                projdir = customFolder + "\\" + projName;
            }
            else
            {
                projdir = Environment.CurrentDirectory + "\\Projects\\" + projName;
            }

            if (Directory.Exists(projdir))
            {
                var result = MessageBox.Show("A project with this name already exists, do you want to replace it with a new one?", "Replace Existing Project?", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Cancel)
                {
                    writeProj = false;
                    this.Close();
                }
                else
                {
                    if (result == DialogResult.Yes)
                    {
                        ConsoleHandler.append("Deleting original project");
                        try
                        {
                            Directory.Delete(projdir, true);
                        }
                        catch { ConsoleHandler.append("Directory is currently open in windows file explorer..."); }
                        writeProj = true;
                    }
                    else
                    {
                        writeProj = false;
                        ProjectName_TextBox.Text = "";
                    }
                }
            }

            if (writeProj == true)
            {
                if (!Directory.Exists(projdir))
                {
                    Directory.CreateDirectory(projdir);
                }

                string backupPath = Environment.CurrentDirectory + "\\Backups\\" + CurrentProjectVariables.GameName + "_Original.jet";
                if (!GeneralMethods.Validate_Backup(gameName))
                {
                    GeneralMethods.CreateBackup(gameName);
                }

                if (File.Exists(backupPath))
                {
                    if (!Directory.Exists(projdir))
                    {
                        Directory.CreateDirectory(projdir);
                    }

                    CurrentProjectVariables.ProjectName            = projName;
                    CurrentProjectVariables.PathToProjectClassFile = projdir;
                    CurrentProjectVariables.PathToProjectFiles     = projdir + "\\" + projName;
                    CurrentProjectVariables.UseNKHook = UseNKH_CB.Checked;
                    ProjectHandler.SaveProject();

                    if (gameName == "BTDB")
                    {
                        var getPasss = new Get_BTDB_Password();
                        getPasss.Show();
                        getPasss.isExtracting = true;
                        this.Close();
                    }
                    else
                    {
                        var zip = new ZipForm();
                        zip.Show();
                        zip.Extract();
                        this.Close();
                    }
                }
                else
                {
                    ConsoleHandler.append_Force("Unable to locate or create backup... Cancelling project creation...");
                    if (Directory.Exists(projdir))
                    {
                        Directory.Delete(projdir);
                    }
                    this.Close();
                }
            }

            //This stuff is for zip projects

            /*if (gameName != "BTDB")
             * {
             *  CurrentProjectVariables.JetPassword = "******";
             *  ProjectHandler.SaveProject();
             *
             *  DirectoryInfo dinfo = new DirectoryInfo(projdir);
             *  jetf = new JetForm(dinfo, Main.getInstance(), dinfo.Name);
             *  jetf.MdiParent = Main.getInstance();
             *  jetf.Show();
             *  jetf.PopulateTreeview();
             * }
             * else
             * {
             *  var getPasss = new Get_BTDB_Password();
             *  getPasss.Show();
             * }
             * this.Close();*/
        }