private static void SoundBlock_Preprocess(AbideTagBlock block, TagDefinitionCollection cache) { //Get sound tag group AbideTagGroup sound = cache.GetTagGroup("snd!"); //Change definition to cache_file_sound_block sound.BlockName = "cache_file_sound_block"; }
private void tagDefinitions_BuildCache(string directory) { //Clear collection.Clear(); //Get files string[] abideTagGroupFiles = Directory.GetFiles(directory, "*.atg"); string[] abideTagBlockfiles = Directory.GetFiles(directory, "*.atb"); //Loop foreach (string abideTagGroup in abideTagGroupFiles) { //Load AbideTagGroup group = new AbideTagGroup(); group.Load(abideTagGroup); //Add collection.Add(group); } foreach (string abideTagGroup in abideTagBlockfiles) { //Load AbideTagBlock block = new AbideTagBlock(); block.Load(abideTagGroup); //Add collection.Add(block); } //Begin tagGroupTreeView.BeginUpdate(); //Clear tagGroupTreeView.Nodes.Clear(); //Recursive block node creation Func <AbideTagBlock, TreeNode> createTagBlockNode = null; createTagBlockNode = new Func <AbideTagBlock, TreeNode>((tagBlock) => { //Create Node TreeNode blockNode = new TreeNode(tagBlock.DisplayName) { Tag = tagBlock }; //Loop AbideTagBlock block = null; foreach (AbideTagField field in tagBlock.FieldSet) { //Check switch (field.FieldType) { case FieldType.FieldBlock: block = collection.GetTagBlock(field.BlockName); blockNode.Nodes.Add(createTagBlockNode(block)); field.ReferencedBlock = block; break; case FieldType.FieldStruct: block = collection.GetTagBlock(field.StructName); blockNode.Nodes.Add(createTagBlockNode(block)); field.ReferencedBlock = block; break; } } //Return return(blockNode); }); //Recursive group node creation Action <AbideTagGroup, TreeNode> createTagGroupNode = null; createTagGroupNode = new Action <AbideTagGroup, TreeNode>((tagGroup, node) => { //Check if (tagGroup.ParentGroupTag.Dword != 0) { createTagGroupNode(collection.GetTagGroup(tagGroup.ParentGroupTag), node); } //Add blocks node.Nodes.Add(createTagBlockNode(collection.GetTagBlock(tagGroup.BlockName))); }); //Loop foreach (AbideTagGroup group in collection.GetTagGroups()) { //Create Node TreeNode groupNode = new TreeNode($"[{group.GroupTag}] - {group.Name}") { Tag = group }; //Add parent blocks createTagGroupNode(group, groupNode); //Add tagGroupTreeView.Nodes.Add(groupNode); } //End tagGroupTreeView.EndUpdate(); }