Example #1
0
        /// <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);
        }
Example #2
0
        protected override void OnClosed(EventArgs e)
        {
            _dock = null;

            FrameStatePool.AddLogHandler -= FrameStatePool_AddLogHandler;

            base.OnClosed(e);
        }
Example #3
0
        internal static void Inspect() {
            if (_dock == null) {
                _dock = new ErrorInfoDock();
                _dock.Show(MainWindow.Instance.DockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockBottom);

            } else {
                _dock.Show();
            }
        }
Example #4
0
        public ErrorInfoDock()
        {
            if (_dock == null)
                _dock = this;

            InitializeComponent();

            this.TabText = Resources.ErrorList;

            FrameStatePool.AddLogHandler += FrameStatePool_AddLogHandler;
        }
        private static void checkBehaviorFiles(string behaviorFilename)
        {
            if (_checkedBehaviorFiles.ContainsKey(behaviorFilename))
            {
                return;
            }

            _checkedBehaviorFiles[behaviorFilename] = true;

            try
            {
                string sourceFilename   = Path.Combine(Workspace.Current.SourceFolder, behaviorFilename);
                string exportedFilename = Path.Combine(Workspace.Current.DefaultExportFolder, behaviorFilename);

                //remove the extension
                int pos = exportedFilename.IndexOf(".xml");

                if (pos != -1)
                {
                    exportedFilename = exportedFilename.Remove(pos);
                }

                exportedFilename += string.Format(".{0}", ms_fileFormat);

                if (File.Exists(sourceFilename) && File.Exists(exportedFilename))
                {
                    FileInfo sourceFileInfo   = new FileInfo(sourceFilename);
                    FileInfo exportedFileInfo = new FileInfo(exportedFilename);

                    //src file is modified after begin exported?
                    if (sourceFileInfo.LastWriteTime.CompareTo(exportedFileInfo.LastWriteTime) > 0)
                    {
                        string info = string.Format(Resources.FileModifiedInfo, behaviorFilename);
                        MessageBox.Show(info, Resources.FileModified, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    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);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #6
0
 internal static void Inspect()
 {
     if (_dock == null)
     {
         _dock = new ErrorInfoDock();
         _dock.Show(MainWindow.Instance.DockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockBottom);
     }
     else
     {
         _dock.Show();
     }
 }
Example #7
0
        public static void WriteExportTypeInfo()
        {
            string exportPath = Workspace.Current.GetExportAbsoluteFolder(Workspace.Current.Language);

            exportPath = Path.Combine(exportPath, "behaviac_generated/types");
            exportPath = Path.GetFullPath(exportPath);

            string msg = string.Format(Resources.ExportMessages, exportPath);

            ErrorInfoDock.Inspect();
            ErrorInfoDock.WriteLineWithTime(msg);
        }
Example #8
0
        public ErrorInfoDock()
        {
            if (_dock == null)
            {
                _dock = this;
            }

            InitializeComponent();

            this.TabText = Resources.ErrorList;

            FrameStatePool.AddLogHandler += FrameStatePool_AddLogHandler;
        }
Example #9
0
        protected override void OnClosed(EventArgs e)
        {
            _dock = null;

            FrameStatePool.AddLogHandler -= FrameStatePool_AddLogHandler;

            base.OnClosed(e);
        }
Example #10
0
        private static void processWorkspace(string msg)
        {
            if (!ms_workspace_handled && Plugin.WorkspaceDelegateHandler != null)
            {
                string str_   = msg.Substring(11);
                string format = "";

                //skip the space
                int pos = 1;

                for (; pos < str_.Length; ++pos)
                {
                    format += str_[pos];

                    if (str_[pos] == ' ')
                    {
                        break;
                    }
                }

                ms_fileFormat = format.Trim();

                Debug.Check(ms_fileFormat == "xml" || ms_fileFormat == "bson");

                //skip the space
                string str = str_.Substring(pos + 1);

                if (!string.IsNullOrEmpty(str))
                {
                    string wksName = string.Empty;

                    if (str[0] == '\"')
                    {
                        for (int i = 1; i < str.Length; ++i)
                        {
                            if (str[i] == '\"')
                            {
                                wksName = str.Substring(1, i - 1);
                                break;
                            }
                        }
                    }
                    else
                    {
                        string[] tokens = str.Split(' ');
                        wksName = tokens[0].Trim(new char[] { ' ', '\"' });
                    }

                    if (!string.IsNullOrEmpty(wksName))
                    {
                        wksName = Path.GetFullPath(wksName);

                        if (!File.Exists(wksName))
                        {
                            try
                            {
                                string errorInfo = string.Format(Resources.WorkspaceDebugErrorInfo, wksName);

                                ErrorInfoDock.Inspect();
                                ErrorInfoDock.WriteLine(errorInfo);

                                //MessageBox.Show(errorInfo, Resources.WorkspaceError, MessageBoxButtons.OK);
                            }
                            catch
                            {
                            }

                            if (Workspace.Current != null)
                            {
                                wksName = Workspace.Current.FileName;
                                if (!string.IsNullOrEmpty(wksName))
                                {
                                    wksName = Path.GetFullPath(wksName);
                                }
                            }
                        }

                        ms_workspace_handled = true;
                        Plugin.WorkspaceDelegateHandler(wksName, false);
                        ms_workspace_handled = false;
                    }

                    AgentDataPool.TotalFrames = 0;
                }
            }
        }