def actUndoExecute(): what = WorldEditor.undo(0) if what: WorldEditor.addCommentaryMsg( "Undoing: " + what ) WorldEditor.undo() bd.itemTool.functor.script.selUpdate()
def onMiddleMouse( self ): # ensure that we both have a selection and something under the mouse if not self.selection.size or not self.mouseRevealer.size: return # ensure that we're in shell mode if not WorldEditor.isChunkSelected(): return # If v is held down, clone and snap the shell under the cursor if WorldEditor.isKeyDown( KEY_V ): group = WorldEditor.cloneAndAutoSnap( self.mouseRevealer, self.selection ) if ( group != None ): set_assign( self.selection, group ) self.selUpdate() else: WorldEditor.addCommentaryMsg( "No matching portals", 2 ) return # if the selection is different to what's under the mouse, if set_difference_new( self.selection, self.mouseRevealer ).size: # auto snap the shells together if not WorldEditor.autoSnap( self.selection, self.mouseRevealer ): WorldEditor.addCommentaryMsg( "No matching portals" )
def handleWheelCameraSpeed( self, mz ): # look at the rotator for changing the camera speed c = WorldEditor.camera() currentValue = WorldEditor.getOptionString( "camera/speed" ) speeds = ["Slow", "Medium", "Fast", "SuperFast"] iSpeed = 0 if currentValue == speeds[1]: iSpeed = 1 elif currentValue == speeds[2]: iSpeed = 2 elif currentValue == speeds[3]: iSpeed = 3 if mz > 0: iSpeed = iSpeed + 1 if iSpeed > 3: iSpeed = 3 elif mz < 0: iSpeed = iSpeed - 1 if iSpeed < 0: iSpeed = 0 value = speeds[iSpeed] handled = 0 if value != currentValue: c = WorldEditor.camera() WorldEditor.setOptionString( "camera/speed", value ) c.speed = WorldEditor.getOptionFloat( "camera/speed/" + value ) c.turboSpeed = WorldEditor.getOptionFloat( "camera/speed/" + value + "/turbo" ) handled = 1 WorldEditor.addCommentaryMsg( "New camera speed %s" % value, 1 ) return handled
def doRedo( item ): what = WorldEditor.redo(0) if what: WorldEditor.addCommentaryMsg( "Redoing: " + what ) WorldEditor.redo() bd.itemTool.functor.script.selUpdate()
def actUndoExecute(): what = WorldEditor.undo(0) if what: WorldEditor.addCommentaryMsg("Undoing: " + what) WorldEditor.undo() bd.itemTool.functor.script.selUpdate()
def doRedo(item): what = WorldEditor.redo(0) if what: WorldEditor.addCommentaryMsg("Redoing: " + what) WorldEditor.redo() bd.itemTool.functor.script.selUpdate()
def actFreeSnapsExecute(): newSnaps = (0.1, 0.1, 0.1) WorldEditor.setOptionVector3("snaps/movement", newSnaps) WorldEditor.setOptionFloat("snaps/angle", 1) WorldEditor.addCommentaryMsg("Movement snaps are %f,%f,%f" % (newSnaps[0], newSnaps[1], newSnaps[2])) WorldEditor.addCommentaryMsg("Rotation snaps are %f" % WorldEditor.getOptionFloat("snaps/angle"))
def doUndo(item): """This function performs an undo operation.""" what = WorldEditor.undo(0) if what: WorldEditor.addCommentaryMsg("Undoing: " + what) WorldEditor.undo() bd.itemTool.functor.script.selUpdate()
def doUndo( item ): """This function performs an undo operation.""" what = WorldEditor.undo(0) if what: WorldEditor.addCommentaryMsg( "Undoing: " + what ) WorldEditor.undo() bd.itemTool.functor.script.selUpdate()
def actShellSnapsExecute(): WorldEditor.setOptionVector3( "snaps/movement", WorldEditor.getOptionVector3("shellSnaps/movement")) WorldEditor.setOptionFloat("snaps/angle", WorldEditor.getOptionFloat("shellSnaps/angle")) newSnaps = WorldEditor.getOptionVector3("snaps/movement") WorldEditor.addCommentaryMsg("Movement snaps are %f,%f,%f" % (newSnaps[0], newSnaps[1], newSnaps[2])) WorldEditor.addCommentaryMsg("Rotation snaps are %f" % WorldEditor.getOptionFloat("snaps/angle"))
def pgcTerrainTabSelect(value): if value == "tabTerrainTextures": bd.enterMode("TerrainTexture") elif value == "tabTerrainBrushes": bd.enterMode("TerrainHeight") elif value == "tabTerrainFilters": bd.enterMode("TerrainFilter") elif value == "tabTerrainTools": bd.enterMode("TerrainHoleCut") else: WorldEditor.addCommentaryMsg(value + " unknown tab", 1)
def pgcTerrainTabSelect( value ): if value == "tabTerrainTextures": bd.enterMode( "TerrainTexture" ) elif value == "tabTerrainBrushes": bd.enterMode( "TerrainHeight" ) elif value == "tabTerrainFilters": bd.enterMode( "TerrainFilter" ) elif value == "tabTerrainTools": bd.enterMode( "TerrainHoleCut" ) else: WorldEditor.addCommentaryMsg( value + " unknown tab", 1 )
def enterItemSnapMode( self ): newLoc = None newLoc = Locator.ChunkObstacleToolLocator() t = self.itemTool if self.itemSnapMode == 0: newLoc = self.itemToolXZLocator t.delView( "stdView" ) t.size = 1 #½øÈë±à¼Ä£Ê½ if ( WorldEditor.getUserMode() == 0 ): t.addView( self.itemToolPlaneView, "stdView" ) WorldEditor.addCommentaryMsg( "Entering free snap mode" ) elif self.itemSnapMode == 1: newLoc = Locator.TerrainToolLocator() t.delView( "stdView" ) t.size = 1 if ( WorldEditor.getUserMode() == 0 ): t.addView( self.itemToolTextureView, "stdView" ) WorldEditor.addCommentaryMsg( "Entering terrain snap mode" ) elif self.itemSnapMode == 2: newLoc = Locator.ChunkObstacleToolLocator() t.delView( "stdView" ) t.size = 1 if ( WorldEditor.getUserMode() == 0 ): t.addView( self.itemToolModelView, "stdView" ) WorldEditor.addCommentaryMsg( "Entering obstacle snap mode" ) else: #WorldEditor.addCommentaryMsg( "Unknown snap mode" ) WorldEditor.addCommentaryMsg( "" ) #finally, recreate the functor self.itemTool.locator.subLocator = newLoc
def selUpdate( self ): try: # tell big bang what the current selection is WorldEditor.revealSelection( self.selection ) if self.selection.size: self.selEditor = WorldEditor.ChunkItemEditor( self.selection ) WorldEditor.setCurrentEditors( self.selEditor ) #if hasattr(self.selEditor, "description"): # print "Selected a", str(self.selEditor.description) #else: # print "Selected a group" # inform the user of stats about the selection #if ( self.objInfo.shellMode == 1 and self.selection.size > 1): # WorldEditor.showChunkReport( self.selection ) else: self.selEditor = None WorldEditor.setCurrentEditors() except EnvironmentError, e: WorldEditor.addCommentaryMsg( e.args[0], 1 )
def addChunkShell( self ): try: (pChunkSection,chunkName) = WorldEditor.createInsideChunkDataSection() if ( pChunkSection == None ): WorldEditor.addCommentaryMsg( "Could not create data section", 1 ) else: # fill in the model information pChunkSection.writeString( "shell/resource", \ self.objInfo.getBrowsePath() ) # open the model data section pModelSection = ResMgr.openSection( self.objInfo.getBrowsePath() ) if ( not pModelSection ): WorldEditor.addCommentaryMsg( \ "Could not open model file. Shell not added", 1 ) else: # check to see whether the model is nodefull, if so, warn the user testSection = pModelSection["nodefullVisual"] if testSection != None: WorldEditor.addCommentaryMsg( \ "warning: model is nodefull, shell not statically lit", 1 ) # create initial data WorldEditor.chunkFromModel( pChunkSection, pModelSection ) # copy from the template pTemplateSection = ResMgr.openSection( self.objInfo.getBrowsePath() + ".template" ) if pTemplateSection: deepCopyTemplate( pChunkSection, pTemplateSection ) group = WorldEditor.createChunk( pChunkSection, \ chunkName, \ self.mouseLocator.subLocator ) if ( group != None ): self.chunkItemAdded( self.objInfo.getBrowsePath() ); except Exception, e: WorldEditor.addCommentaryMsg( e.args[0], 1 )
def doSaveCameraPosition(item): dir = WorldEditor.getOptionString("space/mru0") dirDS = ResMgr.openSection(dir) if not dirDS: WorldEditor.addCommentaryMsg("Unable to open local directory " + dir) return ds = dirDS["space.localsettings"] if ds == None: ds = dirDS.createSection("space.localsettings") if ds == None: WorldEditor.addCommentaryMsg("Unable to create space.localsettings") return m = WorldEditor.camera(0).view m.invert() ds.writeVector3("startPosition", m.translation) ds.writeVector3("startDirection", (m.roll, m.pitch, m.yaw)) ds.save() WorldEditor.addCommentaryMsg("Camera position saved")
def actSaveCameraPositionExecute(): dir = WorldEditor.getOptionString( "space/mru0" ) dirDS = ResMgr.openSection( dir ) if not dirDS: WorldEditor.addCommentaryMsg( "Unable to open local directory " + dir ) return ds = dirDS["space.localsettings"] if ds == None: ds = dirDS.createSection( "space.localsettings" ) if ds == None: WorldEditor.addCommentaryMsg( "Unable to create space.localsettings" ) return m = WorldEditor.camera(0).view m.invert() ds.writeVector3( "startPosition", m.translation ) ds.writeVector3( "startDirection", (m.roll, m.pitch, m.yaw) ) ds.save() WorldEditor.addCommentaryMsg( "Camera position saved" )
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()
def updateState( self, dTime ): """This function forces an update to be called in World Editor. Usually called everyframe, however it still recieves a dTime value which informs the update function how much time has passed since the last update call.""" # detect a change of space, and act accordingly if self.currentSpace != WorldEditor.getOptionString( "space/mru0" ): self.currentSpace = WorldEditor.getOptionString( "space/mru0" ) # make sure the chunk viz resolution is set correctly self.enterChunkVizMode() GUI.update( dTime ) self.cc.update( dTime ) WorldEditor.camera().update( dTime ) if ( WorldEditor.tool() != None and not WorldEditor.tool().applying ): self.objInfo.overGizmo = WorldEditor.gizmoUpdate( WorldEditor.worldRay() ) # update the WorldEditor WorldEditor.update( dTime ) # update tool views base = dTime / 5 self.alphaToolTextureView.rotation += base * (1 + (self.alphaTool.strength / 650)) self.heightView.rotation += base * (1 + (self.heightTool.strength / 650)) self.filterToolTextureView.rotation += base if self.nextTimeDoSelUpdate == 2: self.itemTool.functor.script.restoreOldSelection() self.nextTimeDoSelUpdate = 0 elif self.nextTimeDoSelUpdate == 1: self.itemTool.functor.script.clearAndSaveSelection() self.nextTimeDoSelUpdate = 2 if WorldEditor.isInPlayerPreviewMode() and not self.avatarMode: WorldEditor.addCommentaryMsg( "entered avatar walkthrough mode." ) self.avatarMode = 1 if self.avatarMode and not WorldEditor.isInPlayerPreviewMode(): self.qDown = 0 self.eDown = 0 self.avatarMode = 0 if self.avatarMode: value = WorldEditor.getOptionString( "camera/speed" ) speed = 1 if value == "Medium": speed = 2 if value == "Fast": speed = 3 if value == "SuperFast": speed = 4 if self.qDown and WorldEditor.getOptionInt( "graphics/cameraHeight" ) - speed <= 2: WorldEditor.setOptionInt( "graphics/cameraHeight", 2 ) if self.qDown and WorldEditor.getOptionInt( "graphics/cameraHeight" ) > 2: WorldEditor.setOptionInt( "graphics/cameraHeight", WorldEditor.getOptionInt( "graphics/cameraHeight" ) - speed ) if self.eDown: WorldEditor.setOptionInt( "graphics/cameraHeight", WorldEditor.getOptionInt( "graphics/cameraHeight" ) + speed ) WorldEditor.snapCameraToTerrain() if WorldEditor.tool() == bd.alphaTool: bd.alphaTool.size = WorldEditor.getOptionFloat ( "terrain/texture/size" ) bd.alphaTool.strength = WorldEditor.getOptionFloat ( "terrain/texture/strength" ) bd.alphaTool.functor.displayOverlay = WorldEditor.getOptionInt ( "terrain/texture/maskoverlay" ) WorldEditor.setPaintLayer(bd.alphaTool.functor.lastPaintedLayer) WorldEditor.setPaintPos(bd.alphaTool.functor.lastPaintedPos) if bd.alphaTool.functor.hadEscapeKey != 0: WorldEditor.setTerrainPaintEscKey(bd.alphaTool.functor.hadEscapeKey) bd.alphaTool.functor.hadEscapeKey = 0 bd.heightTool.size = WorldEditor.getOptionFloat ( "terrain/height/size" ) bd.heightTool.strength = WorldEditor.getOptionFloat ( "terrain/height/strength" ) bd.setHeightFunctor.height = WorldEditor.getOptionFloat ( "terrain/height/height" ) bd.setHeightFunctor.relative = WorldEditor.getOptionInt ( "terrain/height/relative" ) bd.heightFunctor.falloff = WorldEditor.getOptionInt ( "terrain/height/brushFalloff" ) bd.filterTool.size = WorldEditor.getOptionFloat ( "terrain/filter/size" ) bd.filterTool.functor.index = WorldEditor.getOptionInt ( "terrain/filter/index" ) bd.holeTool.size = WorldEditor.getOptionFloat ( "terrain/cutRepair/size" ) bd.holeTool.functor.fillNotCut = WorldEditor.getOptionInt ( "terrain/cutRepair/brushMode" ) if self.needsChunkVizUpdate: self.enterChunkVizMode() return 1
def ownKeyEvent( self, key, modifiers ): if key == KEY_B: if (modifiers & MODIFIER_CTRL) == 0: curr = WorldEditor.getOptionInt( "drawBSP" ) curr = ( curr + 1 ) % 2 WorldEditor.setOptionInt( "drawBSP", curr ) self.showBSPMsg( curr ) elif key == KEY_M: curr = WorldEditor.getOptionInt( "dragOnSelect" ) curr = ( curr + 1 ) % 2 WorldEditor.setOptionInt( "dragOnSelect", curr ) self.dragOnSelectMsg( curr ) elif key == KEY_F8: curr = WorldEditor.getOptionString( "tools/coordFilter" ) if curr == "World": curr = "Local" elif curr == "Local": curr = "View" elif curr == "View": curr = "World" WorldEditor.setOptionString( "tools/coordFilter", curr ) WorldEditor.addCommentaryMsg( "Reference Coordinate System: %s" % curr ) elif key == KEY_L: if modifiers & MODIFIER_CTRL: curr = WorldEditor.getOptionInt( "render/lighting" ) curr = ( curr + 1 ) % 3 WorldEditor.setOptionInt( "render/lighting", curr ) self.lightingModeMsg( curr ) elif key == KEY_G: curr = WorldEditor.getOptionInt( "snaps/xyzEnabled" ) curr = ( curr + 1 )% 2 WorldEditor.setOptionInt( "snaps/xyzEnabled", curr ) self.objectSnapMsg( curr ) elif key == KEY_1 and not modifiers: WorldEditor.setToolMode( "Objects" ) elif key == KEY_2 and not modifiers: WorldEditor.setToolMode( "TerrainTexture" ) elif key == KEY_3 and not modifiers: WorldEditor.setToolMode( "TerrainHeight" ) elif key == KEY_4 and not modifiers: WorldEditor.setToolMode( "TerrainFilter" ) elif key == KEY_5 and not modifiers: WorldEditor.setToolMode( "TerrainMesh" ) elif key == KEY_6 and not modifiers: WorldEditor.setToolMode( "TerrainImpExp" ) elif key == KEY_7 and not modifiers: WorldEditor.setToolMode( "Project" ) t = WorldEditor.tool() sizeSection = '' strengthSection = '' minSizeSection = '' maxSizeSection = '' minStrengthSection = '' maxStrengthSection = '' if t == self.alphaTool: sizeSection = 'terrain/texture/size' minSizeSection = 'terrain/texture/minsizelimit' maxSizeSection = 'terrain/texture/maxsizelimit' strengthSection = 'terrain/texture/strength' minStrengthSection = 'terrain/texture/minstrengthlimit' maxStrengthSection = 'terrain/texture/maxstrengthlimit' elif t == self.heightTool: sizeSection = 'terrain/height/size' minSizeSection = 'terrain/height/minsizelimit' maxSizeSection = 'terrain/height/maxsizelimit' strengthSection = 'terrain/height/strength' minStrengthSection = 'terrain/height/minstrengthlimit' maxStrengthSection = 'terrain/height/maxstrengthlimit' elif t == self.filterTool: sizeSection = 'terrain/filter/size' minSizeSection = 'terrain/filter/minsizelimit' maxSizeSection = 'terrain/filter/maxsizelimit' elif t == self.holeTool: sizeSection = 'terrain/cutRepair/size' minSizeSection = 'terrain/cutRepair/minsizelimit' maxSizeSection = 'terrain/cutRepair/maxsizelimit' if sizeSection: size = WorldEditor.getOptionFloat( sizeSection ) minSize = WorldEditor.getOptionFloat( minSizeSection ) maxSize = WorldEditor.getOptionFloat( maxSizeSection ) if key == KEY_RBRACKET: if not ( modifiers & MODIFIER_SHIFT ): size = size * 1.25 + 1 if size > maxSize: size = maxSize t.size = size WorldEditor.setOptionFloat( sizeSection, size ) WorldEditor.addCommentaryMsg( "Tool size %0.1f" % size ) elif key == KEY_LBRACKET: if not ( modifiers & MODIFIER_SHIFT ): size = size * 0.8 - 1 if size < minSize: size = minSize t.size = size WorldEditor.setOptionFloat( sizeSection, size ) WorldEditor.addCommentaryMsg( "Tool size %0.1f" % size ) if strengthSection: strength = WorldEditor.getOptionFloat( strengthSection ) minStrength = WorldEditor.getOptionFloat( minStrengthSection ) maxStrength = WorldEditor.getOptionFloat( maxStrengthSection ) if key == KEY_RBRACKET and strength >= 0 or key == KEY_LBRACKET and strength < 0: if modifiers & MODIFIER_SHIFT: if strength >= 0: strength = strength * 1.25 + 1 else: strength = strength * 1.25 - 1 if strength > maxStrength: strength = maxStrength t.strength = strength WorldEditor.setOptionFloat( strengthSection, strength ) WorldEditor.addCommentaryMsg( "Tool strength %0.1f" % strength ) elif key == KEY_LBRACKET and strength >= 0 or key == KEY_RBRACKET and strength < 0: if modifiers & MODIFIER_SHIFT: if strength >= 0: strength = strength * 0.8 - 1 else: strength = strength * 0.8 + 1 if strength < minStrength: strength = minStrength t.strength = strength WorldEditor.setOptionFloat( strengthSection, strength ) WorldEditor.addCommentaryMsg( "Tool strength %0.1f" % strength )
def objectSnapMsg( self, state ): if state == 1: WorldEditor.addCommentaryMsg( "Enabling Object Snap Grid" ) else: WorldEditor.addCommentaryMsg( "Disabling Object Snap Grid" )
def itemSnapModeMsg( self, state ): WorldEditor.addCommentaryMsg( "Entering %s snap mode" % self.lockNames[state] )
def onResume( self, exitCode ): self.cc.addAsView() self.cc.visible = 1 WorldEditor.addCommentaryMsg( "entered edit mode." ) self.enterMode( self.modeName, 1 )
def cmbCoordFilterChange(value): WorldEditor.addCommentaryMsg("Reference Coordinate System: %s" % value) WorldEditor.setOptionString("tools/coordFilter", value)
def onCheckBoxToggle( name, value ): WorldEditor.addCommentaryMsg( name + " toggle not yet implemented. value = " + str( value ), 1 )
def onSliderAdjust( name, value, min, max ): WorldEditor.addCommentaryMsg( "%s adjust not yet implemented %f < %f < %f" % (name, min, value, max ), 1 )
def onEvent(event, value): WorldEditor.addCommentaryMsg( "Generic event (%s, %s) not yet implemented" % (event, str(value)), 1)
def spdMiscSnapsYAdjust(value, min, max): snaps = WorldEditor.getOptionVector3("snaps/movement") newSnaps = (snaps[0], value, snaps[2]) WorldEditor.setOptionVector3("snaps/movement", newSnaps) WorldEditor.addCommentaryMsg("Movement snaps are %0.1f,%0.1f,%0.1f" % (newSnaps[0], newSnaps[1], newSnaps[2]))
def ualSelectFilterChange(value): if (WorldEditor.getOptionString("tools/selectFilter") != value): WorldEditor.addCommentaryMsg("Selection Filter: %s" % value) WorldEditor.setOptionString("tools/selectFilter", value) setSelectionFilter(value)
def chunkItemAdded( self, name ): WorldEditor.addItemToHistory( self.objInfo.getBrowsePath(), "FILE" ); WorldEditor.addCommentaryMsg( "Added " + name )
def onComboBoxSelect(name, selectionName): WorldEditor.addCommentaryMsg( "%s select not yet implemented. selection = %s" % (name, selectionName), 1)
def onBrowserItemSelect(name, filename): WorldEditor.addCommentaryMsg( "%s browser item (%s) select not yet implemented" % (name, filename), 1)
def actSaveChunkTemplateExecute(): if bd.itemTool.functor.script.selection.size: WorldEditor.saveChunkTemplate( bd.itemTool.functor.script.selection ) else: WorldEditor.addCommentaryMsg( "Nothing selected" )
def onSliderAdjust(name, value, min, max): WorldEditor.addCommentaryMsg( "%s adjust not yet implemented %f < %f < %f" % (name, min, value, max), 1)
def showBrowse( self ): WorldEditor.addCommentaryMsg( self.getBrowsePath() )
def dragOnSelectMsg( self, state ): if state == 1: WorldEditor.addCommentaryMsg( "Enabling Drag On Select" ) else: WorldEditor.addCommentaryMsg( "Disabling Drag On Select")
def onBrowserItemSelect( name, filename ): WorldEditor.addCommentaryMsg( "%s browser item (%s) select not yet implemented" % (name, filename), 1 )
def lightingModeMsg( self, state ): WorldEditor.addCommentaryMsg( "Lighting Mode: %s" % self.lightNames[state] )
def ualSelectFilterChange( value ): if( WorldEditor.getOptionString( "tools/selectFilter" ) != value ): WorldEditor.addCommentaryMsg( "Selection Filter: %s" % value ) WorldEditor.setOptionString( "tools/selectFilter", value ) setSelectionFilter( value )
def showBSPMsg( self, state ): if state == 1: WorldEditor.addCommentaryMsg( "Drawing custom BSPs" ) else: WorldEditor.addCommentaryMsg( "Normal draw mode")
def onListItemSelect( name, index ): WorldEditor.addCommentaryMsg( "%s list item[%i] select not yet implemented" % (name, index), 1 )
def onButtonClick(name): WorldEditor.addCommentaryMsg("%s click not yet implemented" % name, 1)
def savePrefab(name): message = WorldEditor.saveChunkPrefab(bd.itemTool.functor.script.selection, name) if message != None: WorldEditor.addCommentaryMsg(message, 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
if key == KEY_MIDDLEMOUSE: self.onMiddleMouse() handled = 1 #elif key == KEY_RETURN: # self.addChunkItem() elif key == KEY_DELETE: if self.selection.size: WorldEditor.deleteChunkItems( self.selection ) elif key == KEY_ESCAPE: # clear the selection set_clear( self.selection ) self.selUpdate() #elif key == KEY_R and self.objInfo.shellMode and self.selection.size: elif key == KEY_R and self.selection.size: WorldEditor.recreateChunks( self.selection ) WorldEditor.addCommentaryMsg( "Recreated chunks" ) # clear the selection set_clear( self.selection ) self.selUpdate() # elif key == KEY_T: # WorldEditor.recalcTerrainShadows() # WorldEditor.addCommentaryMsg( "Recalced shadows" ) elif key == KEY_C: if self.selection.size > 0: WorldEditor.cloneChunkItems( self.selection, bd.itemTool.locator.subLocator ) WorldEditor.addCommentaryMsg( "Cloned Selection" ) else: if key == KEY_LEFTMOUSE: self.leftMouseDown = 0
def showBrowse( self ): if not self.getBrowsePath() in ["", "unknown file"]: WorldEditor.addCommentaryMsg( self.getBrowsePath() )
def onCheckBoxToggle(name, value): WorldEditor.addCommentaryMsg( name + " toggle not yet implemented. value = " + str(value), 1)
def savePrefab( name ): message = WorldEditor.saveChunkPrefab( bd.itemTool.functor.script.selection, name ) if message != None: WorldEditor.addCommentaryMsg( message, 0 )
def onListItemSelect(name, index): WorldEditor.addCommentaryMsg( "%s list item[%i] select not yet implemented" % (name, index), 1)
def onComboBoxSelect( name, selectionName ): WorldEditor.addCommentaryMsg( "%s select not yet implemented. selection = %s" % (name, selectionName), 1 )
def onEvent( event, value ): WorldEditor.addCommentaryMsg( "Generic event (%s, %s) not yet implemented" % (event, str(value) ), 1 )
def defaultActionExecute( name ): """This function is the default handler for executing actions.""" WorldEditor.addCommentaryMsg( "%s execute not yet implemented" % name )
def begin( self, dummyValue ): WorldEditor.addCommentaryMsg( "finished calculating ecotypes", 0 )