def onPause( self ):
		self.cc.visible = 0
		self.cc.delAsView()

		if ( WorldEditor.tool() != None ):
			WorldEditor.popTool()

		pass
	def update( self, dTime, tool ):
		# must use update to check for this, key events aren't reliable
		if not WorldEditor.isKeyDown( KEY_LEFTMOUSE ):
			if (WorldEditor.isKeyDown( KEY_LCONTROL ) or WorldEditor.isKeyDown( KEY_RCONTROL )):
				# add the set
				set_union( self.chunkItemFunctor.selection, self.mouseRevealer )
			elif WorldEditor.isKeyDown( KEY_LALT ) or WorldEditor.isKeyDown( KEY_RALT ):
				# remove the set
				self.chunkItemFunctor.selection.rem( self.mouseRevealer )
			else:
				# set the selection to our mouse revaler
				set_assign( self.chunkItemFunctor.selection, self.mouseRevealer )

			if not WorldEditor.isKeyDown( KEY_LALT ) and not WorldEditor.isKeyDown( KEY_RALT ):
				# not removing, so also add whatever is under the cursor
				set_union( self.chunkItemFunctor.selection, self.chunkItemFunctor.mouseRevealer )

			self.chunkItemFunctor.selUpdate()

			WorldEditor.popTool( )
	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()
Exemplo n.º 4
0
	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
Exemplo n.º 5
0
	def onPause( self ):
		WorldEditor.popTool()
		self.cc.visible = 0
		self.cc.delAsView()