Example #1
0
        //
        //
        //Open or Create Projects
        //
        public void OpenJetForm()
        {
            if (!Guard.IsStringValid(Serializer.cfg.LastProject))
            {
                return;
            }

            DirectoryInfo dinfo = new DirectoryInfo(Serializer.cfg.LastProject);

            if (!dinfo.Exists)
            {
                return;
            }

            foreach (JetForm o in JetProps.get())
            {
                if (o.projName == Serializer.cfg.LastProject)
                {
                    MessageBox.Show("The project is already opened..");
                    return;
                }
            }

            JetForm jf = new JetForm(dinfo, dinfo.Name);

            jf.MdiParent = this;
            jf.Show();
            Serializer.cfg.LastProject = dinfo.ToString();
        }
Example #2
0
        private void BrowseForExistingProjects()    //check this if having issues with last project
        {
            string path = BrowseForDirectory("Browse for an existing project", Environment.CurrentDirectory);

            if (path != null && path != "")
            {
                string[] split = path.Split('\\');
                string   name  = split[split.Length - 1];
                if (!name.StartsWith("proj_"))
                {
                    ConsoleHandler.append("Invalid project... Please browse for a folder that starts with    proj_");
                    MessageBox.Show("Error!! Not a valid project file. Please try again...");
                }
                else
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(path);
                    Serializer.cfg.LastProject = path;
                    if (path.Contains("BTD5"))
                    {
                        Serializer.cfg.CurrentGame = "BTD5";
                    }
                    else if (path.Contains("BTDB"))
                    {
                        Serializer.cfg.CurrentGame = "BTDB";
                    }
                    else if (path.Contains("BMC"))
                    {
                        Serializer.cfg.CurrentGame = "BMC";
                    }

                    JetForm jf = new JetForm(dirInfo, name);
                    jf.MdiParent = this;
                    jf.Show();
                    Serializer.SaveSettings();
                }
            }
        }
Example #3
0
        private void Extract_OnThread()
        {
            destPath = CurrentProjectVariables.PathToProjectFiles;
            DirectoryInfo dinfo = new DirectoryInfo(destPath);

            if (!dinfo.Exists)
            {
                ConsoleHandler.append("Creating project files for: " + projName);

                ZipFile archive = new ZipFile(sourcePath);
                archive.Password = password;
                totalFiles       = archive.Count();
                filesTransfered  = 0;

                try
                {
                    archive.ExtractProgress += ZipExtractProgress;
                    archive.ExtractAll(destPath);
                    archive.Dispose();
                }
                catch (Exception ex)
                {
                    error = true;
                    PrintError(ex.Message);
                }

                //Commented this out for now

                /*
                 * if (CurrentProjectVariables.GameName == "BMC")
                 * {
                 *  DialogResult diag = MessageBox.Show("Would you like to extract the Asset Bundles as well? " +
                 *      "They mostly have to do with textures and maps, and" +
                 *      " while you can mod those as well as anything else from data.jet, they are not necessary." +
                 *      "\nNote: Your project will take up more space", "Extract Asset Bundles as well?", MessageBoxButtons.YesNo);
                 *  if(diag == DialogResult.Yes)
                 *  {
                 *      Invoke((MethodInvoker)delegate {
                 *          Filename_TB.Text = "AssetBundles";
                 *      });
                 *      ExtractAssetBundleJet();
                 *  }
                 * }*/
                if (error == false)
                {
                    if (!Directory.Exists(Environment.CurrentDirectory + "\\Backups\\" + gameName + "_BackupProject"))
                    {
                        string gamed = "";
                        if (gameName == "BTD5")
                        {
                            gamed = Serializer.cfg.BTD5_Directory;
                        }
                        else if (gameName == "BTDB")
                        {
                            gamed = Serializer.cfg.BTDB_Directory;
                        }
                        else if (gameName == "BMC")
                        {
                            gamed = Serializer.cfg.BMC_Directory;
                        }

                        //they should have a backup jet of gamed not invalid. create backup proj
                        if (error == false && gamed != "" && gamed != null)
                        {
                            ConsoleHandler.force_append_Notice("Backup project not detected.... Creating one now..");
                            Invoke((MethodInvoker) delegate {
                                this.Focus();

                                destPath                 = Environment.CurrentDirectory + "\\Backups\\" + gameName + "_BackupProject";
                                archive                  = new ZipFile(sourcePath);
                                archive.Password         = password;
                                totalFiles               = archive.Count();
                                filesTransfered          = 0;
                                archive.ExtractProgress += ZipExtractProgress;

                                try
                                {
                                    archive.ExtractAll(destPath);
                                    archive.Dispose();
                                }
                                catch (Exception ex)
                                {
                                    error = true;
                                    PrintError(ex.Message);
                                }


                                //Commented this out for now

                                /*if (gameName == "BMC")
                                 * {
                                 *  DialogResult diag = MessageBox.Show("Would you like to extract the Asset Bundles as well? " +
                                 * "They mostly have to do with textures and maps, and" +
                                 * " while you can mod those as well as anything else from data.jet, they are not necessary." +
                                 * "\nNote: Your project will take up more space", "Extract Asset Bundles as well?", MessageBoxButtons.YesNo);
                                 *  if (diag == DialogResult.Yes)
                                 *  {
                                 *      Invoke((MethodInvoker)delegate {
                                 *          Filename_TB.Text = "AssetBundles";
                                 *      });
                                 *      ExtractAssetBundleJet();
                                 *  }
                                 * }*/
                            });
                        }
                        else
                        {
                            ConsoleHandler.force_append_Notice("Unable to find backup project or the game directory. Backup project WILL NOT be made, and you will NOT be able to use \"Restore to original\" until you browse for your game..");
                        }
                    }
                    ConsoleHandler.append("Project files created at: " + CurrentProjectVariables.PathToProjectFiles);
                    Invoke((MethodInvoker) delegate {
                        jf           = new JetForm(dinfo, dinfo.Name);
                        jf.MdiParent = Main.getInstance();
                        jf.Show();
                    });
                }
                else
                {
                    try
                    { this.Invoke(new Action(() => this.Close())); }
                    catch (Exception ex)
                    {
                        error = true;
                        PrintError(ex.Message);
                    }
                }
            }
            else
            {
                DialogResult varr = MessageBox.Show("A project with this name already exists. Do you want to replace it?", "", MessageBoxButtons.OKCancel);
                if (varr == DialogResult.OK)
                {
                    MessageBox.Show("Please close the Jet viewer for the old project...");
                    ConsoleHandler.append("Deleting existing project....");
                    MessageBox.Show(dinfo.ToString());
                    DeleteDirectory(dinfo.ToString());
                    ConsoleHandler.append("Project Deleted. Creating new project...");
                    Extract_OnThread();
                    return;
                }
                if (varr == DialogResult.Cancel)
                {
                    try
                    { this.Invoke(new Action(() => this.Close())); }
                    catch (Exception ex)
                    {
                        error = true;
                        PrintError(ex.Message);
                    }
                }
            }
            try
            { this.Invoke(new Action(() => this.Close())); }
            catch (Exception ex)
            {
                error = true;
                PrintError(ex.Message);
            }
        }