public static int Execute( List<string> args ) { if ( args.Count < 2 ) { Console.WriteLine( "Usage: game infile.ebm [outfile.txt]" ); Console.WriteLine( " game can be any of:" ); Console.WriteLine( " - [AT3] for Ar tonelico 3" ); Console.WriteLine( " - [AnS] for Ar nosurge" ); Console.WriteLine( " All names will be printed as 'Unknown' if none of those are provided." ); return -1; } string game = args[0]; string infile = args[1]; string outfile = args.Count >= 3 ? args[2] : args[1] + ".txt"; bool debug = args.Contains( "--debug" ); bool oneLine = args.Contains( "--oneLine" ); bool isUtf8 = false; Dictionary<int, string> names; switch ( game.ToLowerInvariant() ) { case "at3": names = GenerateAt3Dict(); isUtf8 = false; break; case "ans": names = GenerateAnSDict(); isUtf8 = true; break; default: names = new Dictionary<int, string>(); break; } var ebm = new ebm( infile, isUtf8 ); List<string> text = new List<string>(); foreach ( var e in ebm.EntryList ) { if ( debug ) { text.Add( "[Id ] " + e.Ident ); text.Add( "[Unk2] " + e.Unknown2 ); text.Add( "[Unk3] " + e.Unknown3 ); text.Add( "[Unk5] " + e.Unknown5 ); text.Add( "[Unk6] " + e.Unknown6 ); text.Add( "[Unk7] " + e.Unknown7 ); text.Add( "[Unk8] " + e.Unknown8 ); } string name; if ( names.ContainsKey( e.CharacterId ) ) { name = names[e.CharacterId]; } else { name = "Unknown_" + e.CharacterId; } if ( oneLine ) { text.Add( ( name != "" ? "[" + name + "] " : "" ) + e.Text.Replace( " <CR>", " " ).Replace( "<CR>", " " ) ); } else { text.Add( "[" + name + "]" ); text.Add( e.Text.Replace( "<CR>", "\r\n" ) ); text.Add( "" ); } } System.IO.File.WriteAllLines( outfile, text.ToArray() ); return 0; }
public static int Execute(List <string> args) { if (args.Count < 2) { Console.WriteLine("Usage: infile.sqlite outfile.ebm"); return(-1); } string infile = args[0]; string outfile = args[1]; var ebm = new ebm(); var rows = SqliteUtil.SelectArray("Data Source=" + infile, "SELECT Ident, Unknown2, Unknown3, CharacterId, Unknown5, Unknown6, Unknown7, Unknown8, Entry FROM ebm ORDER BY ID"); foreach (var row in rows) { ebmEntry e = new ebmEntry() { Ident = (uint)(long)row[0], Unknown2 = (uint)(long)row[1], Unknown3 = (uint)(long)row[2], CharacterId = (int)row[3], Unknown5 = (uint)(long)row[4], Unknown6 = (uint)(long)row[5], Unknown7 = (uint)(long)row[6], Unknown8 = (uint)(long)row[7], Text = (string)row[8], }; ebm.EntryList.Add(e); } using (Stream s = new FileStream(outfile, FileMode.Create)) { ebm.WriteFile(s, TextUtils.GameTextEncoding.UTF8); s.Close(); } return(0); }
public static int Execute(List <string> args) { if (args.Count < 2) { Console.WriteLine("Usage: infile.ebm outfile.sqlite"); return(-1); } string infile = args[0]; string outfile = args[1]; var ebm = new ebm(infile, Util.GameTextEncoding.UTF8); if (System.IO.File.Exists(outfile)) { System.IO.File.Delete(outfile); } SQLiteConnection connection = new SQLiteConnection("Data Source=" + outfile); connection.Open(); using (SQLiteTransaction transaction = connection.BeginTransaction()) { using (SQLiteCommand command = new SQLiteCommand(connection)) { command.CommandText = "CREATE TABLE IF NOT EXISTS ebm(" + "ID INTEGER PRIMARY KEY AUTOINCREMENT," + "Ident UNSIGNED INT," + "Unknown2 UNSIGNED INT," + "Unknown3 UNSIGNED INT," + "CharacterId INT," + "Unknown5 UNSIGNED INT," + "Unknown6 UNSIGNED INT," + "Unknown7 UNSIGNED INT," + "Unknown8 UNSIGNED INT," + "Entry TEXT" + ")"; command.ExecuteNonQuery(); } using (SQLiteCommand command = new SQLiteCommand(connection)) { SQLiteParameter Ident = new SQLiteParameter(); SQLiteParameter Unknown2 = new SQLiteParameter(); SQLiteParameter Unknown3 = new SQLiteParameter(); SQLiteParameter CharacterId = new SQLiteParameter(); SQLiteParameter Unknown5 = new SQLiteParameter(); SQLiteParameter Unknown6 = new SQLiteParameter(); SQLiteParameter Unknown7 = new SQLiteParameter(); SQLiteParameter Unknown8 = new SQLiteParameter(); SQLiteParameter Text = new SQLiteParameter(); command.CommandText = "INSERT INTO ebm ( Ident, Unknown2, Unknown3, CharacterId, Unknown5, Unknown6, Unknown7, Unknown8, Entry ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; command.Parameters.Add(Ident); command.Parameters.Add(Unknown2); command.Parameters.Add(Unknown3); command.Parameters.Add(CharacterId); command.Parameters.Add(Unknown5); command.Parameters.Add(Unknown6); command.Parameters.Add(Unknown7); command.Parameters.Add(Unknown8); command.Parameters.Add(Text); foreach (var e in ebm.EntryList) { Ident.Value = e.Ident; Unknown2.Value = e.Unknown2; Unknown3.Value = e.Unknown3; CharacterId.Value = e.CharacterId; Unknown5.Value = e.Unknown5; Unknown6.Value = e.Unknown6; Unknown7.Value = e.Unknown7; Unknown8.Value = e.Unknown8; Text.Value = e.Text; command.ExecuteNonQuery(); } } transaction.Commit(); } connection.Close(); return(0); }
public static int Execute(List <string> args) { if (args.Count < 2) { Console.WriteLine("Usage: game infile.ebm [outfile.txt]"); Console.WriteLine(" game can be any of:"); Console.WriteLine(" - [AT3] for Ar tonelico 3"); Console.WriteLine(" - [AnS] for Ar nosurge"); Console.WriteLine(" All names will be printed as 'Unknown' if none of those are provided."); return(-1); } string game = args[0]; string infile = args[1]; string outfile = args.Count >= 3 ? args[2] : args[1] + ".txt"; bool debug = args.Contains("--debug"); bool oneLine = args.Contains("--oneLine"); bool isUtf8 = false; Dictionary <int, string> names; switch (game.ToLowerInvariant()) { case "at3": names = GenerateAt3Dict(); isUtf8 = false; break; case "ans": names = GenerateAnSDict(); isUtf8 = true; break; default: names = new Dictionary <int, string>(); break; } var ebm = new ebm(infile, isUtf8); List <string> text = new List <string>(); foreach (var e in ebm.EntryList) { if (debug) { text.Add("[Id ] " + e.Ident); text.Add("[Unk2] " + e.Unknown2); text.Add("[Unk3] " + e.Unknown3); text.Add("[Unk5] " + e.Unknown5); text.Add("[Unk6] " + e.Unknown6); text.Add("[Unk7] " + e.Unknown7); text.Add("[Unk8] " + e.Unknown8); } string name; if (names.ContainsKey(e.CharacterId)) { name = names[e.CharacterId]; } else { name = "Unknown_" + e.CharacterId; } if (oneLine) { text.Add((name != "" ? "[" + name + "] " : "") + e.Text.Replace(" <CR>", " ").Replace("<CR>", " ")); } else { text.Add("[" + name + "]"); text.Add(e.Text.Replace("<CR>", "\r\n")); text.Add(""); } } System.IO.File.WriteAllLines(outfile, text.ToArray()); return(0); }