Exemple #1
0
        public ChatFile(byte[] TO8CHTX)
        {
            Header = new ChatFileHeader();

            Header.Identify  = Util.SwapEndian(BitConverter.ToUInt64(TO8CHTX, 0x00));
            Header.Filesize  = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x08));
            Header.Lines     = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x0C));
            Header.Unknown   = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x10));
            Header.TextStart = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x14));
            Header.Empty     = Util.SwapEndian(BitConverter.ToUInt64(TO8CHTX, 0x18));

            Lines = new ChatFileLine[Header.Lines];

            for (int i = 0; i < Header.Lines; i++)
            {
                Lines[i]          = new ChatFileLine();
                Lines[i].Location = 0x20 + i * 0x10;
                Lines[i].Name     = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x20 + i * 0x10));
                Lines[i].JPN      = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x24 + i * 0x10));
                Lines[i].ENG      = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x28 + i * 0x10));
                Lines[i].Unknown  = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x2C + i * 0x10));

                Lines[i].SName = GetText(TO8CHTX, Lines[i].Name + Header.TextStart);
                Lines[i].SJPN  = GetText(TO8CHTX, Lines[i].JPN + Header.TextStart);
                Lines[i].SENG  = GetText(TO8CHTX, Lines[i].ENG + Header.TextStart).Replace('@', ' ');
            }
        }
Exemple #2
0
        public bool InsertSQL(string ConnectionString, string ConnectionStringGracesJapanese)
        {
            SQLiteConnection sQLiteConnection  = new SQLiteConnection(ConnectionString);
            SQLiteConnection sQLiteConnection2 = new SQLiteConnection(ConnectionStringGracesJapanese);

            sQLiteConnection.Open();
            sQLiteConnection2.Open();
            new SQLiteCommand(sQLiteConnection)
            {
                CommandText = "DELETE FROM Text"
            }.ExecuteNonQuery();
            using (SQLiteTransaction sQLiteTransaction = sQLiteConnection.BeginTransaction())
            {
                using (SQLiteTransaction sQLiteTransaction2 = sQLiteConnection2.BeginTransaction())
                {
                    using (SQLiteCommand sQLiteCommand = new SQLiteCommand(sQLiteConnection))
                    {
                        using (SQLiteCommand sQLiteCommand2 = new SQLiteCommand(sQLiteConnection2))
                        {
                            using (SQLiteCommand sQLiteCommand3 = new SQLiteCommand(sQLiteConnection2))
                            {
                                using (SQLiteCommand sQLiteCommand4 = new SQLiteCommand(sQLiteConnection2))
                                {
                                    SQLiteParameter sQLiteParameter  = new SQLiteParameter();
                                    SQLiteParameter sQLiteParameter2 = new SQLiteParameter();
                                    SQLiteParameter sQLiteParameter3 = new SQLiteParameter();
                                    SQLiteParameter sQLiteParameter4 = new SQLiteParameter();
                                    SQLiteParameter sQLiteParameter5 = new SQLiteParameter();
                                    SQLiteParameter sQLiteParameter6 = new SQLiteParameter();
                                    SQLiteParameter sQLiteParameter7 = new SQLiteParameter();
                                    SQLiteParameter sQLiteParameter8 = new SQLiteParameter();
                                    sQLiteCommand2.CommandText = "INSERT INTO Japanese (ID, string, debug) VALUES (?, ?, 0)";
                                    sQLiteCommand2.Parameters.Add(sQLiteParameter);
                                    sQLiteCommand2.Parameters.Add(sQLiteParameter2);
                                    sQLiteCommand.CommandText = "INSERT INTO Text (ID, StringID, english, comment, updated, status, PointerRef) VALUES (?, ?, ?, null, 0, ?, ?)";
                                    sQLiteCommand.Parameters.Add(sQLiteParameter3);
                                    sQLiteCommand.Parameters.Add(sQLiteParameter4);
                                    sQLiteCommand.Parameters.Add(sQLiteParameter5);
                                    sQLiteCommand.Parameters.Add(sQLiteParameter8);
                                    sQLiteCommand.Parameters.Add(sQLiteParameter6);
                                    sQLiteCommand3.CommandText = "SELECT MAX(ID)+1 FROM Japanese";
                                    sQLiteCommand4.CommandText = "SELECT ID FROM Japanese WHERE string = ?";
                                    sQLiteCommand4.Parameters.Add(sQLiteParameter7);
                                    object         obj   = sQLiteCommand3.ExecuteScalar();
                                    int            num   = int.Parse(obj.ToString());
                                    int            num2  = 1;
                                    ChatFileLine[] lines = this.Lines;
                                    for (int i = 0; i < lines.Length; i++)
                                    {
                                        ChatFileLine chatFileLine = lines[i];
                                        sQLiteParameter7.Value = chatFileLine.SName;
                                        object obj2 = sQLiteCommand4.ExecuteScalar();
                                        int    num3;
                                        if (obj2 != null)
                                        {
                                            num3 = (int)obj2;
                                        }
                                        else
                                        {
                                            num3 = num++;
                                            sQLiteParameter.Value  = num3;
                                            sQLiteParameter2.Value = chatFileLine.SName;
                                            sQLiteCommand2.ExecuteNonQuery();
                                        }
                                        sQLiteParameter3.Value = num2;
                                        sQLiteParameter4.Value = num3;
                                        sQLiteParameter5.Value = chatFileLine.SName;
                                        sQLiteParameter8.Value = 1;
                                        sQLiteParameter6.Value = chatFileLine.Location;
                                        sQLiteCommand.ExecuteNonQuery();
                                        num2++;
                                        sQLiteParameter7.Value = chatFileLine.SJPN;
                                        obj2 = sQLiteCommand4.ExecuteScalar();
                                        if (obj2 != null)
                                        {
                                            num3 = (int)obj2;
                                        }
                                        else
                                        {
                                            num3 = num++;
                                            sQLiteParameter.Value  = num3;
                                            sQLiteParameter2.Value = chatFileLine.SJPN;
                                            sQLiteCommand2.ExecuteNonQuery();
                                        }
                                        sQLiteParameter3.Value = num2;
                                        sQLiteParameter4.Value = num3;
                                        if (chatFileLine.SENG == "Dummy" || chatFileLine.SENG == "")
                                        {
                                            sQLiteParameter5.Value = null;
                                            sQLiteParameter8.Value = 0;
                                        }
                                        else
                                        {
                                            sQLiteParameter5.Value = chatFileLine.SENG;
                                            sQLiteParameter8.Value = 1;
                                        }
                                        sQLiteParameter6.Value = chatFileLine.Location + 4;
                                        sQLiteCommand.ExecuteNonQuery();
                                        num2++;
                                    }
                                    sQLiteTransaction.Commit();
                                    sQLiteTransaction2.Commit();
                                }
                            }
                        }
                    }
                }
            }
            sQLiteConnection2.Close();
            sQLiteConnection.Close();
            return(true);
        }