Esempio n. 1
0
        private void InspectObject(AgentType agentType, string agentName, string agentFullname)
        {
            Nodes.Node node = null;
            if (agentType == null && !string.IsNullOrEmpty(agentFullname))
            {
                int           frame            = AgentDataPool.CurrentFrame > -1 ? AgentDataPool.CurrentFrame : 0;
                string        behaviorFilename = FrameStatePool.GetBehaviorFilename(agentFullname, frame);
                List <string> highlightNodeIds = FrameStatePool.GetHighlightNodeIds(agentFullname, frame, behaviorFilename);
                List <string> updatedNodeIds   = FrameStatePool.GetUpdatedNodeIds(agentFullname, frame, behaviorFilename);
                Dictionary <string, FrameStatePool.NodeProfileInfos.ProfileInfo> profileInfos = FrameStatePool.GetProfileInfos(frame, behaviorFilename);

                BehaviorNode behavior = UIUtilities.ShowBehaviorTree(agentFullname, frame, highlightNodeIds, updatedNodeIds, HighlightBreakPoint.Instance, profileInfos);
                node = behavior as Nodes.Node;
            }

            _agentType = agentType;
            _agentName = agentName;

            Hide();

            setText(agentType, agentName);
            parametersPanel.InspectObject(agentType, agentFullname, node);

            if (AgentDataPool.CurrentFrame > -1 && !string.IsNullOrEmpty(agentName))
            {
                List <AgentDataPool.ValueMark> valueSet = AgentDataPool.GetValidValues(node, agentType, agentFullname, AgentDataPool.CurrentFrame);
                foreach (AgentDataPool.ValueMark value in valueSet)
                {
                    SetProperty(agentType != null ? agentType.ToString() : null, agentName, value.Name, value.Value);
                }
            }

            lostAnyFocus();
            Show();
        }
Esempio n. 2
0
 private void updateHighlights(string agentFullname, int frame, List <string> highlightedTransitionIds, List <string> highlightNodeIds, List <string> updatedNodeIds, HighlightBreakPoint breakPoint, Dictionary <string, FrameStatePool.NodeProfileInfos.ProfileInfo> profileInfos)
 {
     if (agentFullname == Plugin.DebugAgentInstance || breakPoint != null)
     {
         BehaviorNode behavior = UIUtilities.ShowBehaviorTree(agentFullname, frame, highlightedTransitionIds, highlightNodeIds, updatedNodeIds, breakPoint, profileInfos);
     }
 }
Esempio n. 3
0
        private void selectRowNode(DataGridViewRow row)
        {
            Debug.Check(row != null);
            if (row != null)
            {
                row.Selected = true;

                string           behaviorFilename = (string)row.Cells["BehaviorFilename"].Value;
                BehaviorTreeView behaviorTreeView = UIUtilities.ShowBehaviorTree(behaviorFilename);

                if (behaviorTreeView != null)
                {
                    string       nodeId = (string)row.Cells["NodeId"].Value;
                    NodeViewData nvd    = behaviorTreeView.RootNodeView.FindNodeViewData(nodeId);

                    if (nvd != null)
                    {
                        behaviorTreeView.SelectedNode = nvd;
                        //if (behaviorTreeView.ClickNode != null)
                        //    behaviorTreeView.ClickNode(nvd);
                        behaviorTreeView.Invalidate();
                    }
                }
            }
        }
Esempio n. 4
0
        private void InspectObject(AgentType agentType, string agentName, string agentFullName, FrameStatePool.PlanningState nodeState)
        {
            Nodes.Node node = null;

            if (!string.IsNullOrEmpty(agentFullName))
            {
                int           frame            = AgentDataPool.CurrentFrame > -1 ? AgentDataPool.CurrentFrame : 0;
                string        behaviorFilename = FrameStatePool.GetBehaviorFilename(agentFullName, frame);
                List <string> transitionIds    = FrameStatePool.GetHighlightTransitionIds(agentFullName, frame, behaviorFilename);
                List <string> highlightNodeIds = FrameStatePool.GetHighlightNodeIds(agentFullName, frame, behaviorFilename);
                List <string> updatedNodeIds   = FrameStatePool.GetUpdatedNodeIds(agentFullName, frame, behaviorFilename);
                Dictionary <string, FrameStatePool.NodeProfileInfos.ProfileInfo> profileInfos = FrameStatePool.GetProfileInfos(frame, behaviorFilename);

                BehaviorNode behavior = UIUtilities.ShowBehaviorTree(agentFullName, frame, transitionIds, highlightNodeIds, updatedNodeIds, HighlightBreakPoint.Instance, profileInfos);
                node = behavior as Nodes.Node;
            }

            _agentType = agentType;
            _agentName = agentName;

            Hide();

            setText(agentType, agentName);

            if (nodeState != null)
            {
                foreach (string agentFullName1 in nodeState._agents.Keys)
                {
                    string[] tokens = agentFullName1.Split('#');
                    Debug.Check(tokens.Length == 2);
                    string at = tokens[0];
                    string an = tokens[1];

                    AgentType agentType1 = Plugin.GetAgentType(at);

                    ParametersDock dock = findParametersDock(agentType1, an);
                    dock.InspectObject(agentType1, agentFullName1);

                    dock.setProperty(nodeState, agentFullName1);
                }
            }
            else if (AgentDataPool.CurrentFrame > -1 && !string.IsNullOrEmpty(agentName))
            {
                ParametersDock dock = findParametersDock(agentType, agentName);
                dock.InspectObject(agentType, agentFullName);

                List <AgentDataPool.ValueMark> valueSet = AgentDataPool.GetValidValues(agentType, agentFullName, AgentDataPool.CurrentFrame);

                foreach (AgentDataPool.ValueMark value in valueSet)
                {
                    dock.setProperty(null, value.Name, value.Value);
                }
            }

            lostAnyFocus();
            Show();
        }
Esempio n. 5
0
        private void openSelectedFiles()
        {
            foreach (DataGridViewRow row in this.filesGridView.SelectedRows)
            {
                UIUtilities.ShowBehaviorTree((string)row.Cells["filepathColumn"].Value);
            }

            this.Close();
        }
Esempio n. 6
0
        private void UpdateStackCb(string tree, bool bAdd)
        {
            if (bAdd)
            {
                callstackListBox.Items.Insert(0, tree);
            }
            else
            {
                //Debug.Check(callstackListBox.Items.Count < 2 || ((string)callstackListBox.Items[0]) == tree);
                if (callstackListBox.Items.Count > 0 && ((string)callstackListBox.Items[0]) == tree)
                {
                    callstackListBox.Items.RemoveAt(0);
                }
            }

            if (callstackListBox.Items.Count > 0)
            {
                //callstackListBox.SelectedIndex = -1;
                callstackListBox.SelectedIndex = 0;

                string currentBt = (string)callstackListBox.Items[0];
                UIUtilities.ShowBehaviorTree(currentBt);
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            try
            {
                if (Settings.Default.UpdateRequired)
                {
                    Settings.Default.Upgrade();
                    Settings.Default.UpdateRequired = false;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                MainWindow.SetDefaultSettings();

                Plugin.LoadPlugins();

                //only do it when there are args
                if (args.Length > 0)
                {
                    NativeMethods.InitConsoleHandles();
                }

                CommandOptions options = new CommandOptions();

                bool bOk = options.Parse(args);

                if (!bOk || options.help)
                {
                    string allFormats = string.Empty;

                    foreach (ExporterInfo info in Plugin.Exporters)
                    {
                        if (!string.IsNullOrEmpty(allFormats))
                        {
                            allFormats += "|";
                        }

                        allFormats += info.ID;
                    }

                    string usage = string.Format
                                       (@"
                                    Usage:
                                    BehaviacDesigner.exe <workspaceFile> <options>
                                    options:
                                    /bt=btFile
                                    /export=<{0}>
                                    /help", allFormats);

                    System.Console.WriteLine(usage);
                }

                if (options.export)
                {
                    if (bOk)
                    {
                        string msg = string.Format("Exporting: format '{0}' workspace '{1}' ...", options.format, options.workspace);
                        System.Console.WriteLine(msg);

                        if (!System.IO.File.Exists(options.workspace))
                        {
                            msg = string.Format("Workspace '{0}' does not exist! check the workspace path and name.", options.workspace);
                            System.Console.WriteLine(msg);

                            return;
                        }

                        try
                        {
                            new MainWindow(false);

                            MainWindow.Instance.Hide();

                            if (MainWindow.Instance.SetWorkspace(options.workspace, false))
                            {
                                MainWindow.Instance.ExportBehavior(true, options.format);
                            }
                            else
                            {
                                //msg = string.Format("Workspace '{0}' is not a valid workspace file!", options.workspace);
                                //System.Console.WriteLine(msg);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(options.workspace))
                        {
                            System.Console.WriteLine("No workspace is specified!");
                        }

                        if (string.IsNullOrEmpty(options.format))
                        {
                            System.Console.WriteLine("No format is specified!");
                        }
                    }

                    return;
                }

                using (MainWindow mainWindow = new MainWindow(true))
                {
                    if (!string.IsNullOrEmpty(options.workspace))
                    {
                        mainWindow.SetWorkspace(options.workspace, false);

                        if (!string.IsNullOrEmpty(options.bt))
                        {
                            UIUtilities.ShowBehaviorTree(options.bt);
                        }
                    }

                    Application.Run(mainWindow);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception is {0}", e);
            }
        }