示例#1
0
        public override bool OnInitialize()
        {
            base.OnInitialize();

            _strings.Clear();
            if (_version == 4)
            {
                SHP0v4 *header = Header4;

                if ((_name == null) && (header->_stringOffset != 0))
                {
                    _name = header->ResourceString;
                }

                _numFrames = header->_numFrames;
                _loop      = header->_loop != 0;

                bint *stringOffset = header->StringEntries;
                for (int i = 0; i < header->_numEntries; i++)
                {
                    _strings.Add(new String((sbyte *)stringOffset + stringOffset[i]));
                }

                if (header->_origPathOffset > 0)
                {
                    _originalPath = header->OrigPath;
                }

                (_userEntries = new UserDataCollection()).Read(header->UserData);

                return(header->Group->_numEntries > 0);
            }
            else
            {
                SHP0v3 *header = Header3;

                if ((_name == null) && (header->_stringOffset != 0))
                {
                    _name = header->ResourceString;
                }

                _numFrames = header->_numFrames;
                _loop      = header->_loop != 0;

                bint *stringOffset = header->StringEntries;
                for (int i = 0; i < header->_numEntries; i++)
                {
                    _strings.Add(new String((sbyte *)stringOffset + stringOffset[i]));
                }

                if (header->_origPathOffset > 0)
                {
                    _originalPath = header->OrigPath;
                }

                return(header->Group->_numEntries > 0);
            }
        }
示例#2
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            ResourceGroup *group;

            if (_version == 4)
            {
                SHP0v4 *header = (SHP0v4 *)address;
                *       header = new SHP0v4(_loop, (ushort)(_numFrames), (ushort)_strings.Count);
                group = header->Group;
            }
            else
            {
                SHP0v3 *header = (SHP0v3 *)address;
                *       header = new SHP0v3(_loop, (ushort)(_numFrames), (ushort)_strings.Count);
                group = header->Group;
            }

            *group = new ResourceGroup(Children.Count);

            VoidPtr entryAddress = group->EndAddress;
            VoidPtr dataAddress  = entryAddress;

            foreach (SHP0EntryNode n in Children)
            {
                dataAddress += n._entryLen;
            }

            ResourceEntry *rEntry = group->First;

            foreach (SHP0EntryNode n in Children)
            {
                (rEntry++)->_dataOffset = (int)entryAddress - (int)group;

                n._dataAddr = dataAddress;
                n.Rebuild(entryAddress, n._entryLen, true);
                entryAddress += n._entryLen;
                dataAddress  += n._dataLen;
            }

            ((SHP0v3 *)address)->_stringListOffset = (int)dataAddress - (int)address;

            dataAddress += _strings.Count * 4;

            if (_userEntries.Count > 0 && _version == 4)
            {
                _userEntries.Write(((SHP0v4 *)address)->UserData = dataAddress);
            }
        }