public static ScenarioFile[] GetSQL(String ConnectionString, int FileNumber, String GracesJapaneseConnectionString) { List <ScenarioFile> ScenarioFiles = new List <ScenarioFile>(); SQLiteConnection Connection = new SQLiteConnection(ConnectionString); Connection.Open(); using (SQLiteTransaction Transaction = Connection.BeginTransaction()) using (SQLiteCommand Command = new SQLiteCommand(Connection)) { if (FileNumber == -1) { Command.CommandText = "SELECT english, PointerRef, StringID FROM Text WHERE status != -1 ORDER BY PointerRef"; } else { Command.CommandText = "SELECT english, PointerRef, StringID FROM Text WHERE status != -1 AND OriginalFile = " + FileNumber.ToString() + " ORDER BY PointerRef"; } SQLiteDataReader r = Command.ExecuteReader(); while (r.Read()) { String SQLText; try { SQLText = r.GetString(0).Replace("''", "'"); } catch (System.InvalidCastException ex) { SQLText = null; } int PointerRef = r.GetInt32(1); int StringID = r.GetInt32(2); ScenarioFile sc = new ScenarioFile(); if (!String.IsNullOrEmpty(SQLText)) { sc.Text = SQLText; } else { sc.Text = GetJapanese(GracesJapaneseConnectionString, StringID); } sc.Pointer = PointerRef; ScenarioFiles.Add(sc); } Transaction.Rollback(); } return(ScenarioFiles.ToArray()); }
private static void ReadOriginalStrings(byte[] file, ScenarioFile entry) { int ptrOffset = (int)Util.SwapEndian(BitConverter.ToUInt32(file, 0x24)) - 0x400; int jpnTextPtr = (int)Util.SwapEndian(BitConverter.ToUInt32(file, entry.Pointer + 0x00)); int engTextPtr = (int)Util.SwapEndian(BitConverter.ToUInt32(file, entry.Pointer + 0x08)); entry.OriginalTextJpn = Util.GetText(ptrOffset + jpnTextPtr, file); entry.OriginalTextEng = Util.GetText(ptrOffset + engTextPtr, file); }
private static void ReadOriginalStrings(byte[] file, ScenarioFile entry) { int dataSectionStart = (int)Util.SwapEndian(BitConverter.ToUInt32(file, 0x0C)); int ptr = dataSectionStart + entry.Pointer; int jpnNamePtr = (int)Util.SwapEndian(BitConverter.ToUInt32(file, ptr + 0x08)); int jpnTextPtr = (int)Util.SwapEndian(BitConverter.ToUInt32(file, ptr + 0x0C)); int engNamePtr = (int)Util.SwapEndian(BitConverter.ToUInt32(file, ptr + 0x10)); int engTextPtr = (int)Util.SwapEndian(BitConverter.ToUInt32(file, ptr + 0x14)); entry.OriginalNameJpn = Util.GetText(dataSectionStart + jpnNamePtr, file); entry.OriginalTextJpn = Util.GetText(dataSectionStart + jpnTextPtr, file); entry.OriginalNameEng = Util.GetText(dataSectionStart + engNamePtr, file); entry.OriginalTextEng = Util.GetText(dataSectionStart + engTextPtr, file); }
private static ScenarioFile[] Block(ScenarioFile[] ScenarioStrings) { List <ScenarioFile> ScenarioBlocks = new List <ScenarioFile>(); for (int i = 0; i < ScenarioStrings.Length; i++) { try { if (ScenarioStrings[i].Pointer + 4 == ScenarioStrings[i + 1].Pointer) { ScenarioFile s = new ScenarioFile(); s.Pointer = ScenarioStrings[i].Pointer - 8; s.Name = ScenarioStrings[i].Text; s.Text = ScenarioStrings[i + 1].Text; s.StringIdName = ScenarioStrings[i].StringIdText; s.StringIdText = ScenarioStrings[i + 1].StringIdText; ScenarioBlocks.Add(s); i++; } else { ScenarioFile s = new ScenarioFile(); s.Pointer = ScenarioStrings[i].Pointer - 12; s.Name = ""; s.Text = ScenarioStrings[i].Text; s.StringIdName = -1; s.StringIdText = ScenarioStrings[i].StringIdText; ScenarioBlocks.Add(s); } } catch (IndexOutOfRangeException) { ScenarioFile s = new ScenarioFile(); s.Pointer = ScenarioStrings[i].Pointer - 12; s.Name = ""; s.Text = ScenarioStrings[i].Text; s.StringIdName = -1; s.StringIdText = ScenarioStrings[i].StringIdText; ScenarioBlocks.Add(s); } } return(ScenarioBlocks.ToArray()); }