예제 #1
0
        public StringBlock(ref BinaryReader reader, ArscHeader header)
        {
            Header      = header;
            StringCount = reader.ReadUInt32();
            StyleCount  = reader.ReadUInt32();
            Flags       = reader.ReadUInt32();

            _isUtf8 = (Flags & Axml.Utf8Flag) != 0;

            StringPoolOffset = reader.ReadUInt32();
            StylePoolOffset  = reader.ReadUInt32();

            _stringOffsets = new uint[StringCount];
            for (var i = 0; i < StringCount; i++)
            {
                _stringOffsets[i] = reader.ReadUInt32();
            }

            _styleOffsets = new uint[StyleCount];
            for (var i = 0; i < StyleCount; i++)
            {
                _styleOffsets[i] = reader.ReadUInt32();
            }

            var size = Header.Size - StringPoolOffset;

            if (StylePoolOffset > 0 && StyleCount > 0)
            {
                size = StylePoolOffset - StringPoolOffset;
            }

            _charBuff = new byte[size];
            reader.Read(_charBuff, (int)reader.BaseStream.Position, (int)size);

            if (StylePoolOffset > 0 && StyleCount > 0)
            {
                size = Header.Size - StylePoolOffset;

                _styles = new uint[size / 4];
                for (var i = 0; i < (int)size / 4; i++)
                {
                    _styles[i] = reader.ReadUInt32();
                }
            }
        }