string Core_GetAllArrayDefines() { string result = "#define None 0\r\n"; string define; ArrayFile definitions; string[] files = new string[] { "Dialog Background List.txt", "Cutscene Screen List.txt", "Music List.txt", "Chapter List.txt", "Character List.txt", "Class List.txt", "Item List.txt", }; //FileInfo[] files = new DirectoryInfo(Core.Path_Arrays).GetFiles("*.txt"); //foreach (FileInfo file in files) foreach (string file in files) { if (file.EndsWith("Commands.txt")) { continue; } definitions = new ArrayFile(file); result += "\r\n"; result += "// " + "file.Name\r\n"; for (uint i = 0; i <= definitions.LastEntry; i++) { define = EventAssemblerIO.ReplaceSpacesAndSpecialChars(definitions[i]); if (define.Equals("None")) { continue; } if (define.Length > 1) { result += "#define " + define + "\t" + i + "\r\n"; } } } return(result); }
void Core_LoadEventCode() { try { StringBuilder stringbuilder = new StringBuilder(); using (StringWriter writer = new StringWriter(stringbuilder)) { EA.IO.Logs.TextWriterMessageLog log = new EA.IO.Logs.TextWriterMessageLog(writer); EA.Program.Disassemble(Language, Program.Core.ROM.FileData, "", writer, true, EA.DisassemblyMode.Structure, Event_PointerBox.Value, EA.Code.Language.Priority.none, 0, log); if (log.ErrorCount > 0 || log.MessageCount > 0) { log.PrintAll(); } } string result = stringbuilder.ToString().TrimStart('\r', '\n'); EventList = Core_LoadEventCode_EventLabels(ref result); if (Tools_ManageSpace.Checked) { Core_LoadEventCode_ManageSpace(ref result); } if (View_ArrayDefinitions.Checked) { EventAssemblerIO.LoadEventCode_ArrayDefinitions(ref result); } if (View_HelperMacros.Checked) { EventAssemblerIO.LoadEventCode_HelperMacros(ref result); } Core_LoadEventCode_MapUnitGroups(); Event_CodeBox.Text = result; } catch (Exception ex) { Program.ShowError("There has been an error while loading the event code.", ex); } }
private void Tools_MakeEAtxt_Click(object sender, EventArgs e) { string[] file; try { OpenFileDialog openWindow = new OpenFileDialog(); openWindow.Title = "Open EM array text file"; openWindow.RestoreDirectory = true; openWindow.Multiselect = false; openWindow.FilterIndex = 1; openWindow.Filter = "Text file (*.txt)|*.txt|" + "All files (*.*)|*.*"; if (openWindow.ShowDialog() == DialogResult.OK) { file = File.ReadAllLines(openWindow.FileName); } else { return; } SaveFileDialog saveWindow = new SaveFileDialog(); openWindow.Title = "Choose destination for EA definitions file"; saveWindow.RestoreDirectory = true; saveWindow.OverwritePrompt = true; saveWindow.CreatePrompt = false; saveWindow.FilterIndex = 1; saveWindow.Filter = "Text file (*.event)|*.event|" + "All files (*.*)|*.*"; if (saveWindow.ShowDialog() == DialogResult.OK) { string number; string define; int start, end; for (int i = 0; i < file.Length; i++) { start = 0; end = file[i].IndexOfAny(new char[] { ' ', '\t' }); if (end < 0) { continue; } number = file[i].Substring(start, end - start); start = end + 1; end = file[i].IndexOfAny(new char[] { '\r', '\n' }, start); if (end < 0) { end = file[i].Length; } define = EventAssemblerIO.ReplaceSpacesAndSpecialChars(file[i].Substring(start, end - start)); file[i] = ("#define " + define + "\t" + number); } File.WriteAllLines(saveWindow.FileName, file); } } catch (Exception ex) { Program.ShowError("Could not make EA definitions file from EM array text file.", ex); } }