예제 #1
0
        /// <summary>
        /// Initializes this.
        /// Use this if you want to re-initialize the class without creating a new instance.
        /// </summary>
        /// <param name="headerAddress">The address of the menu metadata header.</param>
        /// <param name="isLoaded">True if the metadata is already loaded into the game, else false.</param>
        public void Initialize(MetadataHeader *headerAddress, bool isLoaded)
        {
            Header = headerAddress;

            var entryHeaderPtr = (byte *)(headerAddress + 1);

            ObjectSectionHeader = (ObjectSectionHeader *)entryHeaderPtr;

            InitializeOrClear(ref Objects, ObjectSectionHeader->NumObjects);
            InitializeOrClear(ref Layers, ObjectSectionHeader->NumObjects);
            InitializeOrClear(ref ActionLayers, ObjectSectionHeader->NumObjects);

            // Add entry
            for (int x = 0; x < ObjectSectionHeader->NumObjects; x++)
            {
                var entryPtr = isLoaded ? ObjectSectionHeader->GetObjectPointer(ObjectSectionHeader, x) : (Object *)(entryHeaderPtr + (uint)ObjectSectionHeader->GetObjectPointer(ObjectSectionHeader, x));
                Objects.Add(entryPtr);

                // Add action layers.
                var actionLayers = GetItemOrDefault(ActionLayers, x);
                InitializeOrClear(ref actionLayers, 1);

                // Add layers
                var layers = GetItemOrDefault(Layers, x);
                InitializeOrClear(ref layers, entryPtr->LayerCount);

                for (int y = 0; y < entryPtr->LayerCount; y++)
                {
                    var subEntryPtr = isLoaded ? entryPtr->GetLayerPointer(entryPtr, y) : (Layer *)((byte *)entryPtr + (uint)entryPtr->GetLayerPointer(entryPtr, y));
                    if (y == 0)
                    {
                        actionLayers.Add((ActionLayer *)subEntryPtr);
                    }
                    else
                    {
                        layers.Add(subEntryPtr);
                    }
                }

                ActionLayers.Add(actionLayers);
                Layers.Add(layers);
            }

            // Add final section.
            TextureIdHeader = isLoaded ? Header->TextureIndicesPtr : (TextureSectionHeader *)((byte *)headerAddress + (uint)Header->TextureIndicesPtr);
        }
 /// <summary>
 /// Gets the pointer to the inline array of entries.
 /// </summary>
 /// <param name="thisItem">The address of this item.</param>
 public TextureEntry *GetEntryPointer(TextureSectionHeader *thisItem) => (TextureEntry *)(thisItem + 1);