/// <summary> /// returns the Root of the UITree. /// </summary> /// <param name="MemoryReader"></param> /// <returns></returns> static public UITreeNode UIRoot( IPythonMemoryReader MemoryReader) { var CandidateAddresses = PyTypeObject.EnumeratePossibleAddressesOfInstancesOfPythonTypeFilteredByObType(MemoryReader, "UIRoot"); var CandidatesWithChildrenCount = new List <KeyValuePair <UITreeNode, int> >(); foreach (var CandidateAddress in CandidateAddresses) { var Candidate = new UITreeNode(CandidateAddress, MemoryReader); int CandidateChildrenCount = 0; { var CandidateChildren = Candidate.EnumerateChildrenTransitive(MemoryReader); if (null != CandidateChildren) { CandidateChildrenCount = CandidateChildren.Count(); } } CandidatesWithChildrenCount.Add(new KeyValuePair <UITreeNode, int>(Candidate, CandidateChildrenCount)); } // return the candidate the most children nodes where found in. return (CandidatesWithChildrenCount .OrderByDescending((CandidateWithChildrenCount) => CandidateWithChildrenCount.Value) .FirstOrDefault() .Key); }
/// <summary> /// 移除指定位置的项,并返回移除的项 /// 该方法不会删除子节点 /// </summary> /// <param name="index"></param> /// <returns></returns> public UITreeNode RemoveAt(int index) { UITreeNode removeTarget = roots[index]; roots.RemoveAt(index); return(removeTarget); }
/// <summary> /// 移除节点 /// 注意该操作不会删除节点 /// </summary> /// <param name="uiTreeNode"></param> public bool RemoveTreeNode(UITreeNode uiTreeNode) { if (roots.Contains(uiTreeNode)) { return(roots.Remove(uiTreeNode)); } return(false); }
private void _assignEvent(UITreeNode treenode) { treenode.DisplayElement.OnMouseDown += DisplayElement_OnMouseDown; foreach (var child in treenode.TreeNodes) { _assignEvent(child); } }
/// <summary> /// 添加节点 /// </summary> /// <param name="uiTreeNode"></param> public void AddTreeNode(UITreeNode uiTreeNode) { if (!roots.Contains(uiTreeNode)) { roots.Add(uiTreeNode); uiTreeNode.Parent = null; } }
private void GetComponent() { m_container = transform.Find("Viewport/Content"); if (m_container.childCount.Equals(0)) { throw new Exception("UITreeNode Template can not be null! Create a Template!"); } TreeRootNode = m_container.GetChild(0).GetComponent <UITreeNode>(); }
protected void CloseChildren() { for (int i = 0; i < _children.Count; i++) { UITreeNode node = _children[i].GetComponent <UITreeNode>(); node.RemoveListener(); node.CloseChildren(); } UITree.Push(_children); _children = new List <GameObject>(); }
public UIClassifiers(RecipeGraphState main) : base(main) { _filters = new ItemFilters(); var panel = new UIPanel() { AnchorPoint = new Vector2(0.5f, 0.5f), SizeFactor = new Vector2(1, 1), }; _list = new UITreeList() { AnchorPoint = new Vector2(0.5f, 0.5f), SizeFactor = new Vector2(1, 1), Size = new Vector2(-10, -10), }; var scroll = new UIScrollBarV() { AnchorPoint = new Vector2(1, 0.5f), Pivot = new Vector2(1, 0.5f), }; _list.SetScrollBarV(scroll); panel.AppendChild(_list); foreach (var pair in _filters.ModFilters) { List <UITreeNode> itemcls = new List <UITreeNode>(); foreach (var pair2 in _filters.Filters) { var citem = new UIClassifierItem(pair2.Value.Name, pair2.Value.Texture) { Name = pair.Key + " " + pair2.Key, SizeFactor = new Vector2(1f, 0f), Size = new Vector2(0, 36f), }; citem.OnClick += Button_OnClick; itemcls.Add(new UITreeNode(citem, new List <UITreeNode>())); } var moditem = new UIClassifierItem(pair.Value.Name, pair.Value.Texture) { Name = pair.Key, SizeFactor = new Vector2(1f, 0f), Size = new Vector2(0, 36f), }; var node = new UITreeNode(moditem, itemcls); moditem.OnClick += Button_OnClick; _list.AddElement(node); if (pair.Key == "All") { _list.SelectedElement = node.DisplayElement; } } AppendChild(panel); }
/// <summary> /// 显示当前选择节点的说明 /// </summary> private void ShowNowSelectTreeNodeExplan() { //删除之前的 Transform[] childTranses = Enumerable.Range(0, showPanel.childCount).Select(temp => showPanel.GetChild(temp)).ToArray(); foreach (var childTrans in childTranses) { GameObject.Destroy(childTrans.gameObject); } //显示现在的 UITreeNode selectNode = uiTree.SelectNode; if (selectNode == null) { return; } EntryDataInfo entryDataInfo = selectNode.value as EntryDataInfo; if (entryDataInfo == null) { return; } if (!playerState.EntryEnableList.Contains(entryDataInfo.ID)) { return; } foreach (EntryDataInfo.EntryValue entryValue in entryDataInfo.Datas) { switch (entryValue.EntryValueType) { case EntryDataInfo.EnumEntryValueType.Title: AddTitle(entryValue.Data); break; case EntryDataInfo.EnumEntryValueType.Text: Text textValue = AddText(entryValue.Data); LinkImageText linkImageText = textValue as LinkImageText; if (linkImageText) { linkImageText.onHrefClick.AddListener(ClickLink); } break; case EntryDataInfo.EnumEntryValueType.Image: AddSprite(entryValue.Data); break; } } }
/// <summary> /// 显示当前选择节点的说明 /// </summary> private void ShowNowSelectTreeNodeExplan() { //清理之前的数据 int count = detailedInformationTrans.childCount; Transform[] childsTrans = Enumerable.Range(0, count).Select(temp => detailedInformationTrans.GetChild(temp)).ToArray(); foreach (Transform childTrans in childsTrans) { if (Transform.Equals(detailedInformationTestObj, childTrans))//不删除例子 { continue; } GameObject.DestroyImmediate(childTrans.gameObject); } //通过节点的数据判断该节点是什么节点 UITreeNode selectNode = synthesisItemTree.SelectNode; //如果是SynthesisDataStruct数据的节点则显示SynthesisDataStruct数据的内容 if (selectNode.value != null && selectNode.value.GetType().Equals(typeof(SynthesisDataStruct))) { SynthesisDataStruct synthesisDataStruct = selectNode.value as SynthesisDataStruct; //添加条目 Action <string> AddExplanTitleAction = (title) => { GameObject createTitle = GameObject.Instantiate <GameObject>(detailedInformationTestObj); createTitle.transform.SetParent(detailedInformationTrans); createTitle.GetComponent <Text>().text = title; createTitle.SetActive(true); }; //输入结构 AddExplanTitleAction("合成条件:"); foreach (SynthesisDataStruct.SynthesisItemStruct synthesisItemStruct in synthesisDataStruct.inputStruct) { int nowCount = playerState.PlayerAllGoods.Count(temp => temp.GoodsInfo.EnumGoodsType == synthesisItemStruct.itemType); //这里需要转换成对应的名字,这里暂时用枚举名 AddExplanTitleAction(synthesisItemStruct.itemType + ":" + nowCount + "/" + synthesisItemStruct.num); } //输出结构 AddExplanTitleAction("合成物品:"); //这里需要转换成对应的名字,这里暂时用枚举名 AddExplanTitleAction(synthesisDataStruct.outputStruct.itemType.ToString()); //自动对齐 VerticalLayoutGroup verticalLayoutGroup = detailedInformationTrans.GetComponent <VerticalLayoutGroup>(); verticalLayoutGroup.SetLayoutHorizontal(); verticalLayoutGroup.SetLayoutVertical(); } }
private void _dfsCalculate(UITreeNode node, float leftPadding, GameTime gameTime) { _maxLeftPadding = Math.Max(_maxLeftPadding, leftPadding); node.DisplayElement.LeftOffset = leftPadding; node.DisplayElement.Position = new Vector2(0, _totHeight); node.DisplayElement.IsSelected = (node.DisplayElement == SelectedElement); node.DisplayElement.Update(gameTime); _addElement(node.DisplayElement); _totHeight += node.DisplayElement.Height + ItemMargin; node.CanFold = node.TreeNodes.Count != 0; if (node.DisplayElement.IsFolded) { return; } foreach (var child in node.TreeNodes) { _dfsCalculate(child, leftPadding + LayerPaddingLeft, gameTime); } }
static MemoryReadingReportModel.UINode BuildReport(UITreeNode node, IPythonMemoryReader reader) { node.LoadType(reader); node.LoadDict(reader); node.LoadChildren(reader); var immediateChildrenReports = node.children?.Select(childNode => BuildReport(childNode, reader))?.ToArray(); return(new MemoryReadingReportModel.UINode { BaseAddress = node.BaseAddress, PyTypeObjAddress = node.ob_type, PyTypeName = node.TypeObject?.tp_name_Val, Dict = BuildReport(node.Dict, reader), Children = immediateChildrenReports, ChildrenTransitiveCount = (immediateChildrenReports?.Length + immediateChildrenReports?.Select(immediateChild => immediateChild?.ChildrenTransitiveCount ?? 0)?.Sum()) ?? 0, }); }
/// <summary> /// 向上选择节点 /// </summary> public void SelectUPTreeNode() { if (selectNode != null) { UITreeNode tempSelectNode = selectNode; if (selectNode.Parent != null)//不是根节点 { int index = selectNode.Parent.IndexOf(selectNode); if (index > 0) { UITreeNode tempNode = selectNode.Parent[index - 1]; Func <UITreeNode, UITreeNode> FindDeepLastNode = null; FindDeepLastNode = (targetNode) => { if (targetNode.Count > 0) { return(FindDeepLastNode(targetNode[targetNode.Count - 1])); } else { return(targetNode); } }; tempSelectNode = FindDeepLastNode(tempNode); } else if (index == 0) { tempSelectNode = selectNode.Parent; } } else//这是根节点 { int index = roots.IndexOf(selectNode); if (index > 0) { tempSelectNode = roots[index - 1]; } } tempSelectNode.IsSelect = true; } }
/// <summary> /// 点击连接 /// </summary> /// <param name="link"></param> private void ClickLink(string link) { int id; if (entryIDToNodeDic != null && int.TryParse(link, out id) && entryIDToNodeDic.ContainsKey(id)) { Action <UITreeNode> SetTreeNodeExplan = null; SetTreeNodeExplan = (temp) => { if (temp == null) { return; } temp.IsExpand = true; SetTreeNodeExplan(temp.Parent); }; UITreeNode uiTreeNode = entryIDToNodeDic[id]; SetTreeNodeExplan(uiTreeNode); uiTreeNode.IsSelect = true; } }
/// <summary> /// 初始化显示 /// </summary> private void InitShow() { synthesisItemTree.Clear(); SynthesisDataStruct[] synthesisDataStructs = synthesisStructData.SearchSynthesisData(temp => temp.synthesisType == iSynthesisState.SynthesisType); EnumSynthesisItem[] enumSynthesisItems = synthesisDataStructs.Select(temp => temp.synthesisItem).Distinct().ToArray(); //这里需要将枚举转换成对应的文字,但是这里直接使用枚举了(这里添加的是根节点) Dictionary <EnumSynthesisItem, UITreeNode> rootNodeDic = enumSynthesisItems.ToDictionary(temp => temp, temp => { UITreeNode rootNode = synthesisItemTree.CreateTreeNode(); rootNode.ExplanText = temp.ToString(); rootNode.IsDisplay = true; rootNode.IsExpand = true; rootNode.value = null; synthesisItemTree.AddTreeNode(rootNode); return(rootNode); }); //这里添加的是各自类型的子节点 foreach (KeyValuePair <EnumSynthesisItem, UITreeNode> rootNode in rootNodeDic) { SynthesisDataStruct[] tempSynthesisDataStructs = synthesisDataStructs.Where(temp => temp.synthesisItem == rootNode.Key).ToArray(); foreach (SynthesisDataStruct tempSynthesisDataStruct in tempSynthesisDataStructs) { UITreeNode createNode = synthesisItemTree.CreateTreeNode(); createNode.ExplanText = tempSynthesisDataStruct.name; createNode.IsDisplay = true; createNode.IsExpand = true; createNode.value = tempSynthesisDataStruct; rootNode.Value.Add(createNode); } } //选择设置第一个选项为当前选项 if (synthesisItemTree.Count > 0) { synthesisItemTree[0].IsSelect = true; } }
public void ReadRootNode() { try { var MengeCandidateProcess = System.Diagnostics.Process.GetProcessesByName("exefile"); var EveProcess = MengeCandidateProcess.FirstOrDefault(); if (null == EveProcess) { return; } MemoryReader = new ProcessMemoryReader(EveProcess); PyMemoryReader = new PythonMemoryReader(MemoryReader); RootNode = EveOnline.UIRoot(PyMemoryReader); } catch (Exception e) { RootNode = null; } }
/// <summary> /// 创建一个树节点 /// </summary> /// <returns></returns> public UITreeNode CreateTreeNode() { GameObject createNodeObj = Instantiate(exampleNode); UITreeNode createNode = createNodeObj.GetComponent <UITreeNode>(); allTreeNode.Add(createNode); createNode.DeleteNodeHandle += (uiTreeNode) => { allTreeNode.Remove(uiTreeNode); }; createNode.SelectNodeHandle += (uiTreeNode) => { if (selectNode && !object.Equals(selectNode, uiTreeNode)) { selectNode.IsSelect = false; } bool selectNodeChanged = !UITreeNode.Equals(selectNode, uiTreeNode); if (selectNodeChanged) { selectNode = uiTreeNode; //将该节点至于显示区域中 ShowUITreeNode(); //回调通知 if (SelectNodeChangedHandle != null) { SelectNodeChangedHandle(selectNode); } } }; createNode.StateChangedHandle += () => { UpdateRenderer(); }; createNodeObj.transform.SetParent(rendererPanel); createNodeObj.SetActive(false); return(createNode); }
/// <summary> /// 向下选择节点 /// </summary> public void SelectDownTreeNode() { if (selectNode != null) { UITreeNode tempSelectNode = selectNode; Action <UITreeNode> MoveDownAction = null; MoveDownAction = (targetNode) => { if (targetNode.Parent != null) //不是根节点 { int index = targetNode.Parent.IndexOf(targetNode); //在父节点中的下标 if (index >= 0 && index < targetNode.Parent.Count - 1) { tempSelectNode = targetNode.Parent[index + 1]; } else if (index >= targetNode.Parent.Count - 1) { MoveDownAction(targetNode.Parent);//已经到了该子节点的尽头,返回父节点寻找父节点向下移动的方式 } } else if (targetNode.IsExpand && targetNode.Count > 0)//当前节点是根节点且是展开的且子节点不为0 { tempSelectNode = targetNode[0]; } else//当前节点是根节点且无法项该节点的子节点移动了 { int index = roots.IndexOf(targetNode); if (index >= 0 && index < roots.Count - 1) { tempSelectNode = roots[index + 1]; } } }; MoveDownAction(selectNode); tempSelectNode.IsSelect = true; } }
/// <summary> /// 通过数据创建节点 /// </summary> /// <param name="target">数据</param> /// <param name="parent">父节点</param> private void CreateNodeByEntryDataInfo(EntryDataInfo target, UITreeNode parent = null) { UITreeNode uiTreeNode = uiTree.CreateTreeNode(); if (parent == null) { uiTree.AddTreeNode(uiTreeNode); } else { parent.Add(uiTreeNode); } uiTreeNode.value = target; if (playerState.EntryEnableList.Contains(target.ID)) { uiTreeNode.ExplanText = target.Name; } else { uiTreeNode.ExplanText = "????????????????"; } uiTreeNode.IsDisplay = true; uiTreeNode.IsExpand = false; if (!entryIDToNodeDic.ContainsKey(target.ID))//添加到字典中 { entryIDToNodeDic.Add(target.ID, uiTreeNode); } EntryDataInfo[] entryDataInfos = entryData.GetNexts(target); if (entryDataInfos != null) { foreach (EntryDataInfo entryDataInfo in entryDataInfos) { CreateNodeByEntryDataInfo(entryDataInfo, uiTreeNode); } } }
/// <summary> /// 树节点选择项发生变化事件 /// </summary> /// <param name="obj"></param> private void SynthesisItemTree_SelectNodeChangedHandle(UITreeNode obj) { ShowNowSelectTreeNodeExplan(); }
public void OutputToFile(string path) { List <string> data = new List <string>(); try { ReadRootNode(); if (RootNode == null) { return; } else { data.Add("UIRoot found at " + RootNode.BaseAddress.ToString("x")); data.Add(""); } var AllNodes = new UITreeNode[] { RootNode } .Concat(RootNode.EnumerateChildrenTransitive(PyMemoryReader)).ToArray(); // show off the spoils.... foreach (var Node in AllNodes) { data.Add("=================================================================================="); data.Add("= UITree Node at " + Node.BaseAddress.ToString("x")); data.Add("=================================================================================="); data.Add(""); var Dict = Node.Dict; if (null == Dict) { continue; } var DictSlots = Dict.Slots; if (null == DictSlots) { continue; } int itterator = 0; // show info for each entry in dict that has a String as Key. foreach (var Entry in DictSlots) { var EntryKeyStr = Entry.KeyStr; if (null == EntryKeyStr) { continue; } var me_value = Entry.me_value; PyObject obj = new PyObject(me_value.Value, MemoryReader); PyTypeObject typeObject = obj.LoadType(PyMemoryReader); data.Add ( itterator + " : " + Entry.BaseAddress.ToString("x") + " + Entry[\"" + EntryKeyStr + "\"].Value(" + GetTypeName(me_value) + ") = " + (me_value.HasValue ? GetStringValueFromObject(obj) : "null") ); if (GetTypeName(me_value) == "list") { uint[] items = ((PyList)ReadValue(me_value)).Items; if (items == null) { continue; } foreach (uint address in items) { obj = new PyObject(address, MemoryReader); String type = GetTypeName(obj); data.Add("+ List Item: (" + type + ") = " + GetStringValueFromObject(obj)); } } itterator += 1; } data.Add(""); } System.IO.File.WriteAllLines(path, data.ToArray()); } finally { } }
public MemoryManager() { try { // Prep: RootNode = null; Nodes = new Dictionary <long, MemoryNode>(); ReadRootNode(); if (RootNode == null) { return; } var AllNodes = new UITreeNode[] { RootNode } .Concat(RootNode.EnumerateChildrenTransitive(PyMemoryReader)).ToArray(); // show off the spoils.... foreach (var Node in AllNodes) { MemoryNode memNode = new MemoryNode(); memNode.BaseAddress = Node.BaseAddress; var Dict = Node.Dict; if (null == Dict) { continue; } var DictSlots = Dict.Slots; if (null == DictSlots) { continue; } // show info for each entry in dict that has a String as Key. foreach (var Entry in DictSlots) { var EntryKeyStr = Entry.KeyStr; if (null == EntryKeyStr) { continue; } var me_value = Entry.me_value; PyTypeObject typeObject = new PyObject(me_value.Value, MemoryReader).LoadType(PyMemoryReader); MemoryDictEntry memEntry = new MemoryDictEntry(Entry.BaseAddress, EntryKeyStr, GetTypeName(me_value), ReadValue(me_value)); memNode.AddMemoryDictEntry(memEntry); } Nodes.Add(memNode.BaseAddress, memNode); } } finally { } }
/// <summary> /// 树节点选择项发生变化事件 /// </summary> /// <param name="obj"></param> private void UiTree_SelectNodeChangedHandle(UITreeNode obj) { ShowNowSelectTreeNodeExplan(); }
/// <summary> /// 将指定项插入到指定位置 /// </summary> /// <param name="index"></param> /// <param name="item"></param> public void Insert(int index, UITreeNode item) { roots.Insert(index, item); item.Parent = null; }