UNPKG

owl-bt

Version:

owl-bt is editor for Behavior trees. It has been inspired by Unreal engine behavior trees in a way, that it supports special node items like decorators and services. This makes trees smaller and much more readable.

45 lines (36 loc) 1.28 kB
'use strict'; (function() { class CommandContextMenu { constructor(_, $q, CommandContextMenuCfg, CommandPalette, ContextMenu) { this._ = _; this._ContextMenu = ContextMenu; this._CommandPalette = CommandPalette; this._menuItems = CommandContextMenuCfg.menuItems.map(menuItemDesc => { let command = CommandPalette.getCommand(menuItemDesc.command); if (!command) { throw new Error(`Missing command ${menuItemDesc.command}`); } return { title: menuItemDesc.title || command.name, icon: menuItemDesc.icon || command.icon, order: menuItemDesc.order || 0, command: menuItemDesc.command, hotkey: command.hotkeyStr, action: () => $q.when(CommandPalette.exec(menuItemDesc.command)) }; }); this._menuItems = _.sortBy(this._menuItems, 'order'); } show(scope, event) { return this._ContextMenu.show(scope, event, this._getMenuItems()); } hide() { this._ContextMenu.hide(); } _getMenuItems() { return this._menuItems.filter(menuItem => this._CommandPalette.canExec(menuItem.command)); } } angular.module('editorApp') .service('CommandContextMenu', CommandContextMenu); })();