Example #1
0
    def handleKeyEvent(self, event):
        import game
        isDown, key, mods, isRepeat = game.convertKeyEvent(event)
        if isRepeat:
            return False
        elif self.__isStarted and self.__isDetached:
            if self.__curCtrl.alwaysReceiveKeyEvents() and not self.isObserverFPV or CommandMapping.g_instance.isFired(CommandMapping.CMD_CM_LOCK_TARGET, key):
                self.__curCtrl.handleKeyEvent(isDown, key, mods, event)
            return BigWorld.player().handleKey(isDown, key, mods)
        elif not self.__isStarted or self.__isDetached:
            return False
        for command in self.__commands:
            if command.handleKeyEvent(isDown, key, mods, event):
                return True

        if isDown and BigWorld.isKeyDown(Keys.KEY_CAPSLOCK):
            if self.__alwaysShowAimKey is not None and key == self.__alwaysShowAimKey:
                gui_event_dispatcher.toggleCrosshairVisibility()
                return True
            if self.__showMarkersKey is not None and key == self.__showMarkersKey and not self.__isGUIVisible:
                gui_event_dispatcher.toggleMarkers2DVisibility()
                return True
            if key == Keys.KEY_F5 and constants.HAS_DEV_RESOURCES:
                self.__vertScreenshotCamera.enable(not self.__vertScreenshotCamera.isEnabled)
                return True
        if key == Keys.KEY_SPACE and isDown and BigWorld.player().isObserver():
            BigWorld.player().cell.switchObserverFPV(not BigWorld.player().isObserverFPV)
            return True
        else:
            return True if not self.isObserverFPV and self.__curCtrl.handleKeyEvent(isDown, key, mods, event) else BigWorld.player().handleKey(isDown, key, mods)
Example #2
0
 def handleKeyEvent(self, event):
     import game
     isDown, key, mods, isRepeat = game.convertKeyEvent(event)
     if isRepeat:
         return False
     elif self.__isStarted and self.__isDetached:
         return BigWorld.player().handleKey(isDown, key, mods)
     elif not self.__isStarted or self.__isDetached:
         return False
     if isDown and BigWorld.isKeyDown(Keys.KEY_CAPSLOCK):
         if self.__alwaysShowAimKey is not None and key == self.__alwaysShowAimKey:
             gui_event_dispatcher.toggleCrosshairVisibility()
             return True
         if self.__showMarkersKey is not None and key == self.__showMarkersKey and not self.__isGUIVisible:
             gui_event_dispatcher.toggleMarkers2DVisibility()
             return True
         if key == Keys.KEY_F5 and constants.HAS_DEV_RESOURCES:
             self.__vertScreenshotCamera.enable(not self.__vertScreenshotCamera.isEnabled)
             return True
     if self.__curCtrl.handleKeyEvent(isDown, key, mods, event):
         return True
     else:
         return BigWorld.player().handleKey(isDown, key, mods)
Example #3
0
 def handleKeyEvent(self, event):
     import game
     isDown, key, mods, isRepeat = game.convertKeyEvent(event)
     if isRepeat:
         return False
     elif self.__isStarted and self.__isDetached:
         return BigWorld.player().handleKey(isDown, key, mods)
     elif not self.__isStarted or self.__isDetached:
         return False
     if isDown and BigWorld.isKeyDown(Keys.KEY_CAPSLOCK):
         if self.__alwaysShowAimKey is not None and key == self.__alwaysShowAimKey:
             gui_event_dispatcher.toggleCrosshairVisibility()
             return True
         if self.__showMarkersKey is not None and key == self.__showMarkersKey and not self.__isGUIVisible:
             gui_event_dispatcher.toggleMarkers2DVisibility()
             return True
         if key == Keys.KEY_F5 and constants.HAS_DEV_RESOURCES:
             self.__vertScreenshotCamera.enable(not self.__vertScreenshotCamera.isEnabled)
             return True
     if self.__curCtrl.handleKeyEvent(isDown, key, mods, event):
         return True
     else:
         return BigWorld.player().handleKey(isDown, key, mods)