Beispiel #1
0
            private ContinuousTrackBarContextMenu()
            {
                _AddKeyXItem   = new Skill.Editor.UI.MenuItem("Add key X");
                _AddKeyYItem   = new Skill.Editor.UI.MenuItem("Add key Y");
                _AddKeyZItem   = new Skill.Editor.UI.MenuItem("Add key Z");
                _AddKeyWItem   = new Skill.Editor.UI.MenuItem("Add key W");
                _AddKeyAllItem = new Skill.Editor.UI.MenuItem("Add key All");

                Add(_AddKeyXItem);
                Add(_AddKeyYItem);
                Add(_AddKeyZItem);
                Add(_AddKeyWItem);
                Add(_AddKeyAllItem);

                _AddKeyXItem.Click   += _AddKeyXItem_Click;
                _AddKeyYItem.Click   += _AddKeyYItem_Click;
                _AddKeyZItem.Click   += _AddKeyZItem_Click;
                _AddKeyWItem.Click   += _AddKeyWItem_Click;
                _AddKeyAllItem.Click += _AddKeyAllItem_Click;
            }
Beispiel #2
0
        private void CreateMenuBar()
        {
            _MenuBar = new Skill.Editor.UI.MenuBar()
            {
                Dock = Skill.Framework.UI.Dock.Top
            };

            MenuBarItem file = new MenuBarItem()
            {
                Title = "File"
            };
            MenuBarItem edit = new MenuBarItem()
            {
                Title = "Edit"
            };
            MenuBarItem view = new MenuBarItem()
            {
                Title = "View"
            };
            MenuBarItem window = new MenuBarItem()
            {
                Title = "Window", Width = 54
            };

            _ItmSceneMatinee = new UI.MenuItem("Matinees");
            file.Add(_ItmSceneMatinee);

            _MenuBar.Controls.Add(file);
            _MenuBar.Controls.Add(edit);
            _MenuBar.Controls.Add(view);
            _MenuBar.Controls.Add(window);


            Skill.Editor.UI.MenuItem resetLayout = new Skill.Editor.UI.MenuItem("Reset Layout");
            window.Add(resetLayout);
            resetLayout.Click += resetLayout_Click;

            _ItmRollBack = new Skill.Editor.UI.MenuItem("Rollback");
            edit.Add(_ItmRollBack);
            _ItmRollBack.Click += mnuRollback_Click;
        }
Beispiel #3
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);
            }
Beispiel #4
0
            private EventTrackBarContextMenu()
            {
                // find all event class
                List <EventInfo> events = new List <EventInfo>();

                Type baseType = typeof(EventKey);

                foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (Type objType in assembly.GetTypes())
                    {
                        if ((objType.IsPublic && ((objType.Attributes & System.Reflection.TypeAttributes.Abstract) != System.Reflection.TypeAttributes.Abstract)) &&
                            objType.IsSubclassOf(baseType))
                        {
                            object[] customEventAttributes = objType.GetCustomAttributes(typeof(CustomEventAttribute), true);
                            if (customEventAttributes != null && customEventAttributes.Length > 0)
                            {
                                CustomEventAttribute att = (CustomEventAttribute)customEventAttributes[0];

                                EventInfo info = new EventInfo();
                                info.DisplayName = att.DisplayName;
                                info.Path        = string.IsNullOrEmpty(att.Path) ? "Custom" : att.Path.Trim(' ', '/', '\\', ',', '.').Replace('\\', '/');
                                info.Type        = objType;
                                info.Assembly    = assembly;

                                events.Add(info);
                            }
                        }
                    }
                }

                List <MenuItemData> itemList = new List <MenuItemData>();

                foreach (var e in events)
                {
                    Skill.Editor.UI.MenuItem pathItem = FindItem(itemList, e.Path);
                    if (pathItem == null)
                    {
                        string[] pathParts = e.Path.Split('/');
                        if (pathParts == null || pathParts.Length == 0)
                        {
                            pathParts = new string[] { "Custom" }
                        }
                        ;

                        string path = string.Empty;
                        Skill.Editor.UI.MenuItemBase parentItem = this;
                        for (int i = 0; i < pathParts.Length; i++)
                        {
                            path    += pathParts[i];
                            pathItem = FindItem(itemList, path);

                            if (pathItem == null)
                            {
                                pathItem = new UI.MenuItem(pathParts[i]);
                                itemList.Add(new MenuItemData()
                                {
                                    Path = path, Item = pathItem
                                });
                                parentItem.Add(pathItem);
                            }

                            parentItem = pathItem;
                            path      += "/";
                        }
                    }

                    if (pathItem != null)
                    {
                        Skill.Editor.UI.MenuItem addItem = new UI.MenuItem(e.DisplayName)
                        {
                            UserData = e
                        };
                        addItem.Click += addItem_Click;
                        pathItem.Add(addItem);
                    }
                }
            }
Beispiel #5
0
        public AudioClipSubtitleEditor(DictionaryEditorWindow editor)
        {
            this.Editor = editor;
            GameObject obj = UnityEditor.EditorUtility.CreateGameObjectWithHideFlags("AudioPreview", HideFlags.HideAndDontSave | HideFlags.HideInHierarchy,
                                                                                     new System.Type[] { typeof(AudioSource) });

            _Audio = obj.GetComponent <AudioSource>();

            _Events = new List <SubtitleEvent>();

            RowDefinitions.Add(16, GridUnitType.Pixel);
            RowDefinitions.Add(26, GridUnitType.Pixel);
            RowDefinitions.Add(140, GridUnitType.Pixel);
            RowDefinitions.Add(80, GridUnitType.Pixel);
            RowDefinitions.Add(1, GridUnitType.Star);

            _TimeLine = new TimeLine(new TrackBarView())
            {
                Row = 1, Column = 0, RowSpan = 3, SelectionEnable = false, ExtendTime = false
            };
            _TimeLine.MaxTime = 1;

            _ToolbarBg = new Box()
            {
                Row = 0, Column = 0, Margin = new Thickness(0, 0, 16, 0)
            };
            _BtnPlay = new MediaButton()
            {
                Row = 0, Column = 0, Width = 28, HorizontalAlignment = Skill.Framework.UI.HorizontalAlignment.Left, TogglePressed = false, Margin = new Thickness(4, 0, 0, 0)
            };
            _BtnPlay.Content.tooltip = "Start preview playback from current position";

            _AudioPreview = new AudioPreviewCurve()
            {
                Row = 2, Margin = new Thickness(0, 0, 16, 0)
            };
            _AudioTrack = new TrackBar()
            {
                Height = 138
            };
            _SubtitleTrack = new SubtitleTrackBar(this)
            {
                Height = 60
            };
            _TimeLine.View.Controls.Add(_AudioTrack);
            _TimeLine.View.Controls.Add(_SubtitleTrack);

            this.Controls.Add(_ToolbarBg);
            this.Controls.Add(_BtnPlay);
            this.Controls.Add(_AudioPreview);
            this.Controls.Add(_TimeLine);


            // ************** ContextMenu **************
            _SubtitleTrackContextMenu = new Skill.Editor.UI.ContextMenu();
            Skill.Editor.UI.MenuItem addSubtitle = new Skill.Editor.UI.MenuItem("Add");

            _SubtitleTrackContextMenu.Add(addSubtitle);
            _SubtitleTrack.ContextMenu = _SubtitleTrackContextMenu;

            _SubtitleEventContextMenu = new Skill.Editor.UI.ContextMenu();
            Skill.Editor.UI.MenuItem deleteItem = new Skill.Editor.UI.MenuItem("Delete");
            _SubtitleEventContextMenu.Add(deleteItem);

            Subtitle = null;

            addSubtitle.Click           += AddSubtitle_Click;
            deleteItem.Click            += DeleteSubtitle_Click;
            _BtnPlay.Click              += _BtnPlay_Click;
            _TimeLine.TimeBar.MouseDown += Timebar_MouseDown;
        }
Beispiel #6
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;
        }
Beispiel #7
0
        void AddMenuItem_Click(object sender, System.EventArgs e)
        {
            if (_TreeView.SelectedItem == null)
            {
                return;
            }
            if (!(_TreeView.SelectedItem is TreeViewFolder))
            {
                return;
            }


            Skill.Editor.UI.MenuItem item     = (Skill.Editor.UI.MenuItem)sender;
            BehaviorData             behavior = null;

            if (string.IsNullOrEmpty(item.Tag))
            {
                Skill.Framework.AI.BehaviorType type = (Framework.AI.BehaviorType)item.UserData;
                switch (type)
                {
                case Skill.Framework.AI.BehaviorType.Action:
                    behavior = new ActionData()
                    {
                        Name = _Editor.GetUniqueName("NewAction")
                    };
                    break;

                case Skill.Framework.AI.BehaviorType.Condition:
                    behavior = new ConditionData()
                    {
                        Name = _Editor.GetUniqueName("NewCondition")
                    };
                    break;

                default:
                    behavior = null;
                    break;
                }
            }
            else if (item.Tag == "Decorator")
            {
                Skill.Framework.AI.DecoratorType type = (Framework.AI.DecoratorType)item.UserData;
                switch (type)
                {
                case Skill.Framework.AI.DecoratorType.Default:
                    behavior = new DecoratorData()
                    {
                        Name = _Editor.GetUniqueName("NewDecorator")
                    };
                    break;

                case Skill.Framework.AI.DecoratorType.AccessLimit:
                    behavior = new AccessLimitDecoratorData()
                    {
                        Name = _Editor.GetUniqueName("NewAccessDecorator")
                    };
                    break;

                default:
                    behavior = null;
                    break;
                }
            }
            else if (item.Tag == "Composite")
            {
                Skill.Framework.AI.CompositeType type = (Framework.AI.CompositeType)item.UserData;
                switch (type)
                {
                case Skill.Framework.AI.CompositeType.Sequence:
                    behavior = new SequenceSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewSequence")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Concurrent:
                    behavior = new ConcurrentSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewConcurrent")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Random:
                    behavior = new RandomSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewRandom")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Priority:
                    behavior = new PrioritySelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewPriority")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Loop:
                    behavior = new LoopSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewLoop")
                    };
                    break;

                default:
                    behavior = null;
                    break;
                }
            }

            if (behavior != null)
            {
                TreeViewFolder tvf = (TreeViewFolder)_TreeView.SelectedItem;
                tvf.Foldout.IsOpen = true;
                tvf.AddBehavior(behavior);
                _Editor.AddToList(behavior);
                _Editor.RefreshTree();
                SelectItem(tvf, behavior);
            }
        }
Beispiel #8
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;
                    }
                }
            }
        }
Beispiel #9
0
 private AudioConnectionContextMenu()
 {
     _MnuBreak        = new Skill.Editor.UI.MenuItem("Break");
     _MnuBreak.Click += _MnuBreak_Click;
     this.Add(_MnuBreak);
 }