public BehaviorTreeEditorWindow() { hideFlags = HideFlags.DontSave; _Instance = this; base.titleContent = new GUIContent("BehaviorTree"); base.position = new Rect((Screen.width - Size.x) / 2.0f, (Screen.height - Size.y) / 2.0f, Size.x, Size.y); base.minSize = MinSize; CreateUI(); }
public StateEditor(BehaviorTreeEditorWindow editor) { this._Editor = editor; this.RowDefinitions.Add(20, GridUnitType.Pixel); this.RowDefinitions.Add(1, GridUnitType.Star); this.ColumnDefinitions.Add(1, GridUnitType.Star); this.ColumnDefinitions.Add(90, GridUnitType.Pixel); _StateLabel = new Label() { Row = 0, Column = 0, Text = "States" }; this.Controls.Add(_StateLabel); _StateList = new ListBox() { Row = 1, Column = 0, ColumnSpan = 2 }; _StateList.DisableFocusable(); this.Controls.Add(_StateList); _StateToolbar = new UniformGrid() { Row = 0, Column = 1, Rows = 1, Columns = 3 }; this.Controls.Add(_StateToolbar); _BtnAddState = new Button() { Column = 1 }; _BtnAddState.Content.tooltip = "add new state"; _StateToolbar.Controls.Add(_BtnAddState); _BtnRemoveState = new Button() { Column = 2 }; _BtnRemoveState.Content.tooltip = "remove selected state"; _StateToolbar.Controls.Add(_BtnRemoveState); _BtnSetAsDefaultState = new Button() { Column = 0 }; _BtnSetAsDefaultState.Content.tooltip = "make selected state as default state"; _StateToolbar.Controls.Add(_BtnSetAsDefaultState); SetButtonsEnable(); _StateList.SelectionChanged += _StateList_SelectionChanged; _BtnAddState.Click += _BtnAddState_Click; _BtnRemoveState.Click += _BtnRemoveState_Click; _BtnSetAsDefaultState.Click += _BtnSetAsDefaultState_Click; }
public BehaviorList(BehaviorTreeEditorWindow editor) { this._Editor = editor; this.RowDefinitions.Add(20, GridUnitType.Pixel); this.RowDefinitions.Add(1, GridUnitType.Star); this.ColumnDefinitions.Add(400, GridUnitType.Pixel); this.ColumnDefinitions.Add(1, GridUnitType.Star); _ListViewToolbarBg = new Box() { Row = 0, Column = 1 }; this.Controls.Add(_ListViewToolbarBg); _BehaviorTabs = new Toolbar() { Row = 0, Column = 0 }; this.Controls.Add(_BehaviorTabs); _BtnActions = new ToolbarButton(); _BtnActions.Content.text = "Actions"; _BehaviorTabs.Items.Add(_BtnActions); _BtnConditions = new ToolbarButton(); _BtnConditions.Content.text = "Conditions"; _BehaviorTabs.Items.Add(_BtnConditions); _BtnDecorators = new ToolbarButton(); _BtnDecorators.Content.text = "Decorators"; _BehaviorTabs.Items.Add(_BtnDecorators); _BtnComposites = new ToolbarButton(); _BtnComposites.Content.text = "Composites"; _BehaviorTabs.Items.Add(_BtnComposites); _LbItems = new Framework.UI.ListBox() { Row = 1, Column = 0, ColumnSpan = 2, BackgroundVisible = true }; _LbItems.DisableFocusable(); this.Controls.Add(_LbItems); _BehaviorTabs.SelectedIndex = 0; _BtnActions.Selected += TabChanged; _BtnConditions.Selected += TabChanged; _BtnDecorators.Selected += TabChanged; _BtnComposites.Selected += TabChanged; _LbItems.SelectionChanged += _LbItems_SelectionChanged; }
void OnDestroy() { if (_States != null) { _States.DeselectInspector(); } if (_TreeViewEditor != null) { _TreeViewEditor.DeselectInspector(); } if (_BehaviorList != null) { _BehaviorList.DeselectInspector(); } _Instance = null; }
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; }