public override bool OnInitialize() { base.OnInitialize(); if (_version == 4) { CLR0v4 *header = Header4; _numFrames = header->_frames; _loop = header->_loop != 0; if ((_name == null) && (header->_stringOffset != 0)) { _name = header->ResourceString; } if (header->_origPathOffset > 0) { _originalPath = header->OrigPath; } (_userEntries = new UserDataCollection()).Read(header->UserData); return(header->Group->_numEntries > 0); } else { CLR0v3 *header = Header3; _numFrames = header->_frames; _loop = header->_loop != 0; if ((_name == null) && (header->_stringOffset != 0)) { _name = header->ResourceString; } if (header->_origPathOffset > 0) { _originalPath = header->OrigPath; } return(header->Group->_numEntries > 0); } }
public override void OnRebuild(VoidPtr address, int length, bool force) { int count = Children.Count; CLR0Material *pMat = (CLR0Material *)(address + (_version == 4 ? CLR0v4.Size : CLR0v3.Size) + 0x18 + (count * 0x10)); int offset = Children.Count * 8; foreach (CLR0MaterialNode n in Children) { offset += n.Children.Count * 8; } RGBAPixel *pData = (RGBAPixel *)((VoidPtr)pMat + offset); ResourceGroup *group; if (_version == 4) { CLR0v4 *header = (CLR0v4 *)address; * header = new CLR0v4(length, _numFrames, count, _loop); group = header->Group; } else { CLR0v3 *header = (CLR0v3 *)address; * header = new CLR0v3(length, _numFrames, count, _loop); group = header->Group; } *group = new ResourceGroup(count); ResourceEntry *entry = group->First; foreach (CLR0MaterialNode n in Children) { (entry++)->_dataOffset = (int)pMat - (int)group; uint newFlags = 0; CLR0MaterialEntry *pMatEntry = (CLR0MaterialEntry *)((VoidPtr)pMat + 8); foreach (CLR0MaterialEntryNode e in n.Children) { newFlags |= ((uint)((1 + (e._constant ? 2 : 0)) & 3) << ((int)e._target * 2)); if (e._numEntries == 0) { *pMatEntry = new CLR0MaterialEntry((RGBAPixel)e._colorMask, (RGBAPixel)e._solidColor); } else { *pMatEntry = new CLR0MaterialEntry((RGBAPixel)e._colorMask, (int)pData - (int)((VoidPtr)pMatEntry + 4)); foreach (ARGBPixel p in e._colors) { *pData++ = (RGBAPixel)p; } } pMatEntry++; e._changed = false; } pMat->_flags = newFlags; pMat = (CLR0Material *)pMatEntry; n._changed = false; } if (_userEntries.Count > 0 && _version == 4) { CLR0v4 *header = (CLR0v4 *)address; header->UserData = pData; _userEntries.Write(pData); } }