public static ProjectClass.ProjectFile ReadProject(string projFile) { if (project != null) { CurrentProjectVariables.ResetProjectVariables(); } if (project == null) { project = new ProjectClass.ProjectFile(); } if (!File.Exists(projFile)) { ConsoleHandler.append("Something went wrong when trying to read the" + "project. Project not found..."); return(null); //Create new project //CreateProject(); //Commented out until im sure this is what needs to happen next } if (!IsProjectVald(projFile)) { return(null); } string json = File.ReadAllText(projFile); project = JsonConvert.DeserializeObject <ProjectClass.ProjectFile>(json); CurrentProjectVariables.ProjectName = project.ProjectName.Replace("\\", ""); CurrentProjectVariables.PathToProjectFiles = project.PathToProjectFiles.Replace("\\\\", "\\"); CurrentProjectVariables.PathToProjectClassFile = project.PathToProjectClassFile.Replace("\\\\", "\\"); CurrentProjectVariables.GameName = project.GameName; CurrentProjectVariables.GamePath = project.GamePath.Replace("\\\\", "\\"); CurrentProjectVariables.GameVersion = project.GameVersion; CurrentProjectVariables.JetPassword = project.JetPassword; CurrentProjectVariables.ExportPath = project.ExportPath; CurrentProjectVariables.DateLastOpened = project.DateLastOpened; CurrentProjectVariables.JsonEditor_OpenedTabs = project.JsonEditor_OpenedTabs; CurrentProjectVariables.ModifiedFiles = project.ModifiedFiles; CurrentProjectVariables.UseNKHook = false; CurrentProjectVariables.DontAskAboutNKH = false; if (CurrentProjectVariables.GameName == "BTD5") { if (NKHook.DoesNkhExist()) { CurrentProjectVariables.UseNKHook = project.UseNKHook; CurrentProjectVariables.DontAskAboutNKH = project.DontAskAboutNKH; } } return(project); }
public static void SaveProject() { if (JetProps.get().Count <= 0) { return; } if (project == null) { project = new ProjectClass.ProjectFile(); } project.ProjectName = CurrentProjectVariables.ProjectName; project.PathToProjectFiles = CurrentProjectVariables.PathToProjectFiles; project.PathToProjectClassFile = CurrentProjectVariables.PathToProjectClassFile; project.GameName = CurrentProjectVariables.GameName; project.GamePath = CurrentProjectVariables.GamePath; project.GameVersion = CurrentProjectVariables.GameVersion; project.JetPassword = CurrentProjectVariables.JetPassword; project.ExportPath = CurrentProjectVariables.ExportPath; project.DateLastOpened = CurrentProjectVariables.DateLastOpened; project.JsonEditor_OpenedTabs = CurrentProjectVariables.JsonEditor_OpenedTabs; project.ModifiedFiles = CurrentProjectVariables.ModifiedFiles; project.UseNKHook = false; project.DontAskAboutNKH = false; project.UseNKHook = CurrentProjectVariables.UseNKHook; project.DontAskAboutNKH = CurrentProjectVariables.DontAskAboutNKH; string output_Cfg = JsonConvert.SerializeObject(project, Formatting.Indented); if (JetProps.get().Count <= 0) { return; } if (!Guard.IsStringValid(project.PathToProjectClassFile) || !Directory.Exists(project.PathToProjectClassFile)) { ConsoleHandler.force_append_Notice_CanRepeat("WARNING!!!!! Unable to find the .toolbox file for this project! " + "Failed to save project data. This can easily make toolbox not work properly. Please contact Toolbox" + " Devs if this continues"); return; } StreamWriter serialize = new StreamWriter(project.PathToProjectClassFile + "\\" + project.ProjectName + ".toolbox", false); serialize.Write(output_Cfg); serialize.Close(); }
public static void CreateProject() { project = new ProjectClass.ProjectFile(); CurrentProjectVariables.ResetProjectVariables(); }