Example #1
0
        public void ExtractAssetBundleJet()
        {
            string destPath          = CurrentProjectVariables.PathToProjectFiles + "\\AssetBundles";
            string backupAssetBundle = Environment.CurrentDirectory + "\\Backups\\AssetBundles_Original";

            if (!Directory.Exists(backupAssetBundle))
            {
                ConsoleHandler.append("Unable to find the Backup for BMC Asset Bundles. Reaquiring...");
                GeneralMethods.CreateBackup("BMC");
            }
            var jets = new DirectoryInfo(backupAssetBundle).GetFiles();

            foreach (var jet in jets)
            {
                if (jet.Name.EndsWith(".jet"))
                {
                    Invoke((MethodInvoker) delegate {
                        Filename_TB.Text = "Asset Bundle: " + jet.Name;
                    });
                    string dest = (destPath + "\\" + jet.Name).Replace("/", "\\");

                    ZipFile zip = new ZipFile(jet.FullName);
                    zip.Password = CurrentProjectVariables.JetPassword;
                    foreach (ZipEntry z in zip)
                    {
                        //string dest = (destPath + "\\" + jet.Name + "\\" + z.FileName).Replace("/", "\\");
                        if (z.FileName.Contains("JSON") && !dest.Contains(".tmp"))
                        {
                            z.ExtractWithPassword(dest, ExtractExistingFileAction.OverwriteSilently, CurrentProjectVariables.JetPassword);
                        }
                    }
                    zip.Dispose();
                }
            }
        }
Example #2
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();*/
        }