Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
        /// <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))
            {
                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(BehaviorTreeViewDock.GetBehaviorTreeView(behavior));
        }
Exemplo n.º 3
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            bool themeChanged              = (Settings.Default.ColorTheme != themeComboBox.SelectedIndex);
            bool basicDisplayNameChanged   = (Settings.Default.UseBasicDisplayName != useBasicDisplayNameCheckBox.Checked);
            bool showVersionChanged        = (Settings.Default.ShowVersionInfo != showVersionCheckBox.Checked);
            bool limitDisplayLengthChanged = (Settings.Default.IsDisplayLengthLimited != limitDisplayLengthCheckBox.Checked) ||
                                             (Settings.Default.LimitedDisplayLength != (int)displayLengthNumericUpDown.Value);
            bool languageChanged = (Settings.Default.Language != languageComboBox.SelectedIndex);

            Settings.Default.Language                   = languageComboBox.SelectedIndex;
            Settings.Default.ColorTheme                 = themeComboBox.SelectedIndex;
            Settings.Default.ShowNodeToolTips           = nodeToolTipsCheckBox.Checked;
            Settings.Default.ShowControlsOnStartUp      = showControlsCheckBox.Checked;
            Settings.Default.CheckLatestVersion         = checkBoxChecktheLatest.Checked;
            Settings.Default.DumpConnectData            = dumpConnectDataCheckBox.Checked;
            Settings.Default.ShowVersionInfo            = showVersionCheckBox.Checked;
            Settings.Default.UseBasicDisplayName        = useBasicDisplayNameCheckBox.Checked;
            Settings.Default.NoResultTreatAsError       = checkBoxTweatAsError.Checked;
            Settings.Default.IsDisplayLengthLimited     = limitDisplayLengthCheckBox.Checked;
            Settings.Default.LimitedDisplayLength       = (int)displayLengthNumericUpDown.Value;
            Settings.Default.ConcurrentProcessBehaviors = concurrentProcessBehaviorsCheckBox.Checked;

            Nodes.Node.ColorTheme = (Nodes.Node.ColorThemes)Settings.Default.ColorTheme;
            Behaviac.Design.Nodes.Action.NoResultTreatAsError = Settings.Default.NoResultTreatAsError;

            if (Settings.Default.ShowProfilingInfo != showProfileCheckBox.Checked)
            {
                Settings.Default.ShowProfilingInfo = showProfileCheckBox.Checked;
                Network.NetworkManager.Instance.SendProfiling(Settings.Default.ShowProfilingInfo);
            }

            Plugin.UseBasicDisplayName = Settings.Default.UseBasicDisplayName;
            //Plugin.ConcurrentProcessBehaviors = Settings.Default.ConcurrentProcessBehaviors;

            NodeViewData.ShowNodeId             = Settings.Default.ShowVersionInfo;
            NodeViewData.IsDisplayLengthLimited = Settings.Default.IsDisplayLengthLimited;
            NodeViewData.LimitedDisplayLength   = Settings.Default.LimitedDisplayLength;

            if (themeChanged || basicDisplayNameChanged || showVersionChanged || limitDisplayLengthChanged)
            {
                BehaviorTreeViewDock.RefreshAll();
                PropertiesDock.UpdatePropertyGrids();
            }

            if (languageChanged)
            {
                MessageBox.Show(Resources.LanguageChangedWarning, Resources.Warning, MessageBoxButtons.OK);
                //MainWindow.Instance.ReloadLayout();
            }

            Settings.Default.FastExportFileType.Clear();


            foreach (ListViewItem it in listView1.CheckedItems)
            {
                Settings.Default.FastExportFileType.Add(it.Text);
            }
        }
Exemplo n.º 4
0
        internal static void Inspect(BehaviorTreeViewDock dock) {
            if (_metaStoreDock == null) {
                _metaStoreDock = new MetaStoreDock();
                _metaStoreDock.Owner = MainWindow.Instance;
            }

            _metaStoreDock.initialize(dock);
            _metaStoreDock.Show();
        }
Exemplo n.º 5
0
        internal void MakeFocused()
        {
            if (__lastFocusedInstance != this)
            {
                __lastFocusedInstance = this;

                _behaviorTreeView.Redraw();
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        private void deleteBreakpoints(string[] behaviorFilenames, string[] nodeIds, DebugDataPool.Action[] actions)
        {
            Debug.Check(behaviorFilenames.Length == nodeIds.Length && nodeIds.Length == actions.Length);

            for (int i = 0; i < behaviorFilenames.Length; i++)
            {
                DebugDataPool.RemoveBreakPoint(behaviorFilenames[i], nodeIds[i], actions[i]);
            }

            BehaviorTreeViewDock.RefreshAll();
            Inspect();
        }
Exemplo n.º 8
0
        protected override void OnClosed(EventArgs e)
        {
            if (__lastFocusedInstance == this)
            {
                __lastFocusedInstance = null;
            }

            __instances.Remove(this);

            _behaviorTreeView.RootNode.WasSaved -= RootNode_WasSaved;

            base.OnClosed(e);
        }
Exemplo n.º 9
0
        internal static void CloseAll()
        {
            BehaviorTreeViewDock[] behaviorTreeViewDocks = __instances.ToArray();
            foreach (BehaviorTreeViewDock dock in behaviorTreeViewDocks)
            {
                __saved_bt_paths.Add(dock._behaviorTreeView.RootNode.RelativePath);
                dock.Hide();
                dock.Close();
            }

            __instances.Clear();
            __lastFocusedInstance = null;
        }
Exemplo n.º 10
0
        private void showButton_Click(object sender, EventArgs e)
        {
            HighlightBreakPoint.ShowBreakPoint = !HighlightBreakPoint.ShowBreakPoint;
            BehaviorTreeViewDock.RefreshAll();

            if (HighlightBreakPoint.ShowBreakPoint)
            {
                showButton.ToolTipText = Resources.BreakpointsHide;
            }
            else
            {
                showButton.ToolTipText = Resources.BreakpointsShow;
            }
        }
Exemplo n.º 11
0
        /// <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));
        }
Exemplo n.º 12
0
        private void updateValue()
        {
            if (this.update(_timelineDock.trackBar.Value))
            {
                this.setUpdateMode(UpdateModes.Break, this._break_prompt);
            }
            else
            {
                if (Plugin.EditMode == EditModes.Analyze)
                {
                    BehaviorTreeViewDock.ClearHighlightBreakPoint();
                    _timelineDock.promptLabel.Text = "";

                    _currentFrame = _timelineDock.trackBar.Value;
                }
            }
        }
Exemplo n.º 13
0
        private void updateValue()
        {
            _agenttype_index     = 0;
            _agentinstance_index = 0;

            if (this.update(_timelineDock.trackBar.Value))
            {
                this.setUpdateMode(UpdateModes.Break, this._break_prompt);
            }
            else
            {
                if (Plugin.EditMode == EditModes.Analyze)
                {
                    BehaviorTreeViewDock.ClearHighlightBreakPoint();
                    _timelineDock.promptLabel.Text = "";
                }
            }
        }
Exemplo n.º 14
0
        protected override void OnClosed(EventArgs e)
        {
            if (__lastFocusedInstance == this)
                __lastFocusedInstance = null;

            __instances.Remove(this);

            _behaviorTreeView.RootNode.WasSaved -= RootNode_WasSaved;

            base.OnClosed(e);
        }
Exemplo n.º 15
0
        private void initialize(BehaviorTreeViewDock dock)
        {
            _initialized = false;
            _dock = dock;

            this.Text = Resources.MetaStore;

            if (getCurrentBehaviorTreeDock() != null) {
                this.Text += " - " + getCurrentBehaviorTreeDock().Text;
            }

            this.typeListBox.Items.Clear();
            this.instanceComboBox.Items.Clear();
            this.memberTypeComboBox.Items.Clear();

            string selectedType = _lastSelectedType;

            if (string.IsNullOrEmpty(_lastSelectedType))
            {
                AgentType agentType = getCurrentViewAgentType();

                if (agentType == null)
                {
                    agentType = _lastAgent;
                }

                if (agentType != null)
                {
                    selectedType = agentType.AgentTypeName;
                }
            }

            resetAllTypes(selectedType);

            // set all member types
            foreach(string mt in Enum.GetNames(typeof(MemberType))) {
                this.memberTypeComboBox.Items.Add(mt);
            }

            this.memberTypeComboBox.SelectedIndex = _lastMemberTypeIndex;

            this.exportTypeTextBox.Text = Workspace.Current.GetExportAbsoluteFolder(Plugin.SourceLanguage);

            _initialized = true;
        }
Exemplo n.º 16
0
        protected override void OnClosed(EventArgs e) {
            if (__lastFocusedInstance == this) {
                __lastFocusedInstance = null;
            }

            __instances.Remove(this);

            if (_behaviorTreeView != null && _behaviorTreeView.RootNode != null) {
                _behaviorTreeView.RootNode.WasModified -= RootNode_WasModified;
                _behaviorTreeView.RootNode.WasSaved -= RootNode_WasSaved;
            }

            base.OnClosed(e);
        }
Exemplo n.º 17
0
        internal static void CloseAll()
        {
            BehaviorTreeViewDock[] behaviorTreeViewDocks = __instances.ToArray();
            foreach (BehaviorTreeViewDock dock in behaviorTreeViewDocks)
            {
                __saved_bt_paths.Add(dock._behaviorTreeView.RootNode.RelativePath);
                dock.Hide();
                dock.Close();
            }

            __instances.Clear();
            __lastFocusedInstance = null;
        }
Exemplo n.º 18
0
        internal void MakeFocused()
        {
            if (__lastFocusedInstance != this)
            {
                __lastFocusedInstance = this;

                _behaviorTreeView.Redraw();
            }
        }
Exemplo n.º 19
0
        public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename)
        {
            BehaviorNode behavior = ShowBehavior(behaviorFilename);

            return(BehaviorTreeViewDock.GetBehaviorTreeView(behavior));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Handles when a behaviour is supposed to be presented to the user.
        /// </summary>
        /// <param name="node">The behaviour which will be presented to the user.</param>
        private BehaviorTreeViewDock behaviorTreeList_ShowBehavior(BehaviorNode node)
        {
            // check if there is a tab for the behaviour
            BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDock(node);
            BehaviorTreeView control = (dock == null) ? null : dock.BehaviorTreeView;

            if (control == null)
            {
                control = new BehaviorTreeView();
                control.Dock = DockStyle.Fill;
                control.RootNode = node;
                control.BehaviorTreeList = behaviorTreeList;

                control.ClickNode += new BehaviorTreeView.ClickNodeEventDelegate(control_ClickNode);
                control.ClickEvent += new BehaviorTreeView.ClickEventEventDelegate(control_ClickEvent);

                dock = new BehaviorTreeViewDock();
                dock.Text = ((Node)node).Label;
                dock.TabText = ((Node)node).Label;
                dock.BehaviorTreeView = control;
                dock.Activated += new EventHandler(dock_Activated);
                dock.FormClosed += new FormClosedEventHandler(dock_FormClosed);
                dock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Document);

                dock.ToolTipText = FileManagers.FileManager.GetRelativePath(node.Filename);
            }

            dock.Focus();
            dock.MakeFocused();

            return dock;
        }
Exemplo n.º 21
0
        private void dock_Activated(object sender, EventArgs e) {
            BehaviorTreeViewDock dock = sender as BehaviorTreeViewDock;

            if (dock != null && _lastActivatedDock != dock) {
                if (_lastActivatedDock != null && _lastActivatedDock.BehaviorTreeView != null &&
                    _lastActivatedDock.BehaviorTreeView.RootNode != null &&
                    _lastActivatedDock.BehaviorTreeView.RootNode.AgentType != null) {
                    _lastActivatedDock.BehaviorTreeView.RootNode.AgentType.ClearPars();
                }

                _lastActivatedDock = dock;

                if (dock != null && dock.BehaviorTreeView != null &&
                    dock.BehaviorTreeView.RootNode != null &&
                    dock.BehaviorTreeView.RootNode.AgentType != null) {
                    dock.BehaviorTreeView.RootNode.AgentType.AddPars(((Behavior)dock.BehaviorTreeView.RootNode).LocalVars);
                }

                if (MetaStoreDock.IsVisible()) {
                    MetaStoreDock.Inspect(dock);
                }

                OnNodeClicked(dock.BehaviorTreeView.SelectedNode);

                dock.BehaviorTreeView.Focus();
            }
        }
Exemplo n.º 22
0
        private void dock_Activated(object sender, EventArgs e) {
            BehaviorTreeViewDock dock = sender as BehaviorTreeViewDock;

            if (dock != null && _lastActivatedDock != dock) {
                if (_lastActivatedDock != null && _lastActivatedDock.BehaviorTreeView != null &&
                    _lastActivatedDock.BehaviorTreeView.RootNode != null &&
                    _lastActivatedDock.BehaviorTreeView.RootNode.AgentType != null) {
                    _lastActivatedDock.BehaviorTreeView.RootNode.AgentType.ClearPars();
                }

                _lastActivatedDock = dock;

                if (dock != null && dock.BehaviorTreeView != null &&
                    dock.BehaviorTreeView.RootNode != null &&
                    dock.BehaviorTreeView.RootNode.AgentType != null) {
                    dock.BehaviorTreeView.RootNode.AgentType.AddPars(((Behavior)dock.BehaviorTreeView.RootNode).LocalVars);
                }

                if (Plugin.UpdateMetaStoreHandler != null)
                    Plugin.UpdateMetaStoreHandler(dock);

                OnNodeClicked(dock.BehaviorTreeView.SelectedNode);

                dock.BehaviorTreeView.Focus();
            }
        }
Exemplo n.º 23
0
        private void dock_Activated(object sender, EventArgs e)
        {
            if (ParSettingsDock.IsVisible())
            {
                BehaviorTreeViewDock dock = sender as BehaviorTreeViewDock;
                if (lastActivatedDock != dock)
                {
                    lastActivatedDock = dock;
                    ParSettingsDock.Inspect((Node)dock.BehaviorTreeView.RootNode);
                }

                dock.BehaviorTreeView.Focus();
            }

            if (MetaStoreDock.IsVisible())
            {
                MetaStoreDock.Inspect();
            }
        }
Exemplo n.º 24
0
        private void initialize(BehaviorTreeViewDock dock) {
            _initialized = false;
            _dock = dock;

            this.Text = Resources.MetaStore;

            if (getCurrentBehaviorTreeDock() != null) {
                this.Text += " - " + getCurrentBehaviorTreeDock().Text;
            }

            this.typeListBox.Items.Clear();
            this.instanceComboBox.Items.Clear();
            this.memberTypeComboBox.Items.Clear();

            AgentType agentType = getCurrentViewAgentType();

            if (agentType == null) {
                agentType = _lastAgent;
            }

            resetAllTypes(agentType != null ? agentType.AgentTypeName : "");

            // set all member types
            foreach(string mt in Enum.GetNames(typeof(MemberType))) {
                this.memberTypeComboBox.Items.Add(mt);
            }

            this.memberTypeComboBox.SelectedIndex = _lastMemberTypeIndex;

            _initialized = true;
        }