public static void LoadEditorLogicPreset(string Path, string WebPath, object sender, EventArgs e, string WebDicOverride = "") { try { if (LogicEditor.EditorForm == null) { return; } var LEditorForm = LogicEditor.EditorForm; if (!LEditorForm.PromptSave()) { return; } string[] Lines = null; if (File.Exists(Path)) { Lines = File.ReadAllLines(Path); Debugging.Log(Path); } else { System.Net.WebClient wc = new System.Net.WebClient(); string webData = wc.DownloadString(WebPath); Lines = webData.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); Debugging.Log(WebPath); } List <LogicObjects.LogicDictionaryEntry> DicOverride = null; if (WebDicOverride != "") { try { System.Net.WebClient wc = new System.Net.WebClient(); string webData = wc.DownloadString(WebDicOverride); var DicLines = webData.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); var csv = Utility.ConvertCsvFileToJsonObject(DicLines); DicOverride = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(csv); Debugging.Log(WebDicOverride); } catch { DicOverride = null; } } LogicEditor.EditorInstance = new LogicObjects.TrackerInstance(); LogicEditor.EditorInstance.LogicDictionary = DicOverride; Tools.CreateTrackerInstance(LogicEditor.EditorInstance, Lines.ToArray()); LogicEditor.AssignUniqueItemnames(LogicEditor.EditorInstance.Logic); if (LogicEditor.EditorInstance.Logic.Count < Convert.ToInt32(LEditorForm.nudIndex.Value)) { LEditorForm.nudIndex.Value = LogicEditor.EditorInstance.Logic.Count - 1; } LogicEditor.EditorForm.FormatForm(Convert.ToInt32(LEditorForm.nudIndex.Value)); } catch { MessageBox.Show("Preset File Invalid! If you have not tampered with the preset files in \"Recources\\Other Files\\\" Please report this issue. Otherwise, redownload or delete those files.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void LoadMainLogicPreset(string Path, string WebPath, object sender, EventArgs e, string WebDicOverride, bool New = true) { Console.WriteLine(WebDicOverride + "Was Dic"); try { if (!Tools.PromptSave(LogicObjects.MainTrackerInstance)) { return; } string[] Lines = null; if (File.Exists(Path)) { Lines = File.ReadAllLines(Path); Debugging.Log(Path); } else { System.Net.WebClient wc = new System.Net.WebClient(); string webData = wc.DownloadString(WebPath); Lines = webData.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); Debugging.Log(WebPath); } List <LogicObjects.LogicDictionaryEntry> DicOverride = null; if (WebDicOverride != "") { try { System.Net.WebClient wc = new System.Net.WebClient(); string webData = wc.DownloadString(WebDicOverride); var DicLines = webData.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); var csv = Utility.ConvertCsvFileToJsonObject(DicLines); DicOverride = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(csv); Debugging.Log(WebDicOverride); } catch (Exception j) { Console.WriteLine("Dictionary Invalid"); DicOverride = null; } } if (New) { LogicObjects.MainTrackerInstance = new LogicObjects.TrackerInstance(); LogicObjects.MainTrackerInstance.LogicDictionary = DicOverride; Tools.CreateTrackerInstance(LogicObjects.MainTrackerInstance, Lines.ToArray()); } else { LogicObjects.MainTrackerInstance.LogicDictionary = DicOverride; LogicEditing.RecreateLogic(LogicObjects.MainTrackerInstance, Lines); } MainInterface.CurrentProgram.FormatMenuItems(); MainInterface.CurrentProgram.ResizeObject(); MainInterface.CurrentProgram.PrintToListBox(); MainInterface.FireEvents(sender, e); Tools.UpdateTrackerTitle(); } catch { MessageBox.Show("Preset File Invalid! If you have not tampered with the preset files in \"Recources\\Other Files\\\" Please report this issue. Otherwise, redownload or delete those files.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }