/// <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); }
public ExportDialog(BehaviorTreeList behaviorTreeList, BehaviorNode node, bool ignoreErrors, TreeNode selectedTreeRoot, int formatIndex) { _initialized = false; InitializeComponent(); _behaviorTreeList = behaviorTreeList; _node = node; _ignoreErrors = ignoreErrors; _selectedTreeRoot = selectedTreeRoot; // add all valid exporters to the format combobox Debug.Check(Workspace.Current != null); int exportIndex = -1; for (int i = 0; i < Plugin.Exporters.Count; ++i) { ExporterInfo info = Plugin.Exporters[i]; if (node != null || info.MayExportAll) { int index = this.exportSettingGridView.Rows.Add(); DataGridViewRow row = this.exportSettingGridView.Rows[index]; row.Cells["Enable"].Value = Workspace.Current.ShouldBeExported(info.ID); row.Cells["Format"].Value = info.Description; row.Cells["Format"].ReadOnly = true; if (info.HasSettings) { int fileCount = Workspace.Current.GetExportFileCount(info.ID); row.Cells["Setting"].Value = fileCount.ToString(); row.Cells["Setting"].ReadOnly = false; } else { row.Cells["Setting"].Value = ""; row.Cells["Setting"].ReadOnly = true; } if (Workspace.Current.ShouldBeExported(info.ID) && (exportIndex == -1 || info.HasSettings)) { exportIndex = i; } } } changeExportFormat(exportIndex); _initialized = true; }
private List <Nodes.Node> GetRootNodes(FindRange findRange) { List <Nodes.Node> rootNodes = new List <Nodes.Node>(); switch (findRange) { case FindRange.CurrentFile: if (BehaviorTreeViewDock.LastFocused != null) { BehaviorTreeView behaviorTreeView = BehaviorTreeViewDock.LastFocused.BehaviorTreeView; if (behaviorTreeView != null && behaviorTreeView.RootNodeView != null) { rootNodes.Add(behaviorTreeView.RootNodeView.Node); } } break; case FindRange.AllOpenFiles: foreach (BehaviorTreeViewDock dock in BehaviorTreeViewDock.Instances) { BehaviorTreeView behaviorTreeView = dock.BehaviorTreeView; if (behaviorTreeView != null && behaviorTreeView.RootNodeView != null) { rootNodes.Add(behaviorTreeView.RootNodeView.Node); } } break; case FindRange.EntireWorkspace: BehaviorTreeList behaviorTreeList = BehaviorManager.Instance as BehaviorTreeList; if (behaviorTreeList != null) { foreach (Nodes.BehaviorNode behavior in behaviorTreeList.GetAllBehaviors()) { if (behavior != null && behavior is Nodes.Node) { rootNodes.Add((Nodes.Node)behavior); } } } break; } return(rootNodes); }
/// <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 ExportDialog(BehaviorTreeList behaviorTreeList, BehaviorNode node, bool ignoreErrors, TreeNode selectedTreeRoot, int formatIndex) { _initialized = false; InitializeComponent(); _behaviorTreeList = behaviorTreeList; _node = node; _ignoreErrors = ignoreErrors; _selectedTreeRoot = selectedTreeRoot; // add all valid exporters to the format combobox Debug.Check(Workspace.Current != null); int exportIndex = -1; for (int i = 0; i < Plugin.Exporters.Count; ++i) { ExporterInfo info = Plugin.Exporters[i]; if (node != null || info.MayExportAll) { int index = this.exportSettingGridView.Rows.Add(); DataGridViewRow row = this.exportSettingGridView.Rows[index]; bool isExported = Workspace.Current.ShouldBeExported(info.ID); if (info.ID == Plugin.SourceLanguage && this.ExportCustomizedMeta()) { isExported = true; } row.Cells["Enable"].Value = isExported; row.Cells["Format"].Value = info.Description; row.Cells["Format"].ReadOnly = true; row.Cells["Setting"].Value = info.HasSettings ? "..." : ""; row.Cells["Setting"].ReadOnly = true; if (Workspace.Current.ShouldBeExported(info.ID) && (exportIndex == -1 || info.HasSettings)) { exportIndex = i; } } } changeExportFormat(exportIndex); _initialized = true; }
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(); } } } }
private void RegisterBehaviorTreeList(BehaviorTreeListDock dock) { behaviorTreeListDock = dock; behaviorTreeList = dock.behaviorTreeList; nodeTreeList = dock.nodeTreeList; RegisterDelegateHandlers(); }
private void loadLayout(EditModes editMode, string layoutFile, bool bLoadWks) { preLoadLayout(editMode); __layoutFile = layoutFile; // Remove all controls and create a new dockPanel. this.Controls.Clear(); InitializeComponent(); this.RecentWorkspacesMenu = new RecentMenu(this.recentWorkspacesMenuItem, new RecentMenu.ClickedHandler(OnMenuRecentWorkspaces), "SOFTWARE\\Tencent\\Tag\\Behaviac\\MRU"); this.FormClosed -= this.MainWindow_FormClosed; this.FormClosed += this.MainWindow_FormClosed; this.KeyDown -= this.MainWindow_KeyDown; this.KeyDown += this.MainWindow_KeyDown; // Display the file version this.Text = "BehaviacDesigner " + this.ProductVersion; // Set the stored settings for the window this.WindowState = Settings.Default.MainWindowState; if (this.WindowState == FormWindowState.Normal) { this.Size = Settings.Default.MainWindowSize; this.Location = Settings.Default.MainWindowLocation; this.PerformLayout(); } // If we have no stored layout, generate a default one if (behaviorTreeListDock != null) { nodeTreeList.Dispose(); nodeTreeList = null; behaviorTreeList.Dispose(); behaviorTreeList = null; behaviorTreeListDock.Close(); behaviorTreeListDock = null; } bool layoutFileExisting = System.IO.File.Exists(layoutFile); if (layoutFileExisting) { // Add child controls for the dockPanel from the layout file. dockPanel.LoadFromXml(layoutFile, new WeifenLuo.WinFormsUI.Docking.DeserializeDockContent(GetContentFromPersistString)); if (this.behaviorTreeList == null) { //the corrupt layout file was deleted layoutFileExisting = false; } } if (!layoutFileExisting) { BehaviorTreeListDock btlDock = new BehaviorTreeListDock(); RegisterBehaviorTreeList(btlDock); btlDock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockLeft); PropertiesDock dock = new PropertiesDock(); dock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockRight); } if (this.WindowState == FormWindowState.Maximized) { this.Hide(); this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Maximized; this.Show(); if (!layoutFileExisting) { this.dockPanel.Size = new Size(this.Size.Width - 20, this.Size.Height - 68); } } postLoadLayout(editMode, bLoadWks); // Make sure the window is focused Focus(); }
public static void ShowErrorDialog(ref ErrorCheckDialog errorDialog, BehaviorTreeList behaviorTreeList, BehaviorTreeView behaviorTreeView, Form owner, string title, List <Node.ErrorCheck> result) { // store the old position of the check dialogue and close it if (errorDialog != null) { errorDialog.Close(); } // prepare the new dialogue errorDialog = new ErrorCheckDialog(); errorDialog.Owner = owner; errorDialog.BehaviorTreeList = behaviorTreeList; errorDialog.BehaviorTreeView = behaviorTreeView; errorDialog.Text = title; // add the errors to the check dialogue foreach (Node.ErrorCheck check in result) { BehaviorNode behavior = check.Node != null ? check.Node.Behavior : null; // group the errors by the behaviour their occured in // get the group for the error's behaviour ListViewGroup group = null; foreach (ListViewGroup grp in errorDialog.listView.Groups) { if (grp.Tag == behavior) { group = grp; break; } } // if there is no group, create it if (group == null) { group = new ListViewGroup(behavior != null ? ((Node)behavior).Label : "Error"); group.Tag = behavior; errorDialog.listView.Groups.Add(group); } // create an item for the error in the group ListViewItem item = new ListViewItem(check.Description); item.Group = group; item.Tag = check.Node; switch (check.Level) { case (ErrorCheckLevel.Message): item.ImageIndex = 0; break; case (ErrorCheckLevel.Warning): item.ImageIndex = 1; break; case (ErrorCheckLevel.Error): item.ImageIndex = 2; break; } errorDialog.listView.Items.Add(item); } // if no errors were found, tell the user so if (result.Count < 1) { errorDialog.listView.Items.Add(new ListViewItem("No Errors.", (int)ErrorCheckLevel.Message)); } // show the dialogue errorDialog.Show(); }
public static void ShowErrorDialog(ref ErrorCheckDialog errorDialog, BehaviorTreeList behaviorTreeList, BehaviorTreeView behaviorTreeView, Form owner, string title, List<Node.ErrorCheck> result) { // store the old position of the check dialogue and close it if (errorDialog != null) { errorDialog.Close(); } // prepare the new dialogue errorDialog = new ErrorCheckDialog(); errorDialog.Owner = owner; errorDialog.BehaviorTreeList = behaviorTreeList; errorDialog.BehaviorTreeView = behaviorTreeView; errorDialog.Text = title; // add the errors to the check dialogue foreach (Node.ErrorCheck check in result) { BehaviorNode behavior = check.Node != null ? check.Node.Behavior : null; // group the errors by the behaviour their occured in // get the group for the error's behaviour ListViewGroup group = null; foreach (ListViewGroup grp in errorDialog.listView.Groups) { if (grp.Tag == behavior) { group = grp; break; } } // if there is no group, create it if (group == null) { group = new ListViewGroup(behavior != null ? ((Node)behavior).Label : "Error"); group.Tag = behavior; errorDialog.listView.Groups.Add(group); } // create an item for the error in the group ListViewItem item = new ListViewItem(check.Description); item.Group = group; item.Tag = check.Node; switch (check.Level) { case (ErrorCheckLevel.Message): item.ImageIndex = 0; break; case (ErrorCheckLevel.Warning): item.ImageIndex = 1; break; case (ErrorCheckLevel.Error): item.ImageIndex = 2; break; } errorDialog.listView.Items.Add(item); } // if no errors were found, tell the user so if (result.Count < 1) { errorDialog.listView.Items.Add(new ListViewItem("No Errors.", (int)ErrorCheckLevel.Message)); } // show the dialogue errorDialog.Show(); }