Example #1
0
        protected internal virtual void PostProcess(VoidPtr dataAddress, StringTable stringTable)
        {
            PAT0Pattern *header = (PAT0Pattern *)dataAddress;

            header->ResourceStringAddress = stringTable[Name] + 4;
        }
Example #2
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            PAT0Pattern *header = (PAT0Pattern *)address;

            int x = 0;

            foreach (int i in _dataLens)
            {
                if (i == -1)
                {
                    _dataAddrs[x] = ((PAT0EntryNode)Parent.Children[((PAT0TextureNode)Children[x])._matIndex])._dataAddrs[((PAT0TextureNode)Children[x])._texIndex];
                }
                x++;
            }
            uint flags = 0;

            foreach (PAT0TextureNode table in Children)
            {
                table._texFlags |= PAT0Flags.Enabled;
                if (table.Children.Count > 1)
                {
                    table._texFlags &= ~PAT0Flags.FixedTexture;
                }
                else
                {
                    table._texFlags |= PAT0Flags.FixedTexture;
                }

                bool hasTex = false, hasPlt = false;

                //foreach (PAT0TextureEntryNode e in table.Children)
                //{
                //    if (e.Texture != null)
                //        hasTex = true;
                //    if (e.Palette != null)
                //        hasPlt = true;
                //}

                hasTex = table._hasTex;
                hasPlt = table._hasPlt;

                if (!hasTex)
                {
                    table._texFlags &= ~PAT0Flags.HasTexture;
                }
                else
                {
                    table._texFlags |= PAT0Flags.HasTexture;
                }
                if (!hasPlt)
                {
                    table._texFlags &= ~PAT0Flags.HasPalette;
                }
                else
                {
                    table._texFlags |= PAT0Flags.HasPalette;
                }

                if (table.Children.Count > 1)
                {
                    header->SetTexTableOffset(table.Index, _dataAddrs[table.Index]);
                    if (table._rebuild)
                    {
                        table.Rebuild(_dataAddrs[table.Index], PAT0TextureTable.Size + PAT0Texture.Size * table.Children.Count, true);
                    }
                }
                else
                {
                    PAT0TextureEntryNode entry = (PAT0TextureEntryNode)table.Children[0];
                    PAT0Node             node  = (PAT0Node)Parent;

                    short i = 0;
                    if (table._hasTex && !String.IsNullOrEmpty(entry.Texture))
                    {
                        i = (short)node._textureFiles.IndexOf(entry.Texture);
                    }

                    if (i < 0)
                    {
                        entry._texFileIndex = 0;
                    }
                    else
                    {
                        entry._texFileIndex = (ushort)i;
                    }

                    i = 0;
                    if (table._hasPlt && !String.IsNullOrEmpty(entry.Palette))
                    {
                        i = (short)node._paletteFiles.IndexOf(entry.Palette);
                    }

                    if (i < 0)
                    {
                        entry._pltFileIndex = 0;
                    }
                    else
                    {
                        entry._pltFileIndex = (ushort)i;
                    }

                    header->SetIndex(table.Index, entry._texFileIndex, false);
                    header->SetIndex(table.Index, entry._pltFileIndex, true);
                }

                flags = flags & ~((uint)0xF << (table._textureIndex * 4)) | ((uint)table._texFlags << (table._textureIndex * 4));
            }

            header->_flags = flags;
        }