def startDragSelect( self ): # add a drag select tool, which will pop itself and set our # selection when done. nt = WorldEditor.Tool() nt.locator = bd.itemTool.locator.subLocator nt.functor = Functor.ScriptedFunctor( DragSelectFunctor(nt, self) ) WorldEditor.pushTool( nt )
def onLeftMouse( self ): # first see if there's a gizmo in the house if self.objInfo.overGizmo: # if so, let it take care of things WorldEditor.gizmoClick() return # we have to compare what's under the cursor to our selection # if there's no selection then (for now) set it to that # and do nothing more if not self.selection.size: self.selection.add( self.mouseRevealer ) self.selUpdate() return # if there's a selection but nothing under the mouse, # clear the selection if self.selection.size and not self.mouseRevealer.size: self.selection.rem( self.selection ) self.selUpdate() return # if the selection is different to what's under the mouse, # change the selection diff = WorldEditor.ChunkItemGroup() diff.add( self.selection ) diff.rem( self.mouseRevealer ) # cumbersome I know if diff.size: self.selection.rem( self.selection ) self.selection.add( self.mouseRevealer ) self.selUpdate() return # ok the selection and what's under the mouse are the same, # start a drag of the selection # first make the tool nt = WorldEditor.Tool() nt.locator = self.mouseLocator nt.functor = Functor.MatrixMover( self.selection ) # and then push it onto the stack. it'll pop itself off when done WorldEditor.pushTool( nt )
def enterMode( self, modeName, forceUpdate = 0 ): #print "enterMode - current %s, new %s, terrainMode %s" % (self.modeName, modeName, self.terrainModeName ) if (self.modeName == modeName) and (not forceUpdate): return t = WorldEditor.tool() oldTool = t if t != None and modeName != "Object": if self.itemTool.functor.script.selection.size: self.itemTool.functor.script.selection.rem( self.itemTool.functor.script.selection ) self.itemTool.functor.script.selUpdate() WorldEditor.popTool() # Remove the project or height module if we're coming out of project or height mode if self.modeName in ("Project", "Height"): self.modeStack.pop() self.modeName = self.modeStack[ len( self.modeStack ) - 1 ] WorldEditor.pop() if ( modeName == "TerrainTexture" ): WorldEditor.pushTool( self.alphaTool ) self.terrainModeName = modeName elif ( modeName == "TerrainHeight" ): WorldEditor.pushTool( self.heightTool ) self.terrainModeName = modeName elif ( modeName == "TerrainFilter" ): WorldEditor.pushTool( self.filterTool ) self.terrainModeName = modeName elif ( modeName == "TerrainHoleCut" ): WorldEditor.pushTool( self.holeTool ) self.terrainModeName = modeName elif ( modeName == "Terrain" ): self.modeName = modeName self.enterMode( self.terrainModeName ) self.modeStack.append( modeName ) return elif ( modeName == "Object" ): WorldEditor.pushTool( self.itemTool ) self.modeStack.append( modeName ) elif ( modeName == "Project" ): WorldEditor.push( "ProjectModule" ) self.modeStack.append( modeName ) elif ( modeName == "Height" ): WorldEditor.push( "HeightModule" ) self.modeStack.append( modeName ) else: WorldEditor.addCommentaryMsg( "%s mode not yet implemented" % modeName, 1 ) self.enterChunkVizMode() WorldEditor.addCommentaryMsg( "entered " + modeName + " mode" ) self.modeName = modeName newTool = WorldEditor.tool() if oldTool != None and oldTool != newTool: oldTool.endUsing() if newTool != None: newTool.beginUsing()
return abs( self.clickX ) > self.dragStartDelta or abs( self.clickY ) > self.dragStartDelta def onMouseEvent( self, (dx,dy,dz), tool ): if dz != 0 \ and ( WorldEditor.isKeyDown( KEY_LSHIFT ) \ or WorldEditor.isKeyDown( KEY_RSHIFT ) \ or WorldEditor.getOptionInt( "input/legacyMouseWheel" ) != 0 ) \ and self.selection.size: rotateTool = WorldEditor.Tool() rotateTool.functor = Functor.WheelRotator() rotateTool.locator = Locator.OriginLocator() rotateTool.handleMouseEvent( dx, dy, dz ) # Add the mousewheel rotate tool, it'll automatically pop itself WorldEditor.pushTool( rotateTool ) if not WorldEditor.isKeyDown( KEY_MOUSE0 ): # just to make sure that leftMouseDown has a consistent value self.leftMouseDown = 0 if self.dragging: self.clickX += dx self.clickY += dy if self.dragDeltaExceeded(): self.dragging = 0 try: nt = WorldEditor.Tool() nt.locator = bd.itemTool.locator.subLocator nt.functor = Functor.MatrixMover()
def ownKeyEvent( self, key, modifiers ): t = WorldEditor.tool() handled = 1 if key == KEY_RBRACKET: if modifiers & MODIFIER_SHIFT: t.strength = t.strength * 1.25 WorldEditor.addCommentaryMsg( "Tool strength %0.1f" % t.strength, 0 ) else: t.size = t.size * 1.25 WorldEditor.addCommentaryMsg( "Tool size %0.1f" % t.size, 0 ) elif key == KEY_LBRACKET: if modifiers & MODIFIER_SHIFT: t.strength = t.strength * 0.8 WorldEditor.addCommentaryMsg( "Tool strength %0.1f" % t.strength, 0 ) else: t.size = t.size * 0.8 WorldEditor.addCommentaryMsg( "Tool size %0.1f" % t.size, 0 ) elif key == KEY_F6: scv = WorldEditor.getOptionString( "tools/showChunkVisualisation" ) if scv == "true": self.alphatool.delView( self.chunkvis ) WorldEditor.setOptionString( "tools/showChunkVisualisation", "false" ) else: self.alphatool.addView( self.chunkvis ) WorldEditor.setOptionString( "tools/showChunkVisualisation", "true" ) elif key == KEY_F8: WorldEditor.save() elif key == KEY_F9: if not t.applying: if t == self.alphatool: if t.functor == self.alphafunc: t.functor = self.heightfunc self.guiview.visible = 0 WorldEditor.addCommentaryMsg( "Entering height filter mode. Press LMB to apply", 0 ) else: t.functor = self.alphafunc WorldEditor.pushTool( self.ecotool ) WorldEditor.addCommentaryMsg( "Entering ecotype mode. Press Enter to apply", 0 ) elif t == self.ecotool: WorldEditor.popTool() WorldEditor.pushTool( self.objtool ) WorldEditor.addCommentaryMsg( "Entering objt manipln mode. Use LMB to select", 0 ) else: WorldEditor.popTool() self.guiview.visible = 1 WorldEditor.addCommentaryMsg( "Entering alpha mode. Press LMB to apply", 0 ) elif key == KEY_Z: if not t.applying and (modifiers & MODIFIER_CONTROL): if not (modifiers & MODIFIER_SHIFT): what = WorldEditor.undo(0) if what: WorldEditor.addCommentaryMsg( "Undoing: " + what, 1 ) WorldEditor.undo() else: what = WorldEditor.redo(0) if what: WorldEditor.addCommentaryMsg( "Redoing: " + what, 1 ) WorldEditor.redo() elif key == KEY_I and (modifiers & MODIFIER_CONTROL): self.objInfo.browseUp() self.objInfo.showBrowse() elif key == KEY_K and (modifiers & MODIFIER_CONTROL): self.objInfo.browseDown() self.objInfo.showBrowse() elif key == KEY_J and (modifiers & MODIFIER_CONTROL): self.objInfo.browseLeft() self.objInfo.showBrowse() elif key == KEY_L and (modifiers & MODIFIER_CONTROL): self.objInfo.browseRight() self.objInfo.showBrowse() else: handled = 0 return handled
def onResume( self, exitCode ): WorldEditor.pushTool( self.alphatool ) self.cc.addAsView() self.cc.visible = 1