def onTool( self, tool ): name = tool.name if name == 'add_session': self.addSession() elif name == 'add_scheme': if not self.currentSession: logging.warn( 'no quest session specified' ) return False requestSearchView( info = 'select quest scheme to add', context = 'quest_scheme', on_search = self.enumerateSelectableGraphs, on_selection = self.addSchemeEntry ) elif name == 'remove_scheme': if not self.currentSession: logging.warn( 'no quest session specified' ) return False for node in self.tree.getSelection(): if isMockInstance( node, 'QuestSessionSchemeEntry' ): self.removeSchemeEntry( node ) elif isMockInstance( node, 'QuestSession' ): self.removeSession( node ) elif name == 'refresh': self.tree.rebuild()
def getNodeChildren( self, node ): if node == self.getRootNode(): return [ session for session in list(node.sessions.values()) ] elif isMockInstance( node, 'QuestSession' ): return [ entry for entry in list(node.schemeEntries.values()) ] elif isMockInstance( node, 'QuestSessionSchemeEntry' ): return []
def onPropertyChanged(self, obj, fid, value): if isMockInstance(obj, 'SQNode'): self.treeRoutineNode.refreshNodeContent(obj) if self.currentNodeEditor: self.currentNodeEditor.onRefresh(obj) elif isMockInstance(obj, 'SQRoutine'): pass
def __lt__(self, other): node0 = self.node node1 = hasattr(other, 'node') and other.node or None if not node1: return True if not node0: return False tree = self.treeWidget() group0 = isMockInstance( node0, 'EntityGroup' ) group1 = isMockInstance( node1, 'EntityGroup' ) if group0 != group1: if tree.sortOrder() == 0: if group0: return True if group1: return False else: if group0: return False if group1: return True proto0 = node0[ 'FLAG_PROTO_SOURCE' ] proto1 = node1[ 'FLAG_PROTO_SOURCE' ] if proto0 != proto1: if tree.sortOrder() == 0: if proto0: return True if proto1: return False else: if proto0: return False if proto1: return True return super( SceneGraphTreeItem, self ).__lt__( other )
def __lt__(self, other): node0 = self.node node1 = hasattr(other, 'node') and other.node or None if not node1: return True if not node0: return False tree = self.treeWidget() group0 = isMockInstance(node0, 'EntityGroup') group1 = isMockInstance(node1, 'EntityGroup') if group0 != group1: if tree.sortOrder() == 0: if group0: return True if group1: return False else: if group0: return False if group1: return True proto0 = node0['FLAG_PROTO_SOURCE'] proto1 = node1['FLAG_PROTO_SOURCE'] if proto0 != proto1: if tree.sortOrder() == 0: if proto0: return True if proto1: return False else: if proto0: return False if proto1: return True return super(SceneGraphTreeItem, self).__lt__(other)
def onPropertyChanged(self, obj, fid, value): if isMockInstance(obj, "SQNode"): self.treeRoutineNode.refreshNodeContent(obj) if self.currentNodeEditor: self.currentNodeEditor.onRefresh(obj) elif isMockInstance(obj, "SQRoutine"): pass
def getNodeParent( self, node ): if node == self.getRootNode(): return None if isMockInstance( node, 'QuestSession' ): return self.getRootNode() elif isMockInstance( node, 'QuestSessionSchemeEntry' ): return node.session else: print(node) raise Exception( 'Unknown Quest Object Type' )
def updateItemContent( self, item, node, **option ): pal = self.palette() defaultBrush = QColorF( .8,.8,.8 ) name = None if isMockInstance( node, 'AnimatorTrackGroup' ): item.setText( 0, node.toString( node ) ) item.setIcon( 0, getIcon('track_group') ) elif isMockInstance( node, 'AnimatorClipSubNode' ): item.setText( 0, node.toString( node ) ) item.setIcon( 0, getIcon(node.getIcon( node )) ) item.setIcon( 1, getIcon('track_key_0') )
def onItemSelectionChanged( self ): m = app.getModule( 'quest_session_manager' ) for node in self.getSelection(): if isMockInstance( node, 'QuestSession' ): session = node schemeEntry = None m.setCurrentSelection( session, schemeEntry ) elif isMockInstance( node, 'QuestSessionSchemeEntry' ): session = node.session schemeEntry = node m.setCurrentSelection( session, schemeEntry ) break
def updateItemContent(self, item, node, **option): if node == self.owner: return # name = node.getName( node ) # item.setText( 0, name or '<unknown>' ) # item.setIcon( 0, getIcon( 'entity' ) ) node.forceUpdate(node) if node['FLAG_PROTO_SOURCE']: item.setIcon(0, getIcon('proto')) elif node['PROTO_INSTANCE_STATE']: item.setIcon(0, getIcon('instance')) elif node['__proto_history']: item.setIcon(0, getIcon('instance-sub')) elif node['__prefabId']: item.setIcon(0, getIcon('instance-prefab')) elif isMockInstance(node, 'ProtoContainer'): item.setIcon(0, getIcon('instance-container')) elif isMockInstance(node, 'PrefabContainer'): item.setIcon(0, getIcon('instance-prefab-container')) else: item.setIcon(0, getIcon('obj')) item.setText(0, node.getFullName(node) or '<unnamed>') item.setText(1, node.getRootGroupName(node)) item.setText(2, getMockClassName(node)) #update icon if node.isVisible(node): item.setIcon(3, getIcon('entity_vis')) elif node.isLocalVisible(node): item.setIcon(3, getIcon('entity_parent_invis')) else: item.setIcon(3, getIcon('entity_invis')) if node.isEditLocked(node): if node.isLocalEditLocked(node): item.setIcon(4, getIcon('entity_lock')) else: item.setIcon(4, getIcon('entity_parent_lock')) else: item.setIcon(4, getIcon('entity_nolock')) layerName = node.getLayer(node) if isinstance(layerName, tuple): item.setText(5, '????') else: item.setText(5, layerName) item.setText(6, node.getComponentInfo(node) or '')
def getItemFlags( self, node ): flags = { 'editable' : False } if isMockInstance( node, 'QuestSession' ): flags[ 'editable' ] = True return flags
def getItemFlags( self, node ): flags = {} if isMockInstance( node, 'AnimatorTrackGroup' ): flags['editable'] = True else: flags['editable'] = False return flags
def updateItemContent( self, item, node, **option ): pal = self.palette() defaultBrush = QColorF( .8,.8,.8 ) name = None if isMockInstance( node, 'Layer' ): style = defaultBrush item.setText( 0, node.name ) if node.default : item.setIcon( 0, getIcon('layer_default') ) else: item.setIcon( 0, getIcon('layer') ) if node.editorVisible: item.setIcon( 1, getIcon('ok') ) else: item.setIcon( 1, getIcon('no')) style = _BrushLayerHidden if not node.locked: item.setIcon( 2, getIcon('ok') ) else: item.setIcon( 2, getIcon('no')) if node.editorSolo == 'solo': item.setIcon( 3, getIcon('ok') ) style = _BrushLayerSolo else: item.setIcon( 3, getIcon(None) ) if self.hasSoloLayer: style = _BrushLayerHidden item.setForeground( 0, style ) else: item.setText( 0, '' ) item.setIcon( 0, getIcon('normal') )
def updateItemContent(self, item, node, **option): pal = self.palette() defaultBrush = QColorF(.8, .8, .8) name = None if isMockInstance(node, 'Layer'): style = defaultBrush item.setText(0, node.name) if node.default: item.setIcon(0, getIcon('layer_default')) else: item.setIcon(0, getIcon('layer')) if node.editorVisible: item.setIcon(1, getIcon('ok')) else: item.setIcon(1, getIcon('no')) style = _BrushLayerHidden if not node.locked: item.setIcon(2, getIcon('ok')) else: item.setIcon(2, getIcon('no')) if node.editorSolo == 'solo': item.setIcon(3, getIcon('ok')) style = _BrushLayerSolo else: item.setIcon(3, getIcon(None)) if self.hasSoloLayer: style = _BrushLayerHidden item.setForeground(0, style) else: item.setText(0, '') item.setIcon(0, getIcon('normal'))
def updateItemContent( self, item, node, **option ): name = None item.setData( 0, Qt.UserRole, 0 ) if isMockInstance( node, 'EntityGroup' ): item.setText( 0, node.name or '<unnamed>' ) item.setIcon( 0, getIcon('entity_group') ) if node.isLocalVisible( node ): item.setIcon( 1, getIcon( 'entity_vis' ) ) else: item.setIcon( 1, getIcon( 'entity_invis' ) ) if node.isLocalEditLocked( node ): item.setIcon( 2, getIcon( 'entity_lock' ) ) else: item.setIcon( 2, getIcon( 'entity_nolock' ) ) item.setData( 0, Qt.UserRole, 1 ) elif isMockInstance( node, 'Entity' ): if node['FLAG_PROTO_SOURCE']: item.setIcon( 0, getIcon('proto') ) elif node['PROTO_INSTANCE_STATE']: item.setIcon( 0, getIcon('instance') ) elif node['__proto_history']: item.setIcon( 0, getIcon('instance-sub') ) elif isMockInstance( node, 'ProtoContainer' ): item.setIcon( 0, getIcon('instance-container') ) else: item.setIcon( 0, getIcon('obj') ) item.setText( 0, node.name or '<unnamed>' ) layerName = node.getLayer( node ) if isinstance( layerName, tuple ): item.setText( 3, '????' ) else: item.setText( 3, layerName ) # item.setText( 2, node.getClassName( node ) ) # item.setFont( 0, _fontAnimatable ) if node.isLocalVisible( node ): item.setIcon( 1, getIcon( 'entity_vis' ) ) else: item.setIcon( 1, getIcon( 'entity_invis' ) ) if node.isLocalEditLocked( node ): item.setIcon( 2, getIcon( 'entity_lock' ) ) else: item.setIcon( 2, getIcon( 'entity_nolock' ) )
def updateItemContent(self, item, node, **option): name = None item.setData(0, Qt.UserRole, 0) if isMockInstance(node, 'EntityGroup'): item.setText(0, node.name or '<unnamed>') item.setIcon(0, getIcon('entity_group')) if node.isLocalVisible(node): item.setIcon(1, getIcon('entity_vis')) else: item.setIcon(1, getIcon('entity_invis')) if node.isLocalEditLocked(node): item.setIcon(2, getIcon('entity_lock')) else: item.setIcon(2, getIcon('entity_nolock')) item.setData(0, Qt.UserRole, 1) elif isMockInstance(node, 'Entity'): if node['FLAG_PROTO_SOURCE']: item.setIcon(0, getIcon('proto')) elif node['PROTO_INSTANCE_STATE']: item.setIcon(0, getIcon('instance')) elif node['__proto_history']: item.setIcon(0, getIcon('instance-sub')) elif isMockInstance(node, 'ProtoContainer'): item.setIcon(0, getIcon('instance-container')) else: item.setIcon(0, getIcon('obj')) item.setText(0, node.name or '<unnamed>') layerName = node.getLayer(node) if isinstance(layerName, tuple): item.setText(3, '????') else: item.setText(3, layerName) # item.setText( 2, node.getClassName( node ) ) # item.setFont( 0, _fontAnimatable ) if node.isLocalVisible(node): item.setIcon(1, getIcon('entity_vis')) else: item.setIcon(1, getIcon('entity_invis')) if node.isLocalEditLocked(node): item.setIcon(2, getIcon('entity_lock')) else: item.setIcon(2, getIcon('entity_nolock'))
def setTarget( self, target ): introspector = self.getIntrospector() self.target = target self.grid.setTarget( target ) if isMockInstance( target, 'Scene' ): for mgr in target.getManagers( target ).values(): if mgr.FLAG_INTERNAL: continue editor = introspector.addObjectEditor( mgr )
def updateItemContent( self, item, node, **option ): if node == self.getRootNode(): return elif isMockInstance( node, 'QuestSession' ): item.setText( 0, node.name or '<NONAME>' ) item.setIcon( 0, getIcon( 'folder' ) ) elif isMockInstance( node, 'QuestSessionSchemeEntry' ): path = node.path name = os.path.basename( path ) if name.endswith( '.quest.graphml' ): shortName = name[:-14] else: shortName, ext = os.path.splitext( name ) item.setText( 0, shortName ) item.setIcon( 0, getIcon( 'quest_scheme' ) )
def getNodeChildren(self, node): if isMockInstance(node, 'Game'): result = [] for item in list(node.layers.values()): if item.name == '_GII_EDITOR_LAYER': continue result.append(item) return reversed(result) return []
def getNodeChildren( self, node ): if isMockInstance( node, 'Game' ): result = [] for item in node.layers.values(): if item.name == '_GII_EDITOR_LAYER': continue result.append( item ) return reversed( result ) return []
def setTarget(self, target): if not target.components: return introspector = self.getIntrospector() self.target = target self.grid.setTarget(target) if isMockInstance(target, 'Entity'): if target['__proto_history']: self.container.setProperty('proto', True) else: self.container.setProperty('proto', False) self.container.repolish() #setup proto tool protoState = target['PROTO_INSTANCE_STATE'] if protoState: self.header.containerProto.show() protoPath = getProtoPath(target) self.header.labelProtoPath.setText(protoPath) else: self.header.containerProto.hide() prefabPath = target['__prefabId'] if prefabPath: self.header.containerPrefab.show() self.header.labelPrefabPath.setText(prefabPath) else: self.header.containerPrefab.hide() #add component editors for com in list(target.getSortedComponentList(target).values()): if com.FLAG_INTERNAL: continue editor = introspector.addObjectEditor( com, context_menu='component_context', editor_class=ComponentEditor, show_after_add=False) self.buttonAddComponent = buttonAddComponent = QtWidgets.QToolButton( ) buttonAddComponent.setObjectName('ButtonIntrospectorAddComponent') buttonAddComponent.setText('Add Component ...') buttonAddComponent.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) buttonAddComponent.clicked.connect(self.onButtonAddComponent) introspector.addWidget(self.buttonAddComponent) self.buttonPasteComponent = buttonPasteComponent = QtWidgets.QToolButton( ) buttonPasteComponent.setObjectName( 'ButtonIntrospectorAddComponent') buttonPasteComponent.setText('Paste Component') buttonPasteComponent.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) buttonPasteComponent.clicked.connect(self.onButtonPasteComponent) introspector.addWidget(self.buttonPasteComponent) self.restoreFoldState() self.updateAnimatorButton()
def getCurrentClipGroup( self ): selection = self.treeClips.getSelection() if selection: node = selection[ 0 ] while node: if isMockInstance( node, 'AnimatorClipGroup' ): return node node = node.parentGroup return None
def getNodeChildren(self, node): groups = [] entries = [] for entry in list(node.children.values()): if isMockInstance(entry, 'GizmoVisibilityGroup'): groups.append(entry) else: entries.append(entry) return groups + entries
def updateItemContent( self, item, node, **option ): if isMockInstance( node, 'AnimatorClipGroup' ): # pal = self.palette() # defaultBrush = QColorF( .8,.8,.8 ) # name = None item.setText( 0, node.name ) item.setIcon( 0, getIcon('folder') ) else: item.setText( 0, node.name ) item.setIcon( 0, getIcon('clip') )
def __lt__(self, other): node0 = self.node node1 = hasattr(other, 'node') and other.node or None if not node1: return True tree = self.treeWidget() # col = tree.sortColumn() t0 = isMockInstance( node0, 'AnimatorClipGroup' ) and 'group' or 'node' t1 = isMockInstance( node1, 'AnimatorClipGroup' ) and 'group' or 'node' if t1!=t0: if tree.sortOrder() == 0: if t0 == 'group': return True if t1 == 'group': return False else: if t0 == 'group': return False if t1 == 'group': return True return super( AnimatorClipListTreeItem, self ).__lt__( other )
def onClipSelectioChanged( self ): selection = self.treeClips.getSelection() if selection: clip = selection[0] else: clip = None if isMockInstance( clip, 'AnimatorClip' ): self.owner.setTargetClip( clip ) else: #TODO pass
def selectEditTarget(self, node): self.editingTarget = node self.nodePropEditor.setTarget(node) #check tool button state # isSystem = isMockInstance( node, 'EffectNodeParticleSystem' ) if isMockInstance(node, 'EffectNodeParticleState'): self.window.containerScript.setVisible(True) self.paramPropEditor.setVisible(True) self.updateScript() elif isMockInstance(node, 'EffectScript'): self.window.containerScript.setVisible(True) self.paramPropEditor.setVisible(False) self.paramPropEditor.setTarget(None) self.updateScript() else: self.window.containerScript.setVisible(False) self.paramPropEditor.setVisible(False) self.paramPropEditor.setTarget(None)
def updateItemContent(self, item, node, **option): if isMockInstance(node, 'Entity'): item.setText(0, getMockClassName(node)) item.setText(1, node.getName(node)) else: item.setText(0, getMockClassName(node)) alias = node._alias if alias: item.setText(1, alias) else: item.setText(1, '-')
def setTargetTileMapLayer( self, layer ): self.canvas.callMethod( 'editor', 'setTargetTileMapLayer', layer ) self.canvas.updateCanvas() self.targetTileMapLayer = layer if isMockInstance( layer, 'CodeTileMapLayer' ): self.listCodeTile.show() self.listTerrain.hide() self.canvas.hide() self.listCodeTile.rebuild() else: self.listCodeTile.hide() self.listTerrain.show() self.canvas.show() self.listTerrain.rebuild()
def getNodeChildren( self, node ): if isMockInstance( node, 'EntityGroup' ): output = [] #groups for group in node.childGroups: output.append( group ) #entities for ent in node.entities: if ( not ent.parent ) and ( not ( ent.FLAG_EDITOR_OBJECT or ent.FLAG_INTERNAL ) ): output.append( ent ) # output = sorted( output, cmp = _sortEntity ) return output else: #entity output = [] for ent in node.children: if not ( ent.FLAG_EDITOR_OBJECT or ent.FLAG_INTERNAL ): output.append( ent ) # output = sorted( output, cmp = _sortEntity ) return output
def getNodeChildren(self, node): if isMockInstance(node, 'EntityGroup'): output = [] #groups for group in node.childGroups: output.append(group) #entities for ent in node.entities: if (not ent.parent) and (not (ent.FLAG_EDITOR_OBJECT or ent.FLAG_INTERNAL)): output.append(ent) # output = sorted( output, cmp = _sortEntity ) return output else: #entity output = [] for ent in node.children: if not (ent.FLAG_EDITOR_OBJECT or ent.FLAG_INTERNAL): output.append(ent) # output = sorted( output, cmp = _sortEntity ) return output
def setTarget( self, target ): if not target.components: return introspector = self.getIntrospector() self.target = target self.grid.setTarget( target ) if isMockInstance( target, 'Entity' ): if target['__proto_history']: self.container.setProperty( 'proto', True ) else: self.container.setProperty( 'proto', False ) self.container.repolish() #setup prefab tool protoState = target['PROTO_INSTANCE_STATE'] if protoState: self.header.containerPrefab.show() protoPath = getProtoPath( target ) self.header.labelPrefabPath.setText( protoPath ) else: self.header.containerPrefab.hide() #add component editors for com in target.getSortedComponentList( target ).values(): if com.FLAG_INTERNAL: continue editor = introspector.addObjectEditor( com, context_menu = 'component_context', editor_class = ComponentEditor ) container = editor.getContainer() self.buttonAddComponent = buttonAddComponent = QtGui.QToolButton() buttonAddComponent.setObjectName( 'ButtonIntrospectorAddComponent' ) buttonAddComponent.setText( 'Add Component ...' ) buttonAddComponent.setSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed ) buttonAddComponent.clicked.connect( self.onButtonAddComponent ) introspector.addWidget( self.buttonAddComponent ) self.restoreFoldState() self.updateAnimatorButton()
def getNodeParent( self, node ): # reimplemnt for target node if isMockInstance( node, 'Game' ): return None return _MOCK.game
def getNodeChildren( self, node ): if isMockInstance( node, 'AnimatorClipGroup' ): children = node.getChildNodes( node ) return [ child for child in children.values() ] else: return []
def getNodeParent(self, node): # reimplemnt for target node if isMockInstance(node, 'Game'): return None return _MOCK.game
def onPropertyTargetChanged( self, obj ): if isMockInstance( obj, 'AnimatorKey' ): self.timeline.refreshKey( obj ) elif isMockInstance( obj, 'AnimatorClipMarker' ): self.timeline.refreshMarker( obj ) self.owner.onObjectEdited( obj )
def createTrackItem( self, trackNode, **options ): if isMockInstance( trackNode, 'AnimatorEventTrack' ): return TimelineEventTrackItem() else: return TimelineTrackItem()
def getClipTreeRoot(self): if self.targetClip and isMockInstance(self.targetClip, 'AnimatorClipTree'): return self.targetClip.getTreeRoot(self.targetClip)
def updateParamProxy(self): if isMockInstance(self.editingTarget, 'EffectNodeParticleState'): stateNode = self.editingTarget self.paramProxy = stateNode.buildParamProxy(stateNode) self.paramPropEditor.setTarget(self.paramProxy)
def onItemChanged( self, item, col ): node = self.getNodeByItem( item ) if isMockInstance( node, 'QuestSession' ): app.getModule( 'quest_session_manager' ).renameSession( node, item.text(0) ) else: print('WTF?')
def onItemActivated( self, item, col ): node = item.node if isMockInstance( node, 'QuestSessionSchemeEntry' ): path = node.path app.getModule( 'asset_browser' ).locateAsset( path )