// // //UI Buttons // private void OpenJetExplorer_Click(object sender, EventArgs e) { try { if (JetProps.get().Count > 0) { foreach (var a in JetProps.get()) { if (a.Visible) { ConsoleHandler.append("Hiding JetViewer"); a.Hide(); } else { ConsoleHandler.append("Reopening JetViewer"); a.Show(); } } } else { OpenJetForm(); } } catch (Exception ex) { ConsoleHandler.append(ex.StackTrace); } }
// // //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 SaveLastJetViewer() { var list = JetProps.get(); if (list.Count <= 0) { return; } int i = 0; foreach (var jetprop in list) { if (jetprop.projName == CurrentProjectVariables.PathToProjectFiles) { break; } i++; } i = i - 1; cfg.JetExplorer_SizeX = list[i].Size.Width; cfg.JetExplorer_SizeY = list[i].Size.Height; cfg.JetExplorer_PosX = list[i].Location.X; cfg.JetExplorer_PosY = list[i].Location.Y; cfg.JetExplorer_FontSize = list[i].Font.Size; cfg.JetExplorer_SplitterWidth = jetExplorer_SplitterWidth; cfg.JetExplorer_FolderView_FontSize = jetExplorer_FontSize; if (CurrentProjectVariables.PathToProjectFiles != null) { cfg.LastProject = CurrentProjectVariables.PathToProjectFiles.Replace("\\\\", "\\"); } }
private void CheckIfModified(string pathToFile) { string backupfile = Environment.CurrentDirectory + "\\Backups\\" + CurrentProjectVariables.GameName + "_Original.jet"; if (!File.Exists(pathToFile) || !File.Exists(backupfile)) { if (JetProps.get().Count <= 0) { return; } if (!File.Exists(pathToFile)) { ConsoleHandler.append_Force("Can't check if file is modified because the file itself was not found. Was it deleted?"); } else if (!File.Exists(backupfile)) { ConsoleHandler.append_Force("Can't check if file is modified because the backup was not found"); } return; } ZipFile backup = new ZipFile(backupfile); backup.Password = CurrentProjectVariables.JetPassword; string modText = RemoveWhitespace(File.ReadAllText(pathToFile)); string pathInZip = pathToFile.Replace(CurrentProjectVariables.PathToProjectFiles + "\\", ""); string originalText = RemoveWhitespace(ProjectHandler.ReadTextFromZipFile(backup, pathInZip)); try { if (modText == originalText) { //file not modded if (CurrentProjectVariables.ModifiedFiles.Contains(pathToFile)) { CurrentProjectVariables.ModifiedFiles.Remove(pathToFile); } } else { //file modded if (!CurrentProjectVariables.ModifiedFiles.Contains(pathToFile)) { CurrentProjectVariables.ModifiedFiles.Add(pathToFile); } } } catch { //exception occurred. file probably modded if (!CurrentProjectVariables.ModifiedFiles.Contains(pathToFile)) { CurrentProjectVariables.ModifiedFiles.Add(pathToFile); } } ProjectHandler.SaveProject(); }
public static void CompileJet(string switchCase) { if (New_JsonEditor.isJsonError != true) { if (JetProps.get().Count == 1) { string dest = ""; bool isOutputting = false; bool abort = false; var zip = new ZipForm(); if (switchCase.Contains("output")) { isOutputting = true; string exPath = CurrentProjectVariables.ExportPath; if (exPath != "" && exPath != null) { DialogResult diag = MessageBox.Show("Do you want export to the same place as last time?", "Export to the same place?", MessageBoxButtons.YesNo); if (diag == DialogResult.Yes) { dest = exPath; } else { exPath = ""; } } if (exPath == "" || exPath == null) { ConsoleHandler.append("Select where you want to export your jet file. Make sure to give it a name.."); dest = OutputJet(); CurrentProjectVariables.ExportPath = dest; ProjectHandler.SaveProject(); //ZipForm.savedExportPath = dest; //Serializer.SaveSmallSettings("export path"); } zip.destPath = dest; } else if (switchCase.Contains("launch")) { if (switchCase.Contains("nkh")) { zip.launchNKH = true; } if (CurrentProjectVariables.GamePath != null && CurrentProjectVariables.GamePath != "") { zip.launch = true; zip.destPath = CurrentProjectVariables.GamePath + "\\Assets\\" + ReturnJetName(CurrentProjectVariables.GameName); } else { ConsoleHandler.force_append_Notice("Unable to find your game directory, and therefore, unable to launch. Do you want to try browsing for your game?"); DialogResult diag = MessageBox.Show("Unable to find your game directory, and therefore, unable to launch. Do you want to try browsing for your game?", "Browse for game?", MessageBoxButtons.YesNoCancel); if (diag == DialogResult.Yes) { browseForExe(CurrentProjectVariables.GameName); } if (diag == DialogResult.No) { DialogResult diag2 = MessageBox.Show("Do you want to just save your jet file instead?", "Save jet instead?", MessageBoxButtons.YesNo); { if (diag2 == DialogResult.Yes) { isOutputting = true; string exPath = CurrentProjectVariables.ExportPath; if (exPath != "" && exPath != null) { DialogResult diagz = MessageBox.Show("Do you want export to the same place as last time?", "Export to the same place?", MessageBoxButtons.YesNo); if (diagz == DialogResult.Yes) { dest = exPath; } else { exPath = ""; } } if (exPath == "" || exPath == null) { ConsoleHandler.append("Select where you want to export your jet file. Make sure to give it a name.."); dest = OutputJet(); CurrentProjectVariables.ExportPath = dest; ProjectHandler.SaveProject(); /*ZipForm.savedExportPath = dest; * Serializer.SaveSmallSettings("export path");*/ } zip.destPath = dest; } } } else { abort = true; } } } if (!abort) { if (isOutputting) { if (dest != null && dest != "") { zip.destPath = dest; zip.Show(); zip.Compile(); } else { ConsoleHandler.append("Export cancelled..."); } } else { zip.Show(); zip.Compile(); } } } else { if (JetProps.get().Count < 1) { MessageBox.Show("You have no .jets or projects open, you need one to launch."); ConsoleHandler.append("You need to open a project to continue..."); } else { MessageBox.Show("You have multiple .jets or projects open, only one can be launched."); ConsoleHandler.append("You need to close projects to continue..."); } } } }