Exemple #1
0
        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);
        }
Exemple #2
0
 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);
     }
 }