def onLoad( self ): self.viewSelectedOnly = True self.container = self.requestDockWindow( title = 'PaintCanvas' ) self.window = window = self.container.addWidgetFromFile( _getModulePath('PaintCanvasEditor.ui') ) self.canvas = MOCKEditCanvas( window.containerPreview ) self.canvas.loadScript( _getModulePath('PaintCanvasEditor.lua'), { '_module': self } ) self.canvas.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) self.toolbarMain = QtWidgets.QToolBar( window.containerBottom ) self.toolbarMain.setOrientation( Qt.Horizontal ) layoutPreview = QtWidgets.QVBoxLayout( window.containerPreview ) layoutPreview.setSpacing( 0 ) layoutPreview.setContentsMargins( 0 , 0 , 0 , 0 ) layoutPreview.addWidget( self.canvas ) layoutBottom = QtWidgets.QVBoxLayout( window.containerBottom ) layoutBottom.setSpacing( 0 ) layoutBottom.setContentsMargins( 0 , 0 , 0 , 0 ) layoutBottom.addWidget( self.toolbarMain ) self.addToolBar( 'paintcanvas_main', self.toolbarMain ) self.addTool( 'paintcanvas_main/find_paintcanvas', icon = 'find', label = 'Find PaintCanvas' ) self.addTool( 'paintcanvas_main/----' ) self.addTool( 'paintcanvas_main/tool_pen', widget = SceneToolButton( 'paintcanvas_pen', icon = 'paintcanvas/pen', label = 'Pen' ) ) self.addTool( 'paintcanvas_main/tool_eraser', widget = SceneToolButton( 'paintcanvas_eraser', icon = 'paintcanvas/eraser', label = 'Eraser' ) ) self.addTool( 'paintcanvas_main/----' ) self.addTool( 'paintcanvas_main/tool_clear', label = 'Clear', icon = 'paintcanvas/clear' ) signals.connect( 'selection.changed', self.onSceneSelectionChanged ) self.targetPaintCanvas = None
def onLoad(self): self.container = self.requestDocumentWindow('MockStyleSheetEditor', title='Style Sheet Editor', size=(500, 300), minSize=(500, 300), dock='right') self.toolBar = self.addToolBar('style_sheet', self.container.addToolBar()) self.window = window = self.container.addWidgetFromFile( _getModulePath('styleEditor.ui')) self.tree = addWidgetWithLayout( StyleTreeWidget(self.window.containerTree, multiple_selection=False, editable=True, show_root=False, sorting=True, drag_mode=False)) self.tree.module = self self.propEditor = addWidgetWithLayout( PropertyEditor(window.containerProp)) #Previews self.canvasPreviewSheet = addWidgetWithLayout( MOCKEditCanvas(window.previewSheet)) self.canvasPreviewSheet.loadScript( _getModulePath('StyleSheetPreview.lua')) self.canvasPreviewStyle = addWidgetWithLayout( MOCKEditCanvas(window.previewStyle)) self.canvasPreviewStyle.loadScript( _getModulePath('SingleStylePreview.lua')) #Tools self.addTool('style_sheet/save', label='Save', icon='save') self.addTool('style_sheet/add_style', label='Add Style', icon='add') self.addTool('style_sheet/remove_style', label='Remove Style', icon='remove') self.addTool('style_sheet/clone_style', label='Clone Style', icon='clone') #signals self.propEditor.propertyChanged.connect(self.onPropertyChanged) window.textStylePreview.textChanged.connect( self.onStylePreviewTextChanged) window.textSheetPreview.textChanged.connect( self.onSheetPreviewTextChanged)
def onLoad(self): self.windowTitle = 'Deck2D Pack Editor' self.container = self.requestDocumentWindow('MockDeck2DEditor', title='Deck2D Pack Editor', size=(500, 300), minSize=(500, 300), dock='right' # allowDock = False ) self.window = window = self.container.addWidgetFromFile( _getModulePath('Deck2DEditor.ui')) self.propEditor = addWidgetWithLayout( PropertyEditor(window.settingsContainer), window.settingsContainer) self.canvas = addWidgetWithLayout( MOCKEditCanvas(window.canvasContainer), window.canvasContainer) self.canvas.loadScript(_getModulePath('Deck2DEditor.lua')) self.canvas.setDelegateEnv('updateEditor', self.onCanvasUpdateRequested) self.canvas.setDelegateEnv('triangulatePolygon', triangulatePolygon) #setup listwidget treeSprites = addWidgetWithLayout( SpriteTreeWidget(self.window.containerSpriteTree, multiple_selection=False)) treeSprites.module = self treeSprites.setSortingEnabled(True) self.treeSprites = treeSprites #signals window.toolAddQuad.clicked.connect(lambda: self.addItem('quad')) window.toolAddQuadArray.clicked.connect( lambda: self.addItem('quad_array')) window.toolAddTileset.clicked.connect(lambda: self.addItem('tileset')) window.toolAddStretchPatch.clicked.connect( lambda: self.addItem('stretchpatch')) window.toolAddPoly.clicked.connect(lambda: self.addItem('polygon')) window.toolSave.clicked.connect(self.saveAsset) window.toolRemove.clicked.connect(self.onRemoveItem) window.toolClone.clicked.connect(self.onCloneItem) window.toolOriginE.clicked.connect(lambda: self.setOrigin('E')) window.toolOriginS.clicked.connect(lambda: self.setOrigin('S')) window.toolOriginW.clicked.connect(lambda: self.setOrigin('W')) window.toolOriginN.clicked.connect(lambda: self.setOrigin('N')) window.toolOriginSE.clicked.connect(lambda: self.setOrigin('SE')) window.toolOriginSW.clicked.connect(lambda: self.setOrigin('SW')) window.toolOriginNE.clicked.connect(lambda: self.setOrigin('NE')) window.toolOriginNW.clicked.connect(lambda: self.setOrigin('NW')) window.toolOriginC.clicked.connect(lambda: self.setOrigin('C')) window.checkAlphaView.stateChanged.connect(self.toggleAlphaView) self.propEditor.propertyChanged.connect(self.onPropertyChanged) signals.connect('asset.modified', self.onAssetModified) self.container.setEnabled(False)
def createWidget(self, container): self.container = uic.loadUi( _getModulePath('FModPreview.ui') ) self.canvas = addWidgetWithLayout( MOCKEditCanvas(container), self.container.canvasContainer ) self.canvas.loadScript( _getModulePath('FModPreview.lua') ) return self.container
def createWidget(self, container): self.container = uic.loadUi(_getModulePath('FontPreview.ui')) self.canvas = addWidgetWithLayout(MOCKEditCanvas(container), self.container.canvasContainer) self.canvas.loadScript(_getModulePath('FontPreview.lua')) self.container.textPreview.textChanged.connect(self.onTextChanged) self.container.spinFontSize.valueChanged.connect(self.onSizeChanged) return self.container
def onLoad(self): self.configPath = self.getProject().getConfigPath(_DEPLOY_CONFIG_FILE) #UI self.container = self.requestDocumentWindow( 'ScreenProfileManager', title='Screen Profile Manager', allowDock=False, minSize=(200, 200), ) self.window = window = self.container.addWidgetFromFile( _getModulePath('ScreenProfileManager.ui')) # self.tree layout = QtWidgets.QVBoxLayout() window.containerTree.setLayout(layout) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.tree = ScreenProfileTree(window.containerTree, editable=True, multiple_selection=False) self.tree.manager = self layout.addWidget(self.tree) screenToolbar = QtWidgets.QToolBar(window.containerTree) layout.addWidget(screenToolbar) self.targetTool = self.addToolBar('screen_profile', screenToolbar) self.addTool('screen_profile/add_profile', label='+', icon='add') self.addTool('screen_profile/remove_profile', label='-', icon='remove') #target property self.propertyEditor = addWidgetWithLayout( PropertyEditor(window.containerProperty)) #menu self.addMenuItem('main/file/screen_profile_manager', dict(label='Screen Profile Manager')) # self.addTool( # 'asset/show_screen_profile_manager', # label = 'Screen Profile Manager', # on_click = lambda item: self.setFocus() # ) self.canvas = addWidgetWithLayout( MOCKEditCanvas(window.containerPreview)) self.canvas.loadScript(_getModulePath('ScreenProfileManager.lua')) self.propertyEditor.propertyChanged.connect(self.onPropertyChanged)
class TexturePreviewer(AssetPreviewer): def createWidget(self, container): self.canvas = MOCKEditCanvas(container) self.canvas.loadScript(_getModulePath('TexturePreview2.lua')) return self.canvas def accept(self, assetNode): return assetNode.getType() in ['texture', 'render_target'] def onStart(self, assetNode): self.canvas.safeCall('show', assetNode.getPath()) def onStop(self): self.canvas.safeCall('show', None)
class ProtoPreviewer( AssetPreviewer ): def createWidget(self, container): self.canvas = MOCKEditCanvas( container ) self.canvas.loadScript( _getModulePath('ProtoPreviewer.lua') ) return self.canvas def accept(self, assetNode): return assetNode.getType() in [ 'proto', 'prefab', ] def onStart(self, assetNode): self.canvas.safeCallMethod( 'preview', 'setTaretProto', assetNode.getPath() ) def onStop(self): self.canvas.safeCallMethod( 'preview', 'setTaretProto', None )
def onLoad(self): self.windowTitle = 'Shader Editor' self.container = self.requestDocumentWindow( 'ShaderEditor', title='Shader Editor', size=(500, 300), minSize=(500, 300), # allowDock = False ) self.tool = self.addToolBar('shader_editor', self.container.addToolBar()) self.addTool('shader_editor/save', label='Save', icon='save') self.addTool('shader_editor/refresh', label='Refresh', icon='refresh') self.window = window = self.container.addWidgetFromFile( _getModulePath('ShaderEditor.ui')) self.canvas = addWidgetWithLayout( MOCKEditCanvas(window.containerPreview)) self.tree = addWidgetWithLayout( ShaderUniformTreeWidget(window.containerTree, multiple_selection=False, editable=True)) self.tree.module = self
class Deck2DPreviewer(AssetPreviewer): def createWidget(self, container): self.canvas = MOCKEditCanvas(container) self.canvas.loadScript(_getModulePath('Deck2DPreview.lua')) return self.canvas def accept(self, assetNode): return assetNode.getType() in [ 'deck2d.quad', 'deck2d.stretchpatch', 'deck2d.quad_array', 'deck2d.tileset', 'deck2d.polygon', 'deck2d.mquad', 'deck2d.quads', ] def onStart(self, assetNode): self.canvas.safeCallMethod('preview', 'show', assetNode.getPath()) def onStop(self): self.canvas.safeCallMethod('preview', 'show', None)
class EffectPreviewer(AssetPreviewer): def createWidget(self, container): self.canvas = MOCKEditCanvas(container) self.canvas.loadScript(_getModulePath('EffectPreview.lua')) return self.canvas def accept(self, assetNode): return assetNode.getType() in ['effect'] def onStart(self, assetNode): atype = assetNode.getType() self.canvas.makeCurrentCanvas() self.canvas.safeCallMethod('preview', 'showEffect', assetNode.getPath()) self.canvas.startUpdateTimer(60) def onPause(self, paused): if paused: self.canvas.stopUpdateTimer() else: self.canvas.startUpdateTimer(60) def onStop(self): self.canvas.stopUpdateTimer() self.canvas.safeCallMethod('preview', 'clearEffect')
def onLoad(self): self.container = self.requestDocumentWindow( 'MockTextureManager', title='TextureManager', size=(500, 300), minSize=(500, 300), # allowDock = False ) self.toolbar = self.addToolBar('texture_manager', self.container.addToolBar()) self.window = window = self.container.addWidgetFromFile( _getModulePath('TextureManager.ui')) self.tree = addWidgetWithLayout( TextureTreeWidget(window.containerTree, drag_mode='internal', editable=True, multiple_selection=True, expanded=False)) self.tree.module = self self.treeFilter = GenericTreeFilter(window.containerTree) window.containerTree.layout().insertWidget(0, self.treeFilter) self.treeFilter.setTargetTree(self.tree) self.propEditor = addWidgetWithLayout( PropertyEditor(window.containerProp)) self.canvas = addWidgetWithLayout( MOCKEditCanvas(window.containerPreview)) self.canvas.loadScript(_getModulePath('TextureManager.lua')) self.addMenuItem('main/asset/----') self.addMenuItem('main/asset/texture_manager', { 'label': 'Texture Manager', 'on_click': lambda menu: self.setFocus() }) self.addTool('texture_manager/rebuild', label='Rebuild', icon='refresh') self.addTool('texture_manager/----') self.addTool('texture_manager/add_group', label='Add Group', icon='add') self.addTool('texture_manager/remove_group', label='Remove Group', icon='remove') self.addTool('texture_manager/----') self.addTool('texture_manager/assign_group', label='Assign Group', icon='in') self.addTool('texture_manager/----') self.addTool('texture_manager/assign_processor', label='Assign Processor', icon='compose') self.addTool('texture_manager/clear_processor', label='Clear Processor', icon='remove') self.addTool('texture_manager/----') self.addTool('texture_manager/apply', label='Apply Changes') self.addShortcut(self.container, '=', self.regroupTo) self.addShortcut(self.container, '-', self.regroup, 'default') self.propEditor.propertyChanged.connect(self.onPropertyChanged) registerSearchEnumerator(textureGroupSearchEnumerator)
def onLoad(self): self.windowTitle = 'Effect System Editor' self.container = self.requestDocumentWindow( 'MockEffectEditor', title='Effect Editor', size=(500, 300), minSize=(500, 300), # allowDock = False ) self.tool = self.addToolBar('effect_editor', self.container.addToolBar()) self.addTool('effect_editor/save', label='Save', icon='save') self.addTool('effect_editor/----') self.addTool('effect_editor/remove_node', icon='remove') self.addTool('effect_editor/clone_node', icon='clone') self.addTool('effect_editor/add_system', label='+System') self.addTool('effect_editor/add_child', label='+Child') self.addTool('effect_editor/----') self.addTool('effect_editor/add_move', label='+Move') self.addTool('effect_editor/----') self.addTool('effect_editor/move_up', icon='arrow-up') self.addTool('effect_editor/move_down', icon='arrow-down') self.addTool('effect_editor/----') self.addTool('effect_editor/toggle_preview', icon='play', type='check') self.window = window = self.container.addWidgetFromFile( _getModulePath('EffectEditor.ui')) self.canvas = addWidgetWithLayout( MOCKEditCanvas(window.containerPreview)) window.setFocusProxy(self.canvas) self.tree = addWidgetWithLayout( EffectNodeTreeWidget(window.containerTree)) self.tree.module = self propLayout = QtWidgets.QVBoxLayout() window.containerEditor.setLayout(propLayout) propLayout.setSpacing(2) propLayout.setContentsMargins(0, 0, 0, 0) self.nodePropEditor = PropertyEditor(window.containerEditor) self.paramPropEditor = PropertyEditor(window.containerEditor) propLayout.addWidget(self.nodePropEditor) propLayout.addWidget(self.paramPropEditor) self.paramPropEditor.setVisible(False) window.containerScript.setVisible(False) self.codebox = codebox = addWidgetWithLayout( CodeEditor(window.containerScript)) settingData = JSONHelper.tryLoadJSON( self.getApp().findDataFile('script_settings.json')) # if settingData: # codebox.applySetting( settingData ) self.editingTarget = None #ShortCuts self.addShortcut(self.container, '+', self.addSystem) self.addShortcut(self.container, '=', self.promptAddChild) self.addShortcut(self.container, '-', self.removeNode) # self.addShortcut( self.container, ']', self.moveNodeUp ) # self.addShortcut( self.container, '[', self.moveNodeDown ) self.addShortcut(self.container, 'ctrl+D', self.cloneNode) self.addShortcut(self.container, 'f5', self.togglePreview) self.addShortcut(self.container, 'f4', self.restartPreview) #Signals self.nodePropEditor.propertyChanged.connect(self.onNodePropertyChanged) self.paramPropEditor.propertyChanged.connect( self.onParamPropertyChanged) self.codebox.textChanged.connect(self.onScriptChanged) signals.connect('app.activate', self.onAppActivate) signals.connect('app.deactivate', self.onAppDeactivate)
class TileMapEditor( SceneEditorModule ): name = 'tilemap_editor' dependency = [ 'mock' ] def onLoad( self ): self.viewSelectedOnly = True self.container = self.requestDockWindow( title = 'Tilemap' ) self.window = window = self.container.addWidgetFromFile( _getModulePath('TileMapEditor.ui') ) self.canvas = MOCKEditCanvas( window.containerCanvas ) self.canvas.loadScript( _getModulePath('TileMapEditor.lua'), { '_module': self } ) self.toolbarLayers = QtWidgets.QToolBar( window.containerLayers ) self.toolbarLayers.setOrientation( Qt.Horizontal ) self.toolbarLayers.setMaximumHeight( 20 ) self.toolbarMain = QtWidgets.QToolBar( window.containerCanvas ) self.toolbarMain.setOrientation( Qt.Horizontal ) # self.toolbarMain.setIconSize( 32 ) self.treeLayers = TileMapLayerTreeWidget( window.containerLayers, editable = True ) self.treeLayers.parentModule = self self.treeLayers.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) self.listTerrain = TileMapTerrainList( window.containerLayers, editable = False, mode = 'list' ) self.listTerrain.parentModule = self self.listTerrain.setFixedHeight( 70 ) self.listTerrain.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed ) self.listCodeTile = CodeTilesetList( window.containerLayers, editable = False, mode = 'list' ) self.listCodeTile.parentModule = self self.listCodeTile.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) self.listCodeTile.hide() self.canvas.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) canvasLayout = QtWidgets.QVBoxLayout( window.containerCanvas ) canvasLayout.setSpacing( 0 ) canvasLayout.setContentsMargins( 0 , 0 , 0 , 0 ) layersLayout = QtWidgets.QVBoxLayout( window.containerLayers ) layersLayout.setSpacing( 0 ) layersLayout.setContentsMargins( 0 , 0 , 0 , 0 ) canvasLayout.addWidget( self.canvas ) canvasLayout.addWidget( self.listTerrain ) canvasLayout.addWidget( self.listCodeTile ) canvasLayout.addWidget( self.toolbarMain ) layersLayout.addWidget( self.toolbarLayers ) layersLayout.addWidget( self.treeLayers ) self.addToolBar( 'tilemap_layers', self.toolbarLayers ) self.addToolBar( 'tilemap_main', self.toolbarMain ) self.addTool( 'tilemap_layers/add_layer', label = 'Add', icon = 'add' ) self.addTool( 'tilemap_layers/remove_layer', label = 'Remove', icon = 'remove' ) self.addTool( 'tilemap_layers/layer_up', label = 'up', icon = 'arrow-up' ) self.addTool( 'tilemap_layers/layer_down', label = 'down', icon = 'arrow-down' ) self.addTool( 'tilemap_layers/----' ) self.addTool( 'tilemap_layers/edit_property',label = 'edit', icon = 'settings' ) self.addTool( 'tilemap_layers/----' ) self.addTool( 'tilemap_layers/inc_subdiv', label = 'subD+' ) self.addTool( 'tilemap_layers/dec_subdiv', label = 'subD-' ) self.addTool( 'tilemap_layers/----' ) self.addTool( 'tilemap_layers/view_selected_only', label = 'View Selected Only', type='check' ) self.addTool( 'tilemap_main/find_tilemap', icon = 'find', label = 'Find TileMap' ) self.addTool( 'tilemap_main/----' ) self.addTool( 'tilemap_main/tool_pen', widget = SceneToolButton( 'tilemap_pen', icon = 'tilemap/pen', label = 'Pen' ) ) self.addTool( 'tilemap_main/tool_terrain', widget = SceneToolButton( 'tilemap_terrain', icon = 'tilemap/terrain', label = 'Terrain' ) ) self.addTool( 'tilemap_main/tool_eraser', widget = SceneToolButton( 'tilemap_eraser', icon = 'tilemap/eraser', label = 'Eraser' ) ) # self.addTool( 'tilemap_main/tool_flipx', # widget = SceneToolButton( 'tilemap_flipx', # icon = 'tilemap/flip_x', # label = 'Flip X' # ) # ) self.addTool( 'tilemap_main/tool_fill', widget = SceneToolButton( 'tilemap_fill', icon = 'tilemap/fill', label = 'Fill' ) ) self.addTool( 'tilemap_main/----' ) self.addTool( 'tilemap_main/tool_random', label = 'Random', icon = 'tilemap/random', type = 'check' ) self.addTool( 'tilemap_main/----' ) self.addTool( 'tilemap_main/tool_clear', label = 'Clear', icon = 'tilemap/clear' ) signals.connect( 'selection.changed', self.onSceneSelectionChanged ) self.targetTileMap = None self.targetTileMapLayer = None def onStart( self ): self.container.show() # self.container.setEnabled( False ) self.setEditActive( False ) viewSelectedOnly = self.getWorkspaceConfig( 'view_selected_only', True ) self.findTool( 'tilemap_layers/view_selected_only' ).setValue( viewSelectedOnly ) self.setViewSelectedOnly( viewSelectedOnly ) def onStop( self ): self.setWorkspaceConfig( 'view_selected_only', self.viewSelectedOnly ) def onSetFocus( self ): self.getModule( 'scene_editor' ).setFocus() self.container.show() self.container.setFocus() def onSceneSelectionChanged( self, selection, key ): if key != 'scene': return #find animator component target = self.canvas.callMethod( 'editor', 'findTargetTileMap' ) self.setTargetTileMap( target ) def onLayerSelectionChanged( self, selection ): if selection: self.setTargetTileMapLayer( selection[0] ) else: self.setTargetTileMapLayer( None ) signals.emit( 'scene.update' ) def onTerrainSelectionChanged( self, selection ): if selection: self.canvas.callMethod( 'editor', 'setTerrainBrush', selection[0] ) self.changeSceneTool( 'tilemap_terrain' ) def onCodeTileSelectionChanged( self, selection ): if selection: self.canvas.callMethod( 'editor', 'selectCodeTile', selection[0] ) self.changeSceneTool( 'tilemap_pen' ) def setEditActive( self, active ): self.window.containerLayers.setEnabled( active ) self.canvas.setEnabled( active ) self.enableTool( 'tilemap_main/tool_pen', active ) self.enableTool( 'tilemap_main/tool_terrain', active ) self.enableTool( 'tilemap_main/tool_eraser', active ) # self.enableTool( 'tilemap_main/tool_flipx', active ) self.enableTool( 'tilemap_main/tool_fill', active ) self.enableTool( 'tilemap_main/tool_random', active ) self.enableTool( 'tilemap_main/tool_clear', active ) def setViewSelectedOnly( self, toggle ): self.viewSelectedOnly = toggle self.canvas.callMethod( 'editor', 'setViewSelectedOnly', self.viewSelectedOnly ) def clearTerrainSelection( self ): self.listTerrain.selectNode( None ) def clearCodeTileSelection( self ): self.listCodeTile.selectNode( None ) def setTargetTileMap( self, tileMap ): self.setTargetTileMapLayer( None ) self.canvas.callMethod( 'editor', 'setTargetTileMap', tileMap ) self.targetTileMap = tileMap if not self.targetTileMap: self.treeLayers.clear() # self.container.setEnabled( False ) self.setEditActive( False ) return # self.container.setEnabled( True ) self.setEditActive( True ) self.treeLayers.rebuild() layers = self.getLayers() if layers: self.treeLayers.selectNode( layers[0] ) 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 getTerrainTypeList( self ): if self.targetTileMapLayer: tileset = self.targetTileMapLayer.tileset brushTable = tileset.getTerrainBrushes( tileset ) return [ brush for brush in brushTable.values() ] return [] def getCodeTilesetList( self ): if self.targetTileMapLayer: tileset = self.targetTileMapLayer.tileset return [ key for key in tileset.idToTile.values() ] return [] def getLayers( self ): if not self.targetTileMap: return [] layers = self.targetTileMap.getLayers( self.targetTileMap ) return [ layer for layer in layers.values() ] def createLayer( self, tilesetNode ): layer = self.canvas.callMethod( 'editor', 'createTileMapLayer', tilesetNode.getPath() ) if layer: self.treeLayers.addNode( layer ) self.treeLayers.selectNode( layer ) self.treeLayers.editNode( layer ) def renameLayer( self, layer, name ): layer.name = name def listTileMapLayerTypes( self, typeId, context, option ): res = self.canvas.callMethod( 'editor', 'requestAvailTileMapLayerTypes' ) entries = [] for n in list(res.values()): entry = ( n, n, 'LayerTypes', 'obj' ) entries.append( entry ) return entries def changeTool( self, toolId ): self.canvas.callMethod( 'editor', 'changeTool', toolId ) if toolId == 'terrain': currentBrush = self.canvas.callMethod( 'editor', 'getTerrainBrush' ) def selectTileMapEntity( self, com ): entity = com._entity if not entity: return self.changeSelection( entity ) def onTool( self, tool ): name = tool.name if name == 'find_tilemap': requestSearchView( context = 'scene', type = _MOCK.TileMap, on_selection = self.selectTileMapEntity ) elif name == 'add_layer': if not self.targetTileMap: return supportedTilesetTypes = self.targetTileMap.getSupportedTilesetType( self.targetTileMap ) requestSearchView( info = 'select tileset for new layer', context = 'asset', type = supportedTilesetTypes, multiple_selection = False, on_selection = self.createLayer, # on_search = self.listTileMapLayerTypes ) elif name == 'remove_layer': self.canvas.callMethod( 'editor', 'removeTileMapLayer' ) self.treeLayers.rebuild() elif name == 'layer_up': self.canvas.callMethod( 'editor', 'moveTileMapLayerUp' ) self.treeLayers.rebuild() elif name == 'layer_down': self.canvas.callMethod( 'editor', 'moveTileMapLayerDown' ) self.treeLayers.rebuild() elif name == 'tool_clear': self.canvas.callMethod( 'editor', 'clearLayer' ) elif name == 'tool_random': self.canvas.callMethod( 'editor', 'toggleToolRandom', tool.getValue() ) elif name == 'inc_subdiv': if self.targetTileMapLayer: self.canvas.callMethod( 'editor', 'incSubDivision' ) self.treeLayers.refreshNodeContent( self.targetTileMapLayer ) elif name == 'dec_subdiv': if self.targetTileMapLayer: self.canvas.callMethod( 'editor', 'decSubDivision' ) self.treeLayers.refreshNodeContent( self.targetTileMapLayer ) elif name == 'view_selected_only': self.setViewSelectedOnly( tool.getValue() ) elif name == 'edit_property': if self.targetTileMapLayer: self.editLayerProperty( self.targetTileMapLayer ) def editLayerProperty( self, layer ): requestProperty( 'Edit TileMapLayer: ' + layer.name , layer, cancel_button = False ) self.treeLayers.refreshNodeContent( layer ) m = layer.getMap( layer ) if m: m.markDataModified( m )
class PaintCanvasEditor( SceneEditorModule ): name = 'paintcanvas_editor' dependency = [ 'mock' ] def onLoad( self ): self.viewSelectedOnly = True self.container = self.requestDockWindow( title = 'PaintCanvas' ) self.window = window = self.container.addWidgetFromFile( _getModulePath('PaintCanvasEditor.ui') ) self.canvas = MOCKEditCanvas( window.containerPreview ) self.canvas.loadScript( _getModulePath('PaintCanvasEditor.lua'), { '_module': self } ) self.canvas.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) self.toolbarMain = QtWidgets.QToolBar( window.containerBottom ) self.toolbarMain.setOrientation( Qt.Horizontal ) layoutPreview = QtWidgets.QVBoxLayout( window.containerPreview ) layoutPreview.setSpacing( 0 ) layoutPreview.setContentsMargins( 0 , 0 , 0 , 0 ) layoutPreview.addWidget( self.canvas ) layoutBottom = QtWidgets.QVBoxLayout( window.containerBottom ) layoutBottom.setSpacing( 0 ) layoutBottom.setContentsMargins( 0 , 0 , 0 , 0 ) layoutBottom.addWidget( self.toolbarMain ) self.addToolBar( 'paintcanvas_main', self.toolbarMain ) self.addTool( 'paintcanvas_main/find_paintcanvas', icon = 'find', label = 'Find PaintCanvas' ) self.addTool( 'paintcanvas_main/----' ) self.addTool( 'paintcanvas_main/tool_pen', widget = SceneToolButton( 'paintcanvas_pen', icon = 'paintcanvas/pen', label = 'Pen' ) ) self.addTool( 'paintcanvas_main/tool_eraser', widget = SceneToolButton( 'paintcanvas_eraser', icon = 'paintcanvas/eraser', label = 'Eraser' ) ) self.addTool( 'paintcanvas_main/----' ) self.addTool( 'paintcanvas_main/tool_clear', label = 'Clear', icon = 'paintcanvas/clear' ) signals.connect( 'selection.changed', self.onSceneSelectionChanged ) self.targetPaintCanvas = None def onStart( self ): self.container.show() # self.container.setEnabled( False ) self.setEditActive( False ) def onStop( self ): pass def onSetFocus( self ): self.getModule( 'scene_editor' ).setFocus() self.container.show() self.container.setFocus() def onSceneSelectionChanged( self, selection, key ): if key != 'scene': return #find animator component target = self.canvas.callMethod( 'editor', 'findTargetPaintCanvas' ) self.setTargetPaintCanvas( target ) def setEditActive( self, active ): self.enableTool( 'paintcanvas_main/tool_pen', active ) self.enableTool( 'paintcanvas_main/tool_eraser', active ) self.enableTool( 'paintcanvas_main/tool_clear', active ) def setTargetPaintCanvas( self, paintCanvas ): self.canvas.callMethod( 'editor', 'setTargetPaintCanvas', paintCanvas ) self.targetPaintCanvas = paintCanvas if paintCanvas: self.setEditActive( True ) else: self.setEditActive( False ) def renameLayer( self, layer, name ): layer.name = name def changeTool( self, toolId ): self.canvas.callMethod( 'editor', 'changeTool', toolId ) if toolId == 'terrain': currentBrush = self.canvas.callMethod( 'editor', 'getTerrainBrush' ) def selectPaintCanvasEntity( self, com ): entity = com._entity if not entity: return self.changeSelection( entity ) def onTool( self, tool ): name = tool.name if name == 'find_paintcanvas': requestSearchView( context = 'scene', type = _MOCK.PaintCanvas, on_selection = self.selectPaintCanvasEntity ) elif name == 'tool_clear': self.canvas.callMethod( 'editor', 'clearCanvas' )
class ParticlePreviewer(AssetPreviewer): def createWidget(self, container): self.canvas = MOCKEditCanvas(container) self.canvas.loadScript( _getModulePath('ParticlePreview.lua') ) return self.canvas def accept(self, assetNode): return assetNode.getType() in [ 'particle_system', 'particle_pex', 'particle_simple' ] def onStart(self, assetNode): atype = assetNode.getType() self.canvas.makeCurrentCanvas() self.canvas.safeCallMethod( 'preview', 'showParticle', assetNode.getPath() ) self.canvas.startUpdateTimer( 60 ) def onStop(self): self.canvas.stopUpdateTimer() self.canvas.safeCallMethod( 'preview', 'clearParticle' )
def createWidget(self, container): self.canvas = MOCKEditCanvas( container ) self.canvas.loadScript( _getModulePath('ProtoPreviewer.lua') ) return self.canvas
def onLoad( self ): self.viewSelectedOnly = True self.container = self.requestDockWindow( title = 'Tilemap' ) self.window = window = self.container.addWidgetFromFile( _getModulePath('TileMapEditor.ui') ) self.canvas = MOCKEditCanvas( window.containerCanvas ) self.canvas.loadScript( _getModulePath('TileMapEditor.lua'), { '_module': self } ) self.toolbarLayers = QtWidgets.QToolBar( window.containerLayers ) self.toolbarLayers.setOrientation( Qt.Horizontal ) self.toolbarLayers.setMaximumHeight( 20 ) self.toolbarMain = QtWidgets.QToolBar( window.containerCanvas ) self.toolbarMain.setOrientation( Qt.Horizontal ) # self.toolbarMain.setIconSize( 32 ) self.treeLayers = TileMapLayerTreeWidget( window.containerLayers, editable = True ) self.treeLayers.parentModule = self self.treeLayers.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) self.listTerrain = TileMapTerrainList( window.containerLayers, editable = False, mode = 'list' ) self.listTerrain.parentModule = self self.listTerrain.setFixedHeight( 70 ) self.listTerrain.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed ) self.listCodeTile = CodeTilesetList( window.containerLayers, editable = False, mode = 'list' ) self.listCodeTile.parentModule = self self.listCodeTile.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) self.listCodeTile.hide() self.canvas.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding ) canvasLayout = QtWidgets.QVBoxLayout( window.containerCanvas ) canvasLayout.setSpacing( 0 ) canvasLayout.setContentsMargins( 0 , 0 , 0 , 0 ) layersLayout = QtWidgets.QVBoxLayout( window.containerLayers ) layersLayout.setSpacing( 0 ) layersLayout.setContentsMargins( 0 , 0 , 0 , 0 ) canvasLayout.addWidget( self.canvas ) canvasLayout.addWidget( self.listTerrain ) canvasLayout.addWidget( self.listCodeTile ) canvasLayout.addWidget( self.toolbarMain ) layersLayout.addWidget( self.toolbarLayers ) layersLayout.addWidget( self.treeLayers ) self.addToolBar( 'tilemap_layers', self.toolbarLayers ) self.addToolBar( 'tilemap_main', self.toolbarMain ) self.addTool( 'tilemap_layers/add_layer', label = 'Add', icon = 'add' ) self.addTool( 'tilemap_layers/remove_layer', label = 'Remove', icon = 'remove' ) self.addTool( 'tilemap_layers/layer_up', label = 'up', icon = 'arrow-up' ) self.addTool( 'tilemap_layers/layer_down', label = 'down', icon = 'arrow-down' ) self.addTool( 'tilemap_layers/----' ) self.addTool( 'tilemap_layers/edit_property',label = 'edit', icon = 'settings' ) self.addTool( 'tilemap_layers/----' ) self.addTool( 'tilemap_layers/inc_subdiv', label = 'subD+' ) self.addTool( 'tilemap_layers/dec_subdiv', label = 'subD-' ) self.addTool( 'tilemap_layers/----' ) self.addTool( 'tilemap_layers/view_selected_only', label = 'View Selected Only', type='check' ) self.addTool( 'tilemap_main/find_tilemap', icon = 'find', label = 'Find TileMap' ) self.addTool( 'tilemap_main/----' ) self.addTool( 'tilemap_main/tool_pen', widget = SceneToolButton( 'tilemap_pen', icon = 'tilemap/pen', label = 'Pen' ) ) self.addTool( 'tilemap_main/tool_terrain', widget = SceneToolButton( 'tilemap_terrain', icon = 'tilemap/terrain', label = 'Terrain' ) ) self.addTool( 'tilemap_main/tool_eraser', widget = SceneToolButton( 'tilemap_eraser', icon = 'tilemap/eraser', label = 'Eraser' ) ) # self.addTool( 'tilemap_main/tool_flipx', # widget = SceneToolButton( 'tilemap_flipx', # icon = 'tilemap/flip_x', # label = 'Flip X' # ) # ) self.addTool( 'tilemap_main/tool_fill', widget = SceneToolButton( 'tilemap_fill', icon = 'tilemap/fill', label = 'Fill' ) ) self.addTool( 'tilemap_main/----' ) self.addTool( 'tilemap_main/tool_random', label = 'Random', icon = 'tilemap/random', type = 'check' ) self.addTool( 'tilemap_main/----' ) self.addTool( 'tilemap_main/tool_clear', label = 'Clear', icon = 'tilemap/clear' ) signals.connect( 'selection.changed', self.onSceneSelectionChanged ) self.targetTileMap = None self.targetTileMapLayer = None