本文整理汇总了Python中WorldEditor.isKeyDown方法的典型用法代码示例。如果您正苦于以下问题:Python WorldEditor.isKeyDown方法的具体用法?Python WorldEditor.isKeyDown怎么用?Python WorldEditor.isKeyDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldEditor
的用法示例。
在下文中一共展示了WorldEditor.isKeyDown方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onLeftMouse
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import isKeyDown [as 别名]
def onLeftMouse( self ):
self.clickX = 0
self.clickY = 0
# 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
if not self.mouseRevealer.size:
# nothing to click on, start a marquee selection. This will take
# care of clearing the selection if it's only a click.
self.startDragSelect()
return
# Check if control is held down, it indicates that we want to toggle
# what's pointed to in/out of the selection
if (WorldEditor.isKeyDown( KEY_LCONTROL ) or WorldEditor.isKeyDown( KEY_RCONTROL )):
# if we're pointing at a subset of the selection
if set_issubset( self.selection, self.mouseRevealer):
# remove the subset
self.selection.rem( self.mouseRevealer )
self.selUpdate()
return
else:
# add the mouseRevealer to the selection
set_union( self.selection, self.mouseRevealer )
self.selUpdate()
return
else:
# if the selection is totally different to what's under the mouse
# specifically, if we're only pointing at a subset of the
# selection, we don't want to set the selection to that, we want
# to drag it instead (which happens below )
#if not set_intersection_new( self.selection, self.mouseRevealer).size:
if not set_issubset( self.selection, self.mouseRevealer ):
# set the selection to what's under the mouse
set_assign( self.selection, self.mouseRevealer )
self.selUpdate()
# nothing under the mouse, bail
if not self.selection.size:
return
if not WorldEditor.getOptionInt( "dragOnSelect" ):
if not WorldEditor.isKeyDown( KEY_V ):
return
# ok, it's drag time
self.dragging = 1
示例2: onMiddleMouse
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import isKeyDown [as 别名]
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" )
示例3: handleEvent
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import isKeyDown [as 别名]
def handleEvent( self, type, key, modifiers, c ):
if ( WorldEditor.isKeyDown( key ) ):
if ( key == Keys.KEY_LEFTMOUSE ) :
c.textureName = self.textureMouseDown
self.clickState = 1
return 1
else:
if ( key == Keys.KEY_LEFTMOUSE ) :
c.textureName = self.textureFocus
if ( self.clickState == 1 ):
if ( self.eventHandler != None ):
self.eventHandler.onClick( self.buttonEvent )
return 1
return 0
示例4: update
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import isKeyDown [as 别名]
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( )
示例5: onMouseEvent
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import isKeyDown [as 别名]
def onMouseEvent( self, mx, my, mz ):
handled = 0
if mx or my:
self.mouseMoved = 1
legacyMouse = WorldEditor.getOptionInt( "input/legacyMouseWheel" )
itemsRotated = 0
cameraSpeedChanged = False
if legacyMouse != 0:
# if using legacy mouse
if WorldEditor.isKeyDown( KEY_MOUSE1 ):
# Change camera speed with right click
self.handleWheelCameraSpeed( mz )
cameraSpeedChanged = True
elif WorldEditor.tool():
# handle the tool
handled = WorldEditor.tool().handleMouseEvent( mx, my, mz )
itemsRotated = self.itemTool.functor.script.selection.size
else:
# if using new mouse
if WorldEditor.tool() and mz == 0:
# handle the tool
handled = WorldEditor.tool().handleMouseEvent( mx, my, mz )
elif WorldEditor.isKeyDown( KEY_SPACE ):
# Change camera speed with space
self.handleWheelCameraSpeed( mz )
cameraSpeedChanged = True
elif ( WorldEditor.isKeyDown( KEY_LSHIFT ) or WorldEditor.isKeyDown( KEY_RSHIFT ) ) and WorldEditor.tool():
# handle the tool with shift
handled = WorldEditor.tool().handleMouseEvent( mx, my, mz )
itemsRotated = self.itemTool.functor.script.selection.size
elif mz != 0 and \
( WorldEditor.isKeyDown( KEY_LCONTROL ) or WorldEditor.isKeyDown( KEY_RCONTROL ) ) and \
self.itemTool.functor.script.selection.size > 0:
WorldEditor.rotateSnap( self.itemTool.functor.script.selection, mz, self.itemTool.functor.script.mouseRevealer )
itemsRotated = self.itemTool.functor.script.selection.size
if not handled:
handled = WorldEditor.camera().handleMouseEvent( mx, my, mz )
if not handled and ( mz != 0 ) and not itemsRotated and not cameraSpeedChanged:
# zoom using scroll wheel
handled = 1
view = WorldEditor.camera().view
view.invert()
mult = mz / 1200.0
if WorldEditor.isCapsLockOn():
mult = mult * WorldEditor.camera().turboSpeed
else:
mult = mult * WorldEditor.camera().speed
forward = view.applyToAxis( 2 )
view.translation = (
view.translation[0] + forward[0] * mult,
view.translation[1] + forward[1] * mult,
view.translation[2] + forward[2] * mult )
view.invert()
WorldEditor.camera().view = view
return handled
示例6: startDragSelect
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import isKeyDown [as 别名]
pass
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 dragDeltaExceeded( self ):
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