Пример #1
0
    def openScene(self, node, protoNode=None):
        if self.activeSceneNode == node:
            if self.getModule('scene_view'):
                self.getModule('scene_view').setFocus()

            if protoNode:
                self.delegate.safeCallMethod('editor', 'locateProto',
                                             protoNode.getPath())
                if self.getModule('scene_view'):
                    self.getModule('scene_view').focusSelection()

        else:
            if not self.closeScene(): return
            if self.getModule('scene_view'):
                self.getModule('scene_view').makeCanvasCurrent()
            self.activeSceneNode = node
            signals.emitNow('scene.pre_open', node)
            scene = self.delegate.safeCallMethod('editor', 'openScene',
                                                 node.getPath())
            if not scene:
                #todo: raise something
                alertMessage(
                    'error',
                    '%s\n\nfailed to open scene, see console for detailed information.'
                    % node.getPath())
                return False
            signals.emitNow('scene.open', self.activeSceneNode, scene)
            self.setFocus()
            self.editingProtoNode = protoNode
            self.loadWorkspaceState(False)
            self.delegate.safeCallMethod('editor', 'postOpenScene')
Пример #2
0
 def editAsset(self, node):
     editor = app.getModule('deck2d_editor')
     if not editor:
         return alertMessage('Editor not load', 'Deck2D Editor not found!')
     if not node.isType('deck2d'):
         editor.openAsset(node.getParent(), node)
     else:
         editor.openAsset(node)
Пример #3
0
 def makeProto(self):
     selection = self.getSelection()
     if not selection: return
     if len(selection) > 1:
         return alertMessage(
             'multiple entities cannot be converted into Proto')
     target = selection[0]
     if not target: return
     if requestConfirm('convert proto', 'Convert this Entity into Proto?'):
         self.doCommand('scene_editor/make_proto', entity=target)
         self.tree.refreshNodeContent(target)
Пример #4
0
 def createPrefab(self, targetPrefab):
     selection = self.getSelection()
     if not selection: return
     if len(selection) > 1:
         return alertMessage(
             'multiple entities cannot be converted into prefab')
     target = selection[0]
     self.doCommand('scene_editor/create_prefab',
                    entity=target,
                    prefab=targetPrefab.getNodePath(),
                    file=targetPrefab.getAbsFilePath())
Пример #5
0
 def editAsset(self, node):
     editor = app.getModule('sceneoutliner_editor')
     if not editor:
         return alertMessage('Editor not load',
                             'Scene Outliner Editor not found!')
     if node.assetType == 'scene':
         editor.openScene(node)
     elif node.assetType == 'proto':
         scnNode = node.getParent()
         editor.openScene(scnNode, node)
     else:
         return
Пример #6
0
 def editAsset(self, node):
     editor = app.getModule('candy.stylesheet_editor')
     if not editor:
         return alertMessage('Editor not load', 'Style Editor not found!')
     editor.setFocus()
     editor.openAsset(node)
Пример #7
0
def showAlertMessage(title, msg):
    alertMessage(title, msg)
Пример #8
0
    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=_CANDY.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')