Beispiel #1
0
	def onShortcutHandler(self, argsList):
		"""Handles onKbdEvent by firing the keystroke's handler if it has one registered."""
		eventType, key, mx, my, px, py = argsList
		if eventType == 6: # Key down
			if not InputUtil.isModifier(key):
				stroke = InputUtil.Keystroke(key, self.bAlt, self.bCtrl, self.bShift)
				if stroke in self.shortcuts:
					if DebugUtils.bDebugMode:
						print "BugEventManager - calling handler for shortcut %s"
					self.shortcuts[stroke](argsList)
		return 0
	def onKbdEvent(self, argsList):
		"""Handles onKbdEvent by firing the keystroke's handler if it has one registered.
		"""
		eventType, key, mx, my, px, py = argsList
		if eventType == self.EventKeyDown:
			if not InputUtil.isModifier(key):
				stroke = InputUtil.Keystroke(key, self.bAlt, self.bCtrl, self.bShift)
				if stroke in self.shortcuts:
					BugUtil.debug("BugEventManager - calling handler for shortcut %s", stroke)
					self.shortcuts[stroke](argsList)
					return 1
		return 0
Beispiel #3
0
 def onKbdEvent(self, argsList):
     """
     Handles onKbdEvent by firing the keystroke's handler if it has one registered.
     """
     eventType, key, mx, my, px, py = argsList
     if eventType == self.EventKeyDown:
         if not InputUtil.isModifier(key):
             stroke = InputUtil.Keystroke(key, self.bAlt, self.bCtrl, self.bShift)
             if stroke in self.shortcuts:
                 BugUtil.debug("BugEventManager - calling handler for shortcut %s", stroke)
                 self.shortcuts[stroke](argsList)
                 return 1
     return 0
Beispiel #4
0
    def onKbdEvent(self, argsList):
        """
		Handles onKbdEvent by firing the keystroke's handler if it has one registered.
		"""
        eventType, key, mx, my, px, py = argsList
        if eventType == self.EventKeyDown and not InputUtil.isModifier(key):
            # <f1rpo> (advc.007b)
            # Added not bCtrl/bAlt/bShift checks so that each cheat is triggered by only one combination of modifier keys
            theKey = int(key)
            if not self.bShift and self.bCtrl and self.bAlt and theKey == int(
                    InputTypes.KB_R):
                BugUtil.warn(
                    "Note (K-Mod): Reloading of Art Defines (Ctrl+Alt+R) is disabled"
                )
                return 1  # Don't use this key combination for anything else
            # </f1rpo>
            stroke = InputUtil.Keystroke(key, self.bAlt, self.bCtrl,
                                         self.bShift)
            if stroke in self.shortcuts:
                BugUtil.debug(
                    "BugEventManager - calling handler for shortcut %s",
                    stroke)
                self.shortcuts[stroke](argsList)
                return 1
            # <f1rpo> (advc.007b) Cheats copied from CvEventManager
            if gc.getGame().isDebugMode():
                # Shift - T Debug - techs
                if self.bShift and not self.bCtrl and not self.bAlt and theKey == int(
                        InputTypes.KB_T):
                    self.beginEvent(CvUtil.EventAwardTechsAndGold)
                    return 1
                elif self.bShift and self.bCtrl and not self.bAlt and theKey == int(
                        InputTypes.KB_W):
                    self.beginEvent(CvUtil.EventShowWonder)
                    return 1
                # Shift - ] Debug - currently mouse-over'd unit: health+=10
                elif theKey == int(
                        InputTypes.KB_LBRACKET
                ) and self.bShift and not self.bCtrl and not self.bAlt:
                    unit = CyMap().plot(px, py).getUnit(0)
                    if not unit.isNone():
                        d = min(unit.maxHitPoints() - 1, unit.getDamage() + 10)
                        unit.setDamage(d, PlayerTypes.NO_PLAYER)
                # Shift - [ Debug - currently mouse-over'd unit: health-= 10
                elif theKey == int(
                        InputTypes.KB_RBRACKET
                ) and self.bShift and not self.bCtrl and not self.bAlt:
                    unit = CyMap().plot(px, py).getUnit(0)
                    if not unit.isNone():
                        d = max(0, unit.getDamage() - 10)
                        unit.setDamage(d, PlayerTypes.NO_PLAYER)
                # <advc.gfd> Keep Nightinggale's key combination
                elif theKey == int(
                        InputTypes.KB_F1
                ) and self.bShift and self.bCtrl and not self.bAlt:
                    GameFontDisplay.GameFontDisplay().interfaceScreen()
                    return 1  # </advc.gfd>
                elif theKey == int(InputTypes.KB_F1):
                    if self.bShift and not self.bCtrl and not self.bAlt:
                        CvScreensInterface.replayScreen.showScreen(False)
                        return 1
                elif theKey == int(InputTypes.KB_F2):
                    if self.bShift and not self.bCtrl and not self.bAlt:
                        import CvDebugInfoScreen
                        CvScreensInterface.showDebugInfoScreen()
                        return 1
                elif theKey == int(InputTypes.KB_F3):
                    if self.bShift and not self.bCtrl and not self.bAlt:
                        CvScreensInterface.showDanQuayleScreen(())
                        return 1
                elif theKey == int(InputTypes.KB_F4):
                    if self.bShift and not self.bCtrl and not self.bAlt:
                        CvScreensInterface.showUnVictoryScreen(())
                        return 1
                # </f1rpo>
        return 0
    def onKbdEvent(self, argsList):
        'keypress handler - return 1 if the event was consumed'
        """
        Handles onKbdEvent by firing the keystroke's handler if it has one registered.
        """

        eventType, key, mx, my, px, py = argsList
        game = gc.getGame()

        # if self.bAllowCheats:
        if gc.getGame().isDebugMode():
            # notify debug tools of input to allow it to override the control
            argsList = (eventType, key, self.bCtrl, self.bShift, self.bAlt, mx,
                        my, px, py, game.isNetworkMultiPlayer())
            if CvDebugTools.g_CvDebugTools.notifyInput(argsList):
                return 0

        if eventType == self.EventKeyDown and not InputUtil.isModifier(key):
            theKey = int(key)
            # <f1rpo> (advc.007b)
            # Added not bCtrl/bAlt/bShift checks so that each cheat is triggered by only one combination of modifier keys
            if not self.bShift and self.bCtrl and self.bAlt and theKey == int(
                    InputTypes.KB_R):
                BugUtil.warn(
                    "Note (K-Mod): Reloading of Art Defines (Ctrl+Alt+R) is disabled"
                )
                return 1  # Don't use this key combination for anything else
            # </f1rpo>

            stroke = InputUtil.Keystroke(key, self.bAlt, self.bCtrl,
                                         self.bShift)
            if stroke in self.shortcuts:
                BugUtil.debug(
                    "BugEventManager - calling handler for shortcut %s",
                    stroke)
                self.shortcuts[stroke](argsList)
                return 1

            # From FfH-Mod: by Kael 07/05/2008
            if theKey == int(InputTypes.KB_LEFT):
                if self.bCtrl:
                    CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 45.0)
                    return 1
                elif self.bShift:
                    CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 10.0)
                    return 1

            if theKey == int(InputTypes.KB_RIGHT):
                if self.bCtrl:
                    CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 45.0)
                    return 1
                elif self.bShift:
                    CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 10.0)
                    return 1
            # From FfH: End

            # PAE Spieler am Zug Message aktivieren/deaktvieren: STRG+P / CTRL+P --
            if theKey == int(InputTypes.KB_P):
                if self.bCtrl:
                    if self.bPAE_ShowMessagePlayerTurn:
                        self.bPAE_ShowMessagePlayerTurn = False
                        CyInterface().addMessage(
                            gc.getGame().getActivePlayer(), True, 5,
                            CyTranslator().getText(
                                "TXT_KEY_MESSAGE_PAE_CIV_TURN_DEACTIVATED",
                                ("", )), None, 2, None, ColorTypes(14), 0, 0,
                            False, False)
                    else:
                        self.bPAE_ShowMessagePlayerTurn = True
                        self.iPAE_ShowMessagePlayerHumanID = gc.getGame(
                        ).getActivePlayer()
                        CyInterface().addMessage(
                            gc.getGame().getActivePlayer(), True, 5,
                            CyTranslator().getText(
                                "TXT_KEY_MESSAGE_PAE_CIV_TURN_ACTIVATED",
                                ("", )), None, 2, None, ColorTypes(14), 0, 0,
                            False, False)
                    return 1

            CvCameraControls.g_CameraControls.handleInput(theKey)

            ## AI AutoPlay ##
            if CyGame().getAIAutoPlay():
                if theKey == int(InputTypes.KB_SPACE) or theKey == int(
                        InputTypes.KB_ESCAPE):
                    CyGame().setAIAutoPlay(0)
                    return 1
            ## AI AutoPlay ##

            # <f1rpo> (advc.007b) Cheats copied from CvEventManager
            # if self.bAllowCheats:
            if gc.getGame().isDebugMode():
                # Shift - T (Debug - No MP)
                if self.bShift and not self.bCtrl and not self.bAlt and theKey == int(
                        InputTypes.KB_T):
                    self.beginEvent(CvUtil.EventAwardTechsAndGold)
                    return 1
                if self.bShift and self.bCtrl and not self.bAlt and theKey == int(
                        InputTypes.KB_W):
                    self.beginEvent(CvUtil.EventShowWonder)
                    return 1
                # Shift - ] Debug - currently mouse-over'd unit, health += 10
                elif theKey == int(
                        InputTypes.KB_LBRACKET
                ) and self.bShift and not self.bCtrl and not self.bAlt:
                    unit = CyMap().plot(px, py).getUnit(0)
                    if not unit.isNone():
                        d = min(unit.maxHitPoints() - 1, unit.getDamage() + 10)
                        unit.setDamage(d, PlayerTypes.NO_PLAYER)
                # Shift - [ Debug - currently mouse-over'd unit, health -= 10
                elif theKey == int(
                        InputTypes.KB_RBRACKET
                ) and self.bShift and not self.bCtrl and not self.bAlt:
                    unit = CyMap().plot(px, py).getUnit(0)
                    if not unit.isNone():
                        d = max(0, unit.getDamage() - 10)
                        unit.setDamage(d, PlayerTypes.NO_PLAYER)
                # <advc.gfd> Keep Nightinggale's key combination
                elif theKey == int(
                        InputTypes.KB_F1
                ) and self.bShift and self.bCtrl and not self.bAlt:
                    GameFontDisplay.GameFontDisplay().interfaceScreen()
                    return 1  # </advc.gfd>
                elif theKey == int(InputTypes.KB_F1):
                    if self.bShift and self.bAlt:
                        CyInterface().addImmediateMessage(
                            "BEGIN Python file optimization", "")
                        import ResolveConstantFunctions
                        ResolveConstantFunctions.main(True)
                        CyInterface().addImmediateMessage(
                            "END Python file optimization", "")
                        return 1
                    elif self.bShift and not self.bCtrl and not self.bAlt:
                        CvScreensInterface.replayScreen.showScreen(False)
                        return 1
                    # don't return 1 unless you want the input consumed

                elif theKey == int(InputTypes.KB_F2):
                    if self.bShift and not self.bCtrl and self.bAlt:
                        import remote_pdb
                        remote_pdb.RemotePdb("127.0.0.1", 4444).set_trace()
                        return 1
                    elif self.bShift and not self.bCtrl and not self.bAlt:
                        import CvDebugInfoScreen
                        CvScreensInterface.showDebugInfoScreen()
                        return 1
                elif theKey == int(InputTypes.KB_F3):
                    if self.bShift and not self.bCtrl and not self.bAlt:
                        CvScreensInterface.showDanQuayleScreen(())
                        return 1
                elif theKey == int(InputTypes.KB_F4):
                    if self.bShift and not self.bCtrl and not self.bAlt:
                        CvScreensInterface.showUnVictoryScreen(())
                        return 1
                # </f1rpo>
        return 0