private static void UpdateGracesJapanese(SQLiteTransaction ta, int id, string originalString, int debug) { // CREATE TABLE Japanese(ID INT PRIMARY KEY, string TEXT, debug INT) long exists = (long)SqliteUtil.SelectScalar(ta, "SELECT COUNT(1) FROM Japanese WHERE ID = ?", new object[1] { id }); if (exists > 0) { SqliteUtil.Update(ta, "UPDATE Japanese SET string = ?, debug = ? WHERE ID = ?", new object[3] { originalString, debug, id }); } else { SqliteUtil.Update(ta, "INSERT INTO Japanese (ID, string, debug) VALUES (?, ?, ?)", new object[3] { id, originalString, debug }); } }
public static int Replace(List <string> args) { string Database = args[0]; // remove the dumb unicode byte order mark object o1 = SqliteUtil.SelectScalar("Data Source=" + args[0], "SELECT cast(english as blob) FROM text WHERE id = 12"); object o2 = SqliteUtil.SelectScalar("Data Source=" + args[1], "SELECT cast(english as blob) FROM text WHERE id = 14"); List <object[]> objects = GenericSqliteSelect("Data Source=" + Database, //"SELECT id, string FROM japanese ORDER BY id ASC", new object[0] ); "SELECT id, english FROM text ORDER BY id ASC", new object[0]); SQLiteConnection Connection = new SQLiteConnection("Data Source=" + Database); Connection.Open(); for (int i = 0; i < objects.Count; ++i) { byte[] b = Encoding.Unicode.GetBytes((string)objects[i][1]); if (b.Length >= 2 && b[0] == '\xff' && b[1] == '\xfe') { int ID = (int)objects[i][0]; string str = (string)objects[i][1]; string fstr = Encoding.Unicode.GetString(b, 2, b.Length - 2); Console.WriteLine(fstr); SqliteUtil.Update(Connection, //"UPDATE japanese SET string = ? WHERE id = ?", "UPDATE Text SET english = ?, updated = 1 WHERE id = ?", new object[] { fstr, ID } ); } } Connection.Close(); return(0); }
public static int AutoImport(List <string> args) { string dir = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfRebuild\umdimage.dat.ex\"; string voicedir = @"d:\_svn\GraceNote\GraceNote\Voices\"; string[] files = System.IO.Directory.GetFiles(dir); List <String> dbsToUp = new List <string>(); foreach (var x in nonstopDict) { string nonstopFile = GetFromSubstring(files, x.Key); string scriptFile = GetFromSubstring(files, x.Value); string scriptFileFilename = new System.IO.FileInfo(scriptFile).Name; string databaseId = scriptFileFilename.Substring(0, 4); string databaseFile = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfDB\DRBO" + databaseId; dbsToUp.Add("DRBO" + databaseId); //continue; LIN lin = new LIN(scriptFile); NonstopFile nonstop = new NonstopFile(nonstopFile); int lastScriptEntry = 0; foreach (var item in nonstop.items) { int stringId = item.data[(int)NonstopSingleStructure.StringID] + 1; int correspondingTextEntry = stringId * 2; int correspondingScriptEntry = correspondingTextEntry - 1; if (item.data[(int)NonstopSingleStructure.Type] == 0) { lastScriptEntry = correspondingTextEntry; } // --- insert comment info --- string comment = (string)SqliteUtil.SelectScalar( "Data Source=" + databaseFile, "SELECT comment FROM Text WHERE id = ?", new object[] { correspondingTextEntry }); bool weakpt = item.data[(int)NonstopSingleStructure.HasWeakPoint] > 0; comment = (comment == "" ? "" : comment + "\n\n") + "Autogenerated Info:\n" + (lastScriptEntry == 0 ? "Corresponds to file: " + scriptFileFilename : "") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "Normal Line\n" : "Background Noise\n") + (weakpt ? "Has a Weak Point\n" : "No Weakpoint\n") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF) != 255 ? "Shot with Evidence Bullet: " + item.data[(int)NonstopSingleStructure.ShootWithEvidence] + "\n" : "") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF) != 255 ? "Shot with Weak Point: " + item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] + "\n" : "") + (weakpt && (item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF) == 255 && (item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF) == 255 ? "Can't be shot\n" : "") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "" : "Appears around Entry #" + lastScriptEntry + "\n") + (item.data[(int)NonstopSingleStructure.Type] == 0 ? "Sprite: " + DanganUtil.CharacterIdToName((byte)item.data[(int)NonstopSingleStructure.Character]) + " " + item.data[(int)NonstopSingleStructure.Sprite] + "\n" : "") ; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET comment = ?, updated = 1 WHERE id = ?", new object[] { comment, correspondingTextEntry }); // --- insert voice info --- string script = (string)SqliteUtil.SelectScalar( "Data Source=" + databaseFile, "SELECT english FROM Text WHERE id = ?", new object[] { correspondingScriptEntry }); string voicename; string voicefilecheck; byte charid = (byte)item.data[(int)NonstopSingleStructure.Character]; if (item.data[(int)NonstopSingleStructure.Type] == 0) { while (true) { string charac = DanganUtil.CharacterIdToName(charid); if (charac == "Naegi") { charac = "Neagi"; } voicename = "[" + charac + "] " + item.data[(int)NonstopSingleStructure.Chapter] + " " + (item.data[(int)NonstopSingleStructure.AudioSampleId] >> 8) + " " + (item.data[(int)NonstopSingleStructure.AudioSampleId] & 0xFF) + " 100"; voicefilecheck = voicedir + voicename + ".mp3"; if (System.IO.File.Exists(voicefilecheck)) { break; } charid = 0x12; } script += "<__END__>\n" + "<Voice: " + voicename + ">" ; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET english = ?, updated = 1 WHERE id = ?", new object[] { script, correspondingScriptEntry }); // update the header name thingy string header = DanganUtil.CharacterIdToName(charid); SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?", new object[] { header, correspondingTextEntry }); } else { string header = "Background Noise"; SqliteUtil.Update( "Data Source=" + databaseFile, "UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?", new object[] { header, correspondingTextEntry }); } } } System.IO.File.WriteAllLines( @"d:\_svn\GraceNote\GraceNote\temp.txt", dbsToUp.ToArray()); return(0); }