Esempio n. 1
0
 public StringFile(Language language, IGameInstance instance)
 {
     GameInstance   = instance;
     Language       = language;
     Header         = new StringHeader();
     Header.ID      = 0xA84C7F73;
     Header.Version = 0x0001;
 }
Esempio n. 2
0
 public StringFile(UInt16 bucketCount, Language language, IGameInstance instance)
 {
     GameInstance       = instance;
     Language           = language;
     Header             = new StringHeader();
     Header.BucketCount = bucketCount;
     Header.ID          = 0xA84C7F73;
     Header.Version     = 0x0001;
     for (int i = 0; i < bucketCount; i++)
     {
         Buckets.Add(new Dictionary <UInt32, string>());
     }
 }
Esempio n. 3
0
        public StringFile(Stream stream, Language language, IGameInstance instance)
        {
            GameInstance = instance;
            Language     = language;
            Header       = stream.ReadStruct <StringHeader>();

            var map = LanguageUtility.GetDecodeCharMap(GameInstance, Language);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < Header.BucketCount; i++)
            {
                // Seek to the start of our new bucket
                stream.Seek(Marshal.SizeOf(typeof(StringHeader)) + (i * Marshal.SizeOf(typeof(StringBucket))), SeekOrigin.Begin);
                StringBucket bucket = stream.ReadStruct <StringBucket>();

                Dictionary <UInt32, string> bucketData = new Dictionary <uint, string>();
                for (int j = 0; j < bucket.StringCount; j++)
                {
                    stream.Seek(bucket.StringOffset + (sizeof(UInt32) * j), SeekOrigin.Begin);
                    UInt32 stringOffset = stream.ReadUInt32();

                    stream.Seek(stringOffset, SeekOrigin.Begin);
                    UInt32 stringHash = stream.ReadUInt32();
                    if (FileIsSaintsRow2)
                    {
                        stringHash = stringHash.Swap();
                    }

                    sb.Clear();

                    int length = 0;
                    while (true)
                    {
                        UInt16 charValue = stream.ReadUInt16();

                        if (charValue == 0x0000)
                        {
                            break;
                        }

                        if (FileIsSaintsRow2)
                        {
                            charValue = charValue.Swap();
                        }

                        char src = (char)charValue;

                        char value = src;

                        if (map.ContainsKey(src))
                        {
                            value = map[src];
                        }

                        sb.Append(value);

                        length++;
                    }

                    string text = sb.ToString();
                    bucketData.Add(stringHash, text);
                }
                Buckets.Add(bucketData);
            }
        }