Ejemplo n.º 1
0
            public TrackGroupContextMenu(TrackTreeView view)
            {
                _View = view;

                Skill.Editor.UI.MenuItem newTrack = new Skill.Editor.UI.MenuItem("New Track");
                var names  = System.Enum.GetNames(typeof(TrackType));
                var values = System.Enum.GetValues(typeof(TrackType));
                int index  = 0;

                foreach (var value in values)
                {
                    Skill.Editor.UI.MenuItem item = new Skill.Editor.UI.MenuItem(names[index])
                    {
                        UserData = value
                    };
                    item.Click += AddTrack_Click;
                    newTrack.Add(item);
                    index++;
                }


                Skill.Editor.UI.MenuItem addGroup = new Skill.Editor.UI.MenuItem("Add New Group");
                addGroup.Click += TrackGroupAdd_Click;

                Skill.Editor.UI.MenuItem deleteItem = new Skill.Editor.UI.MenuItem("Delete");
                deleteItem.Click += TrackGroupDelete_Click;

                Skill.Editor.UI.MenuItem propertiesItem = new Skill.Editor.UI.MenuItem("Properties");
                propertiesItem.Click += TrackGroupProperties_Click;

                Add(newTrack);
                AddSeparator();
                Add(addGroup);
                Add(deleteItem);
                AddSeparator();
                Add(propertiesItem);
            }
Ejemplo n.º 2
0
        public TreeViewEditor(BehaviorTreeEditorWindow editor)
        {
            this._Editor = editor;
            this.RowDefinitions.Add(20, GridUnitType.Pixel);
            this.RowDefinitions.Add(1, GridUnitType.Star);
            this.ColumnDefinitions.Add(70, GridUnitType.Pixel);
            this.ColumnDefinitions.Add(90, GridUnitType.Pixel);
            this.ColumnDefinitions.Add(1, GridUnitType.Star);

            _TreeView = new Skill.Editor.UI.TreeView()
            {
                Row = 1, Column = 0, ColumnSpan = 4
            };
            _TreeView.DisableFocusable();
            _TreeView.Background.Visibility = Visibility.Visible;
            this.Controls.Add(_TreeView);

            _TreeViewMenuBar = new Skill.Editor.UI.MenuBar()
            {
                Row = 0, Column = 0
            };
            this.Controls.Add(_TreeViewMenuBar);

            #region Add menu
            _AddBehaviorMenuItem = new MenuBarItem();
            _TreeViewMenuBar.Controls.Add(_AddBehaviorMenuItem);

            _AddAction = new Skill.Editor.UI.MenuItem("Action")
            {
                UserData = Skill.Framework.AI.BehaviorType.Action
            };
            _AddAction.Click += AddMenuItem_Click;
            _AddBehaviorMenuItem.Add(_AddAction);

            _AddCondition = new Skill.Editor.UI.MenuItem("Condition")
            {
                UserData = Skill.Framework.AI.BehaviorType.Condition
            };
            _AddCondition.Click += AddMenuItem_Click;
            _AddBehaviorMenuItem.Add(_AddCondition);

            _AddDecorator = new Skill.Editor.UI.MenuItem("Decorator");
            _AddBehaviorMenuItem.Add(_AddDecorator);

            _AddDefaultDecorator = new Skill.Editor.UI.MenuItem("Default")
            {
                Tag = "Decorator", UserData = Skill.Framework.AI.DecoratorType.Default
            };
            _AddDefaultDecorator.Click += AddMenuItem_Click;
            _AddDecorator.Add(_AddDefaultDecorator);

            _AddAccessLimitDecorator = new Skill.Editor.UI.MenuItem("AccessLimit")
            {
                Tag = "Decorator", UserData = Skill.Framework.AI.DecoratorType.AccessLimit
            };
            _AddAccessLimitDecorator.Click += AddMenuItem_Click;
            _AddDecorator.Add(_AddAccessLimitDecorator);

            _AddComposite = new Skill.Editor.UI.MenuItem("Composite");
            _AddBehaviorMenuItem.Add(_AddComposite);

            _AddSequenceComposite = new Skill.Editor.UI.MenuItem("Sequence")
            {
                Tag = "Composite", UserData = Skill.Framework.AI.CompositeType.Sequence
            };
            _AddSequenceComposite.Click += AddMenuItem_Click;
            _AddComposite.Add(_AddSequenceComposite);

            _AddPriorityComposite = new Skill.Editor.UI.MenuItem("Priority")
            {
                Tag = "Composite", UserData = Skill.Framework.AI.CompositeType.Priority
            };
            _AddPriorityComposite.Click += AddMenuItem_Click;
            _AddComposite.Add(_AddPriorityComposite);

            _AddConcurrentComposite = new Skill.Editor.UI.MenuItem("Concurrent")
            {
                Tag = "Composite", UserData = Skill.Framework.AI.CompositeType.Concurrent
            };
            _AddConcurrentComposite.Click += AddMenuItem_Click;
            _AddComposite.Add(_AddConcurrentComposite);

            _AddRandomComposite = new Skill.Editor.UI.MenuItem("Random")
            {
                Tag = "Composite", UserData = Skill.Framework.AI.CompositeType.Random
            };
            _AddRandomComposite.Click += AddMenuItem_Click;
            _AddComposite.Add(_AddRandomComposite);

            _AddLoopComposite = new Skill.Editor.UI.MenuItem("Loop")
            {
                Tag = "Composite", UserData = Skill.Framework.AI.CompositeType.Loop
            };
            _AddLoopComposite.Click += AddMenuItem_Click;
            _AddComposite.Add(_AddLoopComposite);

            #endregion

            #region Insert menu
            _InsertBehaviorMenuItem = new Skill.Editor.UI.MenuBarItem();
            _TreeViewMenuBar.Controls.Add(_InsertBehaviorMenuItem);

            _InsertActions = new Skill.Editor.UI.MenuItem("Actions");
            _InsertBehaviorMenuItem.Add(_InsertActions);

            _InsertConditions = new Skill.Editor.UI.MenuItem("Conditions");
            _InsertBehaviorMenuItem.Add(_InsertConditions);

            _InsertDecorators = new Skill.Editor.UI.MenuItem("Decorators");
            _InsertBehaviorMenuItem.Add(_InsertDecorators);

            _InsertComposites = new Skill.Editor.UI.MenuItem("Composites");
            _InsertBehaviorMenuItem.Add(_InsertComposites);

            _InsertChangeStates = new Skill.Editor.UI.MenuItem("ChangeStates");
            _InsertBehaviorMenuItem.Add(_InsertChangeStates);

            #endregion

            _TreeViewToolbarBg = new Box()
            {
                Row = 0, Column = 2
            };
            this.Controls.Add(_TreeViewToolbarBg);

            _TreeViewToolbar = new StackPanel()
            {
                Row = 0, Column = 1, Orientation = Orientation.Horizontal
            };
            this.Controls.Add(_TreeViewToolbar);


            _BtnRemoveBehavior = new Button()
            {
                Width = 30
            };
            _TreeViewToolbar.Controls.Add(_BtnRemoveBehavior);

            _BtnMoveUp = new Button()
            {
                Width = 30
            };
            _TreeViewToolbar.Controls.Add(_BtnMoveUp);

            _BtnMoveDown = new Button()
            {
                Width = 30
            };
            _TreeViewToolbar.Controls.Add(_BtnMoveDown);

            CheckMenuAvailable();
            _TreeView.SelectedItemChanged += _TreeView_SelectedItemChanged;

            _BtnMoveUp.Click         += _BtnMoveUp_Click;
            _BtnMoveDown.Click       += _BtnMoveDown_Click;
            _BtnRemoveBehavior.Click += _BtnRemoveBehavior_Click;
        }
Ejemplo n.º 3
0
        private void ApplyInsertChanges()
        {
            if (_BehaviorsChanged)
            {
                _BehaviorsChanged = false;
                BehaviorData[] behaviors = _Editor.GetBehaviors();

                _InsertActions.Clear();
                _InsertConditions.Clear();
                _InsertDecorators.Clear();
                _InsertComposites.Clear();
                _InsertChangeStates.Clear();

                foreach (var b in behaviors)
                {
                    switch (b.BehaviorType)
                    {
                    case Skill.Framework.AI.BehaviorType.Action:
                        Skill.Editor.UI.MenuItem actionItem = new Skill.Editor.UI.MenuItem(b.Name)
                        {
                            UserData = b, Image = b.GetIcon()
                        };
                        _InsertActions.Add(actionItem);
                        actionItem.Click += InsertMenuItem_Click;
                        break;

                    case Skill.Framework.AI.BehaviorType.Condition:
                        Skill.Editor.UI.MenuItem conditionItem = new Skill.Editor.UI.MenuItem(b.Name)
                        {
                            UserData = b, Image = b.GetIcon()
                        };
                        _InsertConditions.Add(conditionItem);
                        conditionItem.Click += InsertMenuItem_Click;
                        break;

                    case Skill.Framework.AI.BehaviorType.Decorator:
                        Skill.Editor.UI.MenuItem decoratorItem = new Skill.Editor.UI.MenuItem(b.Name)
                        {
                            UserData = b, Image = b.GetIcon()
                        };
                        _InsertDecorators.Add(decoratorItem);
                        decoratorItem.Click += InsertMenuItem_Click;
                        break;

                    case Skill.Framework.AI.BehaviorType.Composite:
                        Skill.Editor.UI.MenuItem compositeItem = new Skill.Editor.UI.MenuItem(b.Name)
                        {
                            UserData = b, Image = b.GetIcon()
                        };
                        _InsertComposites.Add(compositeItem);
                        compositeItem.Click += InsertMenuItem_Click;
                        break;

                    case Skill.Framework.AI.BehaviorType.ChangeState:
                        Skill.Editor.UI.MenuItem changeStateItem = new Skill.Editor.UI.MenuItem(b.Name)
                        {
                            UserData = b, Image = b.GetIcon()
                        };
                        _InsertChangeStates.Add(changeStateItem);
                        changeStateItem.Click += InsertMenuItem_Click;
                        break;

                    default:
                        break;
                    }
                }
            }
        }