public AnimationBundleWrapper(DATA_Parser.FileEntry file, DATA_Parser dataParser,
                                      Dictionary <uint, DATA_Parser.FileEntry> animationFiles)
        {
            Label = file.Hash.ToString();
            Tag   = file.ChunkEntry.Data;

            File    = file;
            Version = dataParser.Version;

            using (var reader = new FileReader(file.ChunkEntry.Data, true))
            {
                uint numAnimations = reader.ReadUInt32();
                reader.ReadUInt32();
                for (int i = 0; i < numAnimations; i++)
                {
                    reader.ReadUInt32();
                    uint hash = reader.ReadUInt32();
                    if (animationFiles.ContainsKey(hash))
                    {
                        var fileNode = new AnimationWrapper(animationFiles[hash], dataParser);
                        AddChild(fileNode);
                    }
                }
            }
        }
示例#2
0
        private ObjectTreeNode LoadChunkTabe()
        {
            ObjectTreeNode root = new ObjectTreeNode();

            Dictionary <ChunkFileType, ObjectTreeNode> FileContainers = new Dictionary <ChunkFileType, ObjectTreeNode>();
            Dictionary <uint, DATA_Parser.FileEntry>   animationFiles = new Dictionary <uint, DATA_Parser.FileEntry>();

            foreach (var file in DataFile.Files)
            {
                if (!animationFiles.ContainsKey(file.Hash))
                {
                    animationFiles.Add(file.Hash, file);
                }
                if (!GlobalFileList.ContainsKey(file.Hash))
                {
                    GlobalFileList.Add(file.Hash, file);
                }
            }

            Dictionary <string, ObjectTreeNode> fileGrouper = new Dictionary <string, ObjectTreeNode>();

            foreach (var file in DataFile.Files)
            {
                ChunkFileType type = file.ChunkEntry.ChunkType;
                if (!FileContainers.ContainsKey(type))
                {
                    FileContainers.Add(type, new ObjectTreeNode(type.ToString() + $"_{type.ToString("X")}"));
                    root.AddChild(FileContainers[type]);
                }

                var folder   = FileContainers[file.ChunkEntry.ChunkType];
                var fileNode = new ObjectTreeNode(file.Hash.ToString());
                fileNode.Tag = file.ChunkEntry.Data;

                if (type == ChunkFileType.Model)
                {
                    fileNode = new ModelWrapper(file, DataFile);
                }
                if (type == ChunkFileType.AnimationData)
                {
                    fileNode = new AnimationWrapper(file, DataFile);
                }
                if (type == ChunkFileType.Texture)
                {
                    fileNode = new TextureWrapper(file, DataFile);
                }
                if (type == ChunkFileType.Skeleton)
                {
                    fileNode = new SkeletonWrapper(file, DataFile);
                }
                if (type == ChunkFileType.Script)
                {
                    fileNode = new ScriptWrapper(file, DataFile);
                }
                if (type == ChunkFileType.AnimationBundles)
                {
                    fileNode = new AnimationBundleWrapper(file, DataFile, animationFiles);
                }

                //Attempt to group common hashes
                if (type == ChunkFileType.Model)
                {
                    fileGrouper.Add(fileNode.Label, fileNode);
                }

                if (type != ChunkFileType.Model && fileGrouper.ContainsKey(fileNode.Label))
                {
                    ObjectTreeNode tfolder = new ObjectTreeNode(type.ToString());
                    tfolder.AddChild(fileNode);
                    fileGrouper[fileNode.Label].AddChild(tfolder);
                }
                else
                {
                    folder.AddChild(fileNode);
                }

                if (type == ChunkFileType.Model)
                {
                    ObjectTreeNode chunkList = new ObjectTreeNode("Chunks");
                    fileNode.AddChild(chunkList);

                    foreach (var child in file.ChunkEntry.SubData)
                    {
                        chunkList.AddChild(ReadChunk(child));
                    }
                }
                else
                {
                    foreach (var child in file.ChunkEntry.SubData)
                    {
                        fileNode.AddChild(ReadChunk(child));
                    }
                }

                fileNode.Label += $"_({folder.ChildCount})";
                if (ExtensionList.ContainsKey(file.ChunkEntry.ChunkType))
                {
                    fileNode.Label += ExtensionList[file.ChunkEntry.ChunkType];
                }

                if (Hashing.HashNames.ContainsKey(file.Hash))
                {
                    fileNode.Label = Hashing.HashNames[file.Hash];
                }
            }
            return(root);
        }