static TreeNode[] CacheOpenDoWorkGenerateTagTreeNodes(CacheView cv, BlamLib.Blam.CacheFile cache) { List<TreeNode> tg_nodes; Dictionary<BlamLib.TagInterface.TagGroup, TreeNode> tg_dic; BlamLib.TagInterface.TagGroupCollection tg_coll, tg_invalid_for_cv; { var game_man = BlamLib.Program.GetManager(cache.EngineVersion); tg_dic = new Dictionary<BlamLib.TagInterface.TagGroup, TreeNode>(game_man.TagGroups.Count); tg_coll = game_man.TagGroups; tg_invalid_for_cv = game_man.TagGroupsInvalidForCacheViewer; cv.m_groupsInvalidForExtraction = game_man.TagGroupsInvalidForExtraction; tg_nodes = new List<TreeNode>(game_man.TagGroups.Count); }; #region Build tag group parent nodes foreach (var tg in tg_coll) { if (tg == BlamLib.TagInterface.TagGroup.Null || tg_invalid_for_cv.Contains(tg)) continue; var node = new TreeNode(tg.Name); node.Tag = tg; node.Checked = false; node.ForeColor = Color.LightGreen; node.BackColor = SystemColors.ControlDarkDark; tg_dic.Add(tg, node); tg_nodes.Add(node); } #endregion #region Build tag instances foreach (var inst in cache.Index.Tags) { if (inst.IsEmpty) continue; TreeNode tg_node; if (!tg_dic.TryGetValue(inst.GroupTag, out tg_node)) continue; var node = new TreeNode(cache.GetReferenceName(inst.ReferenceName)); node.Tag = inst; node.Checked = false; node.ContextMenuStrip = cv.MenuTagInstance; node.ForeColor = Color.LightGreen; node.BackColor = SystemColors.ControlDarkDark; tg_node.Nodes.Add(node); } #endregion #region Clean up the parent nodes tg_nodes.TrimExcess(); for (int x = 0; x < tg_nodes.Count; x++) if (tg_nodes[x].Nodes.Count == 0) tg_nodes.RemoveAt(x--); #endregion return tg_nodes.ToArray(); }