private void listView_Click(object sender, EventArgs e) { // check if there is an item selected if (listView.SelectedItems.Count < 1) { return; } // check if this item has a node connected to it. The no-errors message doesn't Nodes.Node node = listView.SelectedItems[0].Tag as Nodes.Node; if (node == null) { return; } // show the behaviour and select the node. NodeViewData nvd = _behaviorTreeList.ShowNode(node); Debug.Check(nvd != null); _behaviorTreeView.SelectedNode = nvd; _behaviorTreeView.ShowNode(nvd); PropertiesDock.InspectObject(nvd.RootBehavior, nvd.Node); }
/// <summary> /// Show the behavior tree view. /// </summary> /// <param name="behaviorFilename">The behavior filename in the workspace folder.</param> public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename) { if (string.IsNullOrEmpty(behaviorFilename)) { return(null); } if (!Path.IsPathRooted(behaviorFilename)) { behaviorFilename = FileManagers.FileManager.GetFullPath(behaviorFilename); } if (!File.Exists(behaviorFilename)) { return(null); } BehaviorNode behavior = BehaviorManager.Instance.GetBehavior(behaviorFilename); if (behavior == null) { behavior = BehaviorManager.Instance.LoadBehavior(behaviorFilename); } if (behavior is Node) { BehaviorTreeList behaviorTreeList = BehaviorManager.Instance as BehaviorTreeList; if (behaviorTreeList != null) { behaviorTreeList.ShowNode(behavior as Node); } } return(BehaviorTreeViewDock.GetBehaviorTreeView(behavior)); }
/// <summary> /// Show the behavior tree view. /// </summary> /// <param name="behaviorFilename">The behavior filename in the workspace folder.</param> public static BehaviorNode ShowBehavior(string behaviorFilename) { if (string.IsNullOrEmpty(behaviorFilename)) { return(null); } if (!Path.IsPathRooted(behaviorFilename)) { behaviorFilename = FileManagers.FileManager.GetFullPath(behaviorFilename); } if (!File.Exists(behaviorFilename)) { if (!Plugin.WrongWorksapceReported) { Plugin.WrongWorksapceReported = true; string errorInfo = string.Format(Resources.WorkspaceDebugErrorInfo, behaviorFilename); MessageBox.Show(errorInfo, Resources.WorkspaceError, MessageBoxButtons.OK); ErrorInfoDock.Inspect(); ErrorInfoDock.WriteLine(errorInfo); } return(null); } BehaviorNode behavior = null; bool bForceLoad = false; if (Plugin.EditMode == EditModes.Analyze && _agent_plannings.Count > 0) { bForceLoad = true; } if (!bForceLoad) { behavior = BehaviorManager.Instance.GetBehavior(behaviorFilename); } if (behavior == null) { behavior = BehaviorManager.Instance.LoadBehavior(behaviorFilename, bForceLoad); } if (behavior is Node) { BehaviorTreeList behaviorTreeList = BehaviorManager.Instance as BehaviorTreeList; if (behaviorTreeList != null) { behaviorTreeList.ShowNode(behavior as Node); } } return(behavior); }
public static BehaviorTreeView ShowPlanning(FrameStatePool.PlanningProcess planning) { string behaviorFilename = FileManagers.FileManager.GetFullPath(planning._behaviorTree); if (!File.Exists(behaviorFilename)) { return(null); } string planningName = string.Format("PLanning_{0}_{1}", planning._frame, planning._index); Dictionary <string, BehaviorNode> list_plannings = null; if (!_agent_plannings.ContainsKey(planning._agentFullName)) { list_plannings = new Dictionary <string, BehaviorNode>(); _agent_plannings.Add(planning._agentFullName, list_plannings); } else { list_plannings = _agent_plannings[planning._agentFullName]; } BehaviorNode behavior = null; if (!list_plannings.ContainsKey(planningName)) { Plugin.PlanningProcess = planning; behavior = BehaviorManager.Instance.LoadBehavior(behaviorFilename, true); Behavior b = behavior as Behavior; b.PlanningProcess = planning; Plugin.PlanningProcess = null; b.PlanIsCollapseFailedBranch = Behavior.kPlanIsCollapseFailedBranch; list_plannings.Add(planningName, behavior); behavior.Filename = planningName; ((Node)behavior).Label = planningName; } else { behavior = list_plannings[planningName]; } Debug.Check(behavior is Node); BehaviorTreeList behaviorTreeList = BehaviorManager.Instance as BehaviorTreeList; Debug.Check(behaviorTreeList != null); behaviorTreeList.ShowNode(behavior as Node); BehaviorTreeView view = BehaviorTreeViewDock.GetBehaviorTreeView(behavior); return(view); }
/// <summary> /// Show the behavior tree view. /// </summary> /// <param name="behaviorFilename">The behavior filename in the workspace folder.</param> public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename) { if (string.IsNullOrEmpty(behaviorFilename)) { return(null); } if (!Path.IsPathRooted(behaviorFilename)) { behaviorFilename = FileManagers.FileManager.GetFullPath(behaviorFilename); } if (!File.Exists(behaviorFilename)) { return(null); } BehaviorNode behavior = null; bool bForceLoad = false; if (Plugin.EditMode == EditModes.Analyze && _agent_plannings.Count > 0) { bForceLoad = true; } if (!bForceLoad) { behavior = BehaviorManager.Instance.GetBehavior(behaviorFilename); } if (behavior == null) { behavior = BehaviorManager.Instance.LoadBehavior(behaviorFilename, bForceLoad); } if (behavior is Node) { BehaviorTreeList behaviorTreeList = BehaviorManager.Instance as BehaviorTreeList; if (behaviorTreeList != null) { behaviorTreeList.ShowNode(behavior as Node); } } return(BehaviorTreeViewDock.GetBehaviorTreeView(behavior)); }
public static void ShowObject(ObjectPair obj) { BehaviorTreeList behaviorTreeList = BehaviorManager.Instance as BehaviorTreeList; if (behaviorTreeList == null) { return; } Nodes.Node node = null; Attachments.Attachment attach = null; if (obj.Obj is Nodes.Node) { node = (Nodes.Node)obj.Obj; } else if (obj.Obj is Attachments.Attachment) { attach = (Attachments.Attachment)obj.Obj; node = attach.Node; } if (node != null) { behaviorTreeList.ShowNode(node, obj.Root); if (BehaviorTreeViewDock.LastFocused != null) { BehaviorTreeView behaviorTreeView = BehaviorTreeViewDock.LastFocused.BehaviorTreeView; if (behaviorTreeView != null) { behaviorTreeView.SelectedNodePending = node; behaviorTreeView.SelectedAttachmentPending = attach; behaviorTreeView.Refresh(); } } } }