Esempio n. 1
0
        private void setParName(TextBox nameTextBox)
        {
            int    rowIndex = getRowIndex(null, nameTextBox, null, null, null);
            string newName  = nameTextBox.Text.Trim();

            nameTextBox.Text = newName;
            if (!string.IsNullOrEmpty(newName) && _rootNode.Pars[rowIndex].Name != newName)
            {
                UndoManager.PreSave();

                Plugin.ResetPar(_rootNode, _rootNode.Pars[rowIndex], newName);
                _rootNode.Pars[rowIndex].Name = newName;

                PropertiesDock.UpdatePropertyGrids();
                _rootNode.OnPropertyValueChanged(true);

                UndoManager.Save((Nodes.Behavior)_rootNode);

                UndoManager.PostSave();

                BehaviorTreeView behaviorTreeView = BehaviorTreeViewDock.LastFocused.BehaviorTreeView;
                if (behaviorTreeView != null)
                {
                    behaviorTreeView.Redraw();
                }
            }
        }
Esempio n. 2
0
        private void editSelectedPar(int rowIndex)
        {
            if (rowIndex < 0 || _rootNode == null)
            {
                return;
            }

            ParInfo par = _rootNode.Pars[rowIndex];

            List <Node.ErrorCheck> result = new List <Node.ErrorCheck>();

            Plugin.CheckPar(_rootNode, par, ref result);

            using (ParSettingsDialog parSettingsDialog = new ParSettingsDialog())
            {
                par.ParameterSet -= parameter_ParameterSet;
                parSettingsDialog.SetPar(par, _rootNode, false);

                Type   preType = par.Type;
                string preName = par.Name;

                if (DialogResult.OK == parSettingsDialog.ShowDialog())
                {
                    UndoManager.PreSave();

                    ParInfo curPar  = parSettingsDialog.GetPar();
                    Type    curType = curPar.Type;
                    string  curName = curPar.Name;

                    if (preType != curType)
                    {
                        // If this par is used by others
                        if (result.Count > 0)
                        {
                            string info = string.Format("Par {0} is used in some nodes. Are you sure change its type?", preName);
                            if (DialogResult.Cancel == MessageBox.Show(info, "Warning", MessageBoxButtons.OKCancel))
                            {
                                par.ParameterSet += parameter_ParameterSet;
                                return;
                            }
                        }

                        Plugin.ResetPar(_rootNode, par, string.Empty);
                    }
                    else if (preName != curName)
                    {
                        Plugin.ResetPar(_rootNode, par, curName);
                    }

                    par.Copy(curPar);

                    if (preType != curType)
                    {
                        RowControl rowControl = _rowControls[rowIndex];
                        rowControl.DefaultValueEditor = createValueEditor(rowIndex, curType);
                    }

                    par.ParameterSet += parameter_ParameterSet;
                    par.OnValueChanged();

                    PropertiesDock.UpdatePropertyGrids();
                    _rootNode.OnPropertyValueChanged(true);

                    UndoManager.Save((Nodes.Behavior)_rootNode);

                    UndoManager.PostSave();

                    BehaviorTreeView behaviorTreeView = BehaviorTreeViewDock.LastFocused.BehaviorTreeView;
                    if (behaviorTreeView != null)
                    {
                        behaviorTreeView.Redraw();
                    }
                }
                else
                {
                    par.ParameterSet += parameter_ParameterSet;
                }
            }
        }