Exemple #1
0
        public void Decompile(string filepath)
        {
            using (FileStream stream = new FileStream(filepath, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(stream, Encoding.Latin1))
                {
                    string signature = reader.ReadFixedString(15);
                    if (signature != TRA_SIGNATURE)
                    {
                        Debug.Assert(false, "Invalid TRA signature!");
                        return;
                    }

                    for (; ;)
                    {
                        Int32 blockType = reader.ReadInt32();
                        Int32 blockSize = reader.ReadInt32();

                        if (blockType == (int)BlockType.Content)
                        {
                            for (; ;)
                            {
                                string original    = reader.ReadEncryptedCString();
                                string translation = reader.ReadEncryptedCString();

                                if ((original.Length < 1) && (translation.Length < 1))
                                {
                                    break;
                                }

                                OriginalLines.Add(original);
                                TranslatedLines.Add(translation);
                            }
                        }
                        else if (blockType == (int)BlockType.Header)
                        {
                            GameID   = reader.ReadInt32();
                            GameName = reader.ReadEncryptedCString();
                        }
                        else if (blockType == (int)BlockType.Settings)
                        {
                            //TODO(adm244): read settings
                            break;
                        }
                        else if (blockType == (int)BlockType.End)
                        {
                            break;
                        }
                        else
                        {
                            Debug.Assert(false, "Unknown block type encountered!");
                            break;
                        }
                    }
                }
            }
        }
Exemple #2
0
        public bool Add(string original, string translation)
        {
            if (string.IsNullOrEmpty(original) || string.IsNullOrEmpty(translation))
            {
                return(false);
            }

            OriginalLines.Add(original);
            TranslatedLines.Add(translation);

            return(true);
        }