public void PerformExtraction(CacheView owner_view) { m_ownerView = owner_view; switch (m_sender) { case TagExtractionSender.TagInstance: PerformExtractionTagInstance(); break; case TagExtractionSender.TagTree: PerformExtractionTagHierarchy(); break; } }
/// <summary>Performs the actual cache loading logic</summary> /// <param name="cv"></param> static CacheOpenDoWorkResults CacheOpenDoWorkLoad(CacheView cv) { var results = new CacheOpenDoWorkResults(); var engine = cv.m_engine; BlamLib.Blam.CacheFile cache = null; var gd = BlamLib.Program.GetManager(engine); var cid = BlamLib.Blam.DatumIndex.Null; try { cid = gd.OpenCacheFile(engine, cv.OpenFileDlg.FileName); cache = gd.GetCacheFile(cid); cache.Read(); } catch (Exception ex) { results.OpenException = ex; if (!cid.IsNull && cache != null) { gd.CloseCacheFile(cache.CacheId); } cache = null; } cv.m_cache = cache; if (cache != null) { results.TagTreeNodes = CacheOpenDoWorkGenerateTagTreeNodes(cv, cache); } return(results); }
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()); }
/// <summary>Performs the actual cache loading logic</summary> /// <param name="cv"></param> static CacheOpenDoWorkResults CacheOpenDoWorkLoad(CacheView cv) { var results = new CacheOpenDoWorkResults(); var engine = cv.m_engine; BlamLib.Blam.CacheFile cache = null; var gd = BlamLib.Program.GetManager(engine); var cid = BlamLib.Blam.DatumIndex.Null; try { cid = gd.OpenCacheFile(engine, cv.OpenFileDlg.FileName); cache = gd.GetCacheFile(cid); cache.Read(); } catch (Exception ex) { results.OpenException = ex; if (!cid.IsNull && cache != null) gd.CloseCacheFile(cache.CacheId); cache = null; } cv.m_cache = cache; if (cache != null) results.TagTreeNodes = CacheOpenDoWorkGenerateTagTreeNodes(cv, cache); return results; }
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(); }