// // //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(); }
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(); } } }
public static void launchGame(JetForm form) {/* * while (true) * { * ConsoleHandler.appendLog("Launching game..."); * try * { * string gameJetPath = Settings.readGamePath() + "\\..\\Assets\\BTD5.jet"; * if (!File.Exists(Environment.CurrentDirectory + "\\Backups\\Original.jet")) * { * ConsoleHandler.appendLog("Jet backup not found, creating one..."); * Directory.CreateDirectory(Environment.CurrentDirectory + "\\Backups"); * File.Copy(gameJetPath, Environment.CurrentDirectory + "\\Backups\\Original.jet"); * ConsoleHandler.appendLog("Backup done"); * } * DirectoryInfo projDir = new DirectoryInfo(Environment.CurrentDirectory + "\\" + form.projName); * ConsoleHandler.appendLog("Compiling jet..."); * ExtractingJet_Window.isDecompiling = false; * ExtractingJet_Window.isCompiling = true; * ExtractingJet_Window.launchProgram = true; * ExtractingJet_Window ejw = new ExtractingJet_Window(); * ejw.compile(projDir, gameJetPath); * ConsoleHandler.appendLog("Jet compiled"); * Process.Start(Settings.readGamePath()); * ConsoleHandler.appendLog("Steam is taking over for the rest of the launch."); * break; * } * catch (Exception exc) * { * ConsoleHandler.appendLog(exc.ToString()); * ConsoleHandler.appendLog("No launch dir defined or is wrong."); * OpenFileDialog fileDiag = new OpenFileDialog(); * fileDiag.Title = "Open game exe"; * fileDiag.DefaultExt = "exe"; * fileDiag.Filter = "Exe files (*.exe)|*.exe|All files (*.*)|*.*"; * fileDiag.Multiselect = false; * if (fileDiag.ShowDialog() == DialogResult.OK) * { * string file = fileDiag.FileName; * Settings.setGamePath(file); * string jet = file + "\\..\\Assets\\BTD5.jet"; * if(!File.Exists(Environment.CurrentDirectory + "\\Backups\\Original.jet")) * { * ConsoleHandler.appendLog("Jet backup not found, creating one..."); * Directory.CreateDirectory(Environment.CurrentDirectory + "\\Backups"); * File.Copy(jet, Environment.CurrentDirectory + "\\Backups\\Original.jet"); * ConsoleHandler.appendLog("Backup done"); * } * ConsoleHandler.appendLog("Launch settings saved in launchSettings.txt"); * } * else * { * ConsoleHandler.appendLog("Launch cancelled"); * break; * } * } * } * } * * public static void restoreGame() * { * if (!File.Exists(Environment.CurrentDirectory + "\\Backups\\Original.jet")) * { * MessageBox.Show("No backup found that can be restored! Use steam to re-download the original .jet"); * return; * } * ConsoleHandler.appendLog("Restoring backup .jet"); * string gameJetPath = Settings.readGamePath() + "\\..\\Assets\\BTD5.jet"; * File.Delete(gameJetPath); * File.Copy(Environment.CurrentDirectory + "\\Backups\\Original.jet", gameJetPath); * ConsoleHandler.appendLog("Backup restored"); * MessageBox.Show("Backup .jet restored!"); * }*/ }
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); } }
public static void decrement(JetForm form) { jetformlist.Remove(form); //ConsoleHandler.append("Jet windows opened: " + jetformlist.Count); }