private void LintPanel_MouseClick(object sender, MouseEventArgs e) { if (jsonError) { try { string error = JSON_Reader.GetJSON_Error(Editor_TextBox.Text); ConsoleHandler.force_append_Notice(error); //Line number string[] split = error.Split(','); string[] line = split[split.Length - 2].Split(' '); int lineNumber = Int32.Parse(line[line.Length - 1].Replace(".", "").Replace(",", "")); //Position in line string[] pos = split[split.Length - 1].Split(' '); int linePos = Int32.Parse(pos[pos.Length - 1].Replace(".", "").Replace(",", "")); //Scroll to the line above error int index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 3) + linePos; Editor_TextBox.Select(index, 1); Editor_TextBox.ScrollToCaret(); int numChars = (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 1)) - (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2)); //highlight line with error index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2) + linePos; Editor_TextBox.Focus(); Editor_TextBox.Select(index, numChars - 2); } catch { ConsoleHandler.append_CanRepeat("Something went wrong... Unable to find the bad json"); } } }
private void GetBTDBPasswordToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult diag = MessageBox.Show("You are trying to open the \"Get BTDB Password\" tool. It will take a couple of minutes to get the password. Do you wish to continue?", "Continue?", MessageBoxButtons.YesNo); if (diag == DialogResult.Yes) { var getPass = new CrackBTDB_Pass(); getPass.Get_BTDB_Password(); } else { ConsoleHandler.append_CanRepeat("User cancelled password tool..."); } }
private void Save_Button_Click(object sender, EventArgs e) { Serializer.cfg.useExternalEditor = useExternalEditor.Checked; Serializer.cfg.enableSplash = EnableSplash.Checked; Serializer.cfg.disableUpdates = DisableUpdates_CB.Checked; Serializer.cfg.autoFormatJSON = AutoFormatJSON_CB.Checked; Serializer.cfg.UseDeveloperMode = UseDeveloperMode.Checked; CurrentProjectVariables.UseNKHook = UseNKH_CB.Checked; Serializer.SaveSettings(); ProjectHandler.SaveProject(); ConsoleHandler.append_CanRepeat("Settings saved!!!"); DeveloperMode.ControlDeveloperMode(); this.Close(); }
public void RestoreToOriginal() { if (!filename.Contains(New_JsonEditor.readOnlyName)) { DialogResult diag = MessageBox.Show("You are trying to restore this file to the original unmodded version. Are you sure you want to do this?", "Restore to original?", MessageBoxButtons.YesNo); if (diag == DialogResult.Yes) { string backupProj = Environment.CurrentDirectory + "\\Backups\\" + CurrentProjectVariables.GameName + "_BackupProject\\" + path.Replace(CurrentProjectVariables.PathToProjectFiles.Replace("\\\\", "\\"), ""); if (File.Exists(backupProj)) { if (path.Contains(".")) { if (File.Exists(path)) { JsonEditorHandler.CloseFile(path); File.Delete(path); } File.Copy(backupProj, path); JsonEditorHandler.OpenFile(path); ConsoleHandler.append_CanRepeat(filename + "has been restored"); } } else { ConsoleHandler.append_CanRepeat("Could not find file in backup project... Unable to restore file"); } } else { ConsoleHandler.append_CanRepeat("User cancelled restore"); } } else { ConsoleHandler.append_Notice("You can't restore this file because it IS the original " + filename.Replace(New_JsonEditor.readOnlyName, "") + " and it is read only"); } }
private void AddText(string path, bool isFromZip) { if (!File.Exists(path)) { CloseTab(path); return; } string unformattedText = ""; if (!isFromZip) { unformattedText = File.ReadAllText(path); } else { if (jet == null) { jet = new ZipFile(CurrentProjectVariables.PathToProjectClassFile + "\\" + CurrentProjectVariables.ProjectName + ".jet"); } unformattedText = ProjectHandler.ReadTextFromZipFile(jet, path); } try { JToken jt = JToken.Parse(unformattedText); string formattedText = jt.ToString(Formatting.Indented); userControls[userControls.Count - 1].Editor_TextBox.Text = formattedText; } catch (Exception) { ConsoleHandler.append_CanRepeat("File contains invalid json. Unable to format.."); userControls[userControls.Count - 1].Editor_TextBox.Text = unformattedText; } }
public void NewTab(string path, bool isFromZip) { if (!Guard.IsStringValid(path)) { ConsoleHandler.append_CanRepeat("Something went wrong when trying to read the files path..."); return; } string filepath = ""; if (isFromZip) { filepath = path.Replace(Environment.CurrentDirectory + "\\", "").Replace("\\", "/"); path = filepath; } else { filepath = path; } tabFilePaths.Add(path); if (!CurrentProjectVariables.JsonEditor_OpenedTabs.Contains(path)) { CurrentProjectVariables.JsonEditor_OpenedTabs.Add(path); ProjectHandler.SaveProject(); } tabPages.Add(new TabPage()); userControls.Add(new JsonEditor_Instance()); //create the tab and do required processing string[] split = path.Replace("/", "\\").Split('\\'); string filename = split[split.Length - 1]; if (path.Contains("BackupProject")) { filename = filename + readOnlyName; userControls[userControls.Count - 1].Editor_TextBox.ReadOnly = true; } tabPages[tabPages.Count - 1].Text = filename; tabPages[tabPages.Count - 1].Controls.Add(userControls[userControls.Count - 1]); userControls[userControls.Count - 1].path = path; userControls[userControls.Count - 1].filename = filename; if (isFromZip == false) { AddText(path, false); } else { AddText(path, true); } if ((tabPages.Count - 1) < 0 || tabPages[tabPages.Count - 1] == null) { return; } tabControl1.TabPages.Add(tabPages[tabPages.Count - 1]); OpenTab(path); userControls[userControls.Count - 1].FinishedLoading(); }
private void ExportLog_Button_Click(object sender, EventArgs e) { ConsoleHandler.append_CanRepeat("Copied console log to clipboard."); Clipboard.SetText(output_log.Text); }