public override void Draw() { base.Draw(); if (SelectedEntity == null) { return; } MyListDictionary <MemberInfo, MemberInfo> watch = null; m_watch.TryGetValue(m_selectedType, out watch); if (m_showWatch) { DrawWatch(watch); return; } StringBuilder sb = new StringBuilder(SelectedEntity.GetType().Name); Type currentType = m_selectedType; m_currentInstance = SelectedEntity; foreach (var member in m_currentPath) { sb.Append("."); sb.Append(member.Name); m_currentInstance = member.GetValue(m_currentInstance); currentType = m_currentInstance.GetType(); } if (currentType != m_lastType) { m_lastType = currentType; m_members.Clear(); MemberInfo[] members = currentType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var member in members) { if (member.DeclaringType == currentType) { m_members.Add(member); } } //m_members.AddArray(members); members = currentType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var member in members) { if (member.DeclaringType == currentType) { m_members.Add(member); } } m_members.Sort((x, y) => string.Compare(x.Name, y.Name)); //m_members.AddArray(members); } Vector2 pos = new Vector2(100, 50);// m_counter * 0.2f); MyRenderProxy.DebugDrawText2D(pos, sb.ToString(), Color.White, 0.65f); pos.Y += 20; for (int i = SelectedMember; i < m_members.Count; i++) { var info = m_members[i]; object value = info.GetValue(m_currentInstance); var text = value != null?value.ToString() : "null"; text = text.Replace("\n", ""); MyRenderProxy.DebugDrawText2D(pos, info.Name + " : " + text, (watch != null && watch.GetList(info) != null) ? Color.Green : Color.White, 0.55f); pos.Y += 12; } }
public override bool HandleInput() { var handled = base.HandleInput(); if (handled) { return(true); } if (MyInput.Static.IsKeyPress(MyKeys.OemTilde)) { var info = m_members.Count > SelectedMember ? m_members[SelectedMember] : null; if (MyInput.Static.IsNewKeyPressed(MyKeys.OemPeriod)) { if (m_currentPath.Count > 0 && m_currentPath[m_currentPath.Count - 1] == info) { return(true); } var obj = info.GetValue(m_currentInstance); if (obj != null && !obj.GetType().IsPrimitive&& obj.GetType().GetFields().Length + obj.GetType().GetProperties().Length > 0) { m_currentPath.Add(info); } m_counter = 0; return(true); } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemComma)) { if (m_currentPath.Count > 0) { m_currentPath.RemoveAt(m_currentPath.Count - 1); m_counter = 0; } return(true); } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemQuestion)) { if (m_showWatch) { if (!m_toPlot.Add(SelectedMember)) { m_toPlot.Remove(SelectedMember); } } else { MyListDictionary <MemberInfo, MemberInfo> watch = null; if (!m_watch.TryGetValue(m_selectedType, out watch)) { watch = m_watch[m_selectedType] = new MyListDictionary <MemberInfo, MemberInfo>(); } var lst = watch.GetList(info); if (lst != null) { watch.Remove(info); return(true); } lst = watch.GetOrAddList(info); lst.AddList(m_currentPath); lst.Add(info); } return(true); } else if (MyInput.Static.IsNewKeyPressed(MyKeys.M)) { m_showWatch = !m_showWatch; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemPlus)) { m_scale *= 2; } else if (MyInput.Static.IsNewKeyPressed(MyKeys.OemMinus)) { m_scale /= 2; } m_counter += VRage.Input.MyInput.Static.PreviousMouseScrollWheelValue() - VRage.Input.MyInput.Static.MouseScrollWheelValue(); m_counter = (long)MyMath.Clamp(m_counter, 0, m_members.Count / 0.002f); } return(handled); }