def createAsset(self, creator, instance=None): if isinstance(creator, str): creator = self.getAssetLibrary().getAssetCreator(creator) label = creator.getLabel() assetType = creator.getAssetType() instance = instance or self.browserInstance if instance.currentFolders: contextNode = instance.currentFolders[0] else: contextNode = None if not isinstance(contextNode, AssetNode): contextNode = app.getAssetLibrary().getRootNode() name = requestString('Create Asset <%s>' % assetType, 'Enter asset name: <%s>' % assetType) if not name: return try: finalPath = creator.createAsset(name, contextNode, assetType) self.newCreateNodePath = finalPath except Exception, e: logging.exception(e) alertMessage('Asset Creation Error', repr(e))
def createAsset( self, creator, instance = None ): if isinstance( creator, str ): creator = self.getAssetLibrary().getAssetCreator( creator ) label = creator.getLabel() assetType = creator.getAssetType() instance = instance or self.browserInstance if instance.currentFolders: contextNode = instance.currentFolders[0] else: contextNode = None if not isinstance( contextNode, AssetNode ): contextNode = app.getAssetLibrary().getRootNode() name = requestString('Create Asset <%s>' % assetType, 'Enter asset name: <%s>' % assetType ) if not name: return try: finalPath = creator.createAsset( name, contextNode, assetType ) self.newCreateNodePath=finalPath except Exception,e: logging.exception( e ) alertMessage( 'Asset Creation Error', repr(e) )
def onMenu(self, menuNode): name = menuNode.name if name == 'save_scheme': name = requestString('Save Window Scheme', 'Enter Scheme Name') if not name: return self.saveWindowSchemeToFile(name + WINDOW_SCHEME_EXTENSION) elif name == 'load_scheme': self.prompLoadScheme()
def createRemoteFile( self, instance = None ): name = requestString( 'Add Remote File', 'Target Filename:' ) if not name: return instance = instance or self.browserInstance if instance.currentFolders: contextNode = instance.currentFolders[0] else: contextNode = None if not isinstance( contextNode, AssetNode ): contextNode = app.getAssetLibrary().getRootNode() remoteFilePath = app.getAssetLibrary().createRemoteFile( contextNode, name ) if remoteFilePath: AssetUtils.showFileInBrowser( remoteFilePath )
def editAssetTags(self): target = None itemSelection = self.getItemSelection() if itemSelection: target = itemSelection[0] else: folders = self.getCurrentFolders() if folders: target = folders[0] if not target: return text = requestString('Tags', 'Enter Tags:', target.getTagString()) if text != None: target.setTagString(text) self.updateStatusBar()
def editAssetTags( self ): target = None itemSelection = self.getItemSelection() if itemSelection: target = itemSelection[0] else: folders = self.getCurrentFolders() if folders: target = folders[0] if not target: return text = requestString( 'Tags', 'Enter Tags:', target.getTagString() ) if text != None: target.setTagString( text ) self.updateStatusBar()
def onMenu(self, menu): name = menu.name if name == 'close_scene': if self.previewing: alertMessage('Warning', 'Stop previewing before closing scene') return self.closeScene() elif name == 'open_scene': if self.previewing: alertMessage('Warning', 'Stop previewing before opening scene') return requestSearchView(info='select scene to open', context='asset', type='scene', on_selection=self.openScene) elif name == 'save_scene': if self.previewing: alertMessage('Warning', 'Stop previewing before saving') return self.saveScene() elif name == 'locate_scene_asset': if self.activeSceneNode: assetBrowser = self.getModule('asset_browser') if assetBrowser: assetBrowser.selectAsset(self.activeSceneNode) elif name == 'add_entity': requestSearchView(info='select entity type to create', context='entity_creation', on_selection=lambda obj: self.doCommand( 'scene_editor/create_entity', name=obj)) elif name == 'add_component': requestSearchView(info='select component type to create', context='component_creation', on_selection=lambda obj: self.doCommand( 'scene_editor/create_component', name=obj)) elif name == 'add_empty_entity': self.doCommand('scene_editor/create_entity', name='Entity') elif name == 'load_prefab': requestSearchView(info='select a perfab node to instantiate', context='asset', type='prefab', on_selection=lambda obj: self.doCommand( 'scene_editor/create_prefab_entity', prefab=obj.getNodePath())) elif name == 'load_prefab_in_container': requestSearchView( info='select a perfab node to instantiate( PefabContainer )', context='asset', type='prefab', on_selection=lambda obj: self.doCommand( 'scene_editor/create_prefab_container', prefab=obj.getNodePath())) elif name == 'remove_entity': self.doCommand('scene_editor/remove_entity') elif name == 'clone_entity': self.doCommand('scene_editor/clone_entity') elif name == 'find_entity': requestSearchView( info='search for entity in current scene', context='scene', type='entity', on_selection=lambda x: self.selectEntity(x, focus_tree=True), on_test=self.selectEntity) elif name == 'find_entity_in_group': requestSearchView( info='search for entity in current entity group', context='scene', type='entity_in_group', on_selection=lambda x: self.selectEntity(x, focus_tree=True), on_test=self.selectEntity) elif name == 'find_entity_group': requestSearchView( info='search for group in current scene', context='scene', type='group', on_selection=lambda x: self.selectEntity(x, focus_tree=True), on_test=self.selectEntity) elif name == 'create_group': self.doCommand('scene_editor/entity_group_create') elif name == 'remove_component': context = menu.getContext() if context: self.doCommand('scene_editor/remove_component', target=context) elif name == 'copy_component': context = menu.getContext() if context: self.doCommand('scene_editor/copy_component', target=context) elif name == 'edit_component_alias': context = menu.getContext() if context: oldAlias = context._alias or '' alias = requestString('Edit Alias', 'Enter Alias:', oldAlias) if alias != None: if not alias: alias = False self.doCommand('scene_editor/rename_component', target=context, alias=alias) elif name == 'assign_layer': if not self.tree.getSelection(): return requestSearchView(info='select layer to assign', context='scene_layer', type=_MOCK.Entity, on_selection=self.assignEntityLayer) elif name == 'toggle_visibility': self.doCommand('scene_editor/toggle_entity_visibility') elif name == 'freeze_entity_pivot': self.doCommand('scene_editor/freeze_entity_pivot')
def onMenu( self, menu ): name = menu.name if name == 'close_scene': if self.previewing: alertMessage( 'Warning', 'Stop previewing before closing scene' ) return self.closeScene() elif name == 'open_scene': if self.previewing: alertMessage( 'Warning', 'Stop previewing before opening scene' ) return requestSearchView( info = 'select scene to open', context = 'asset', type = 'scene', on_selection = self.openScene ) elif name == 'save_scene': if self.previewing: alertMessage( 'Warning', 'Stop previewing before saving' ) return self.saveScene() elif name == 'locate_scene_asset': if self.activeSceneNode: assetBrowser = self.getModule( 'asset_browser' ) if assetBrowser: assetBrowser.selectAsset( self.activeSceneNode ) elif name == 'add_entity': requestSearchView( info = 'select entity type to create', context = 'entity_creation', on_selection = lambda obj: self.doCommand( 'scene_editor/create_entity', name = obj ) ) elif name == 'add_component': requestSearchView( info = 'select component type to create', context = 'component_creation', on_selection = lambda obj: self.doCommand( 'scene_editor/create_component', name = obj ) ) elif name == 'add_empty_entity': self.doCommand( 'scene_editor/create_entity', name = 'Entity' ) elif name == 'load_prefab': requestSearchView( info = 'select a perfab node to instantiate', context = 'asset', type = 'prefab', on_selection = lambda obj: self.doCommand( 'scene_editor/create_prefab_entity', prefab = obj.getNodePath() ) ) elif name == 'load_prefab_in_container': requestSearchView( info = 'select a perfab node to instantiate( PefabContainer )', context = 'asset', type = 'prefab', on_selection = lambda obj: self.doCommand( 'scene_editor/create_prefab_container', prefab = obj.getNodePath() ) ) elif name == 'remove_entity': self.doCommand( 'scene_editor/remove_entity' ) elif name == 'clone_entity': self.doCommand( 'scene_editor/clone_entity' ) elif name == 'find_entity': requestSearchView( info = 'search for entity in current scene', context = 'scene', type = 'entity', on_selection = lambda x: self.selectEntity( x, focus_tree = True ) , on_test = self.selectEntity ) elif name == 'find_entity_in_group': requestSearchView( info = 'search for entity in current entity group', context = 'scene', type = 'entity_in_group', on_selection = lambda x: self.selectEntity( x, focus_tree = True ) , on_test = self.selectEntity ) elif name == 'find_entity_group': requestSearchView( info = 'search for group in current scene', context = 'scene', type = 'group', on_selection = lambda x: self.selectEntity( x, focus_tree = True ) , on_test = self.selectEntity ) elif name == 'create_group': self.doCommand( 'scene_editor/entity_group_create' ) elif name == 'remove_component': context = menu.getContext() if context: self.doCommand( 'scene_editor/remove_component', target = context ) elif name == 'copy_component': context = menu.getContext() if context: self.doCommand( 'scene_editor/copy_component', target = context ) elif name == 'edit_component_alias': context = menu.getContext() if context: oldAlias = context._alias or '' alias = requestString( 'Edit Alias', 'Enter Alias:', oldAlias ) if alias != None: if not alias: alias = False self.doCommand( 'scene_editor/rename_component', target = context, alias = alias ) elif name == 'assign_layer': if not self.tree.getSelection(): return requestSearchView( info = 'select layer to assign', context = 'scene_layer', type = _MOCK.Entity, on_selection = self.assignEntityLayer ) elif name == 'toggle_visibility': self.doCommand( 'scene_editor/toggle_entity_visibility' ) elif name == 'freeze_entity_pivot': self.doCommand( 'scene_editor/freeze_entity_pivot' )