Ejemplo n.º 1
0
    def onGameLoad(self, argsList=None, bForceReinit=False, bShowPopup=True):
        # Remove any running mod components
        bDoUnInit = bForceReinit or RevInstances.bIsInitialized
        bDoInit = bDoUnInit or not RevInstances.bIsInitialized
        if bDoUnInit:
            if not RevInstances.BarbarianCivInst == None:
                RevInstances.BarbarianCivInst.removeEventHandlers()
                RevInstances.BarbarianCivInst = None
            if not RevInstances.RevolutionInst == None:
                RevEvents.removeEventHandlers()
                RevInstances.RevolutionInst.removeEventHandlers()
                RevInstances.RevolutionInst = None
            if not RevInstances.AIAutoPlayInst == None:
                RevInstances.AIAutoPlayInst.removeEventHandlers()
                RevInstances.AIAutoPlayInst = None
            if not RevInstances.ChangePlayerInst == None:
                RevInstances.ChangePlayerInst.removeEventHandlers()
                RevInstances.ChangePlayerInst = None

            RevInstances.bIsInitialized = False

        # Initialize mod components
        if bDoInit:
            RevInstances.bIsInitialized = True

            bAIAutoPlay = RevOpt.isAIAutoPlayEnable()
            if bAIAutoPlay:
                RevInstances.AIAutoPlayInst = AIAutoPlay.AIAutoPlay(
                    self.customEM, self.RevOpt)

            if not GAME.isOption(GameOptionTypes.GAMEOPTION_NO_BARBARIAN_CIV):
                RevInstances.BarbarianCivInst = BarbarianCiv.BarbarianCiv(
                    self.customEM, self.RevOpt)

            bChangePlayer = RevOpt.isChangePlayerEnable()
            if bChangePlayer:
                RevInstances.ChangePlayerInst = ChangePlayer.ChangePlayer(
                    self.customEM, self.RevOpt)

            if not GAME.isOption(GameOptionTypes.GAMEOPTION_NO_REVOLUTION):
                # RevEvents needs to service beginPlayerTurn events before Revolution
                RevEvents.init(self.customEM, self.RevOpt)
                RevInstances.RevolutionInst = Revolution.Revolution(
                    self.customEM, self.RevOpt)

        if bShowPopup and self.bShowActivePopup and self.bFirst:
            self.showActivePopup()
            self.bFirst = False

        if bDoInit:
            CyInterface().setDirty(InterfaceDirtyBits.MiscButtons_DIRTY_BIT,
                                   True)
            CyInterface().setDirty(InterfaceDirtyBits.CityScreen_DIRTY_BIT,
                                   True)
            CyInterface().setDirty(InterfaceDirtyBits.MiscButtons_DIRTY_BIT,
                                   True)
Ejemplo n.º 2
0
    def onGameLoad(self, argsList, bForceReinit=False, bShowPopup=True):

        # Remove any running mod components
        bDoUnInit = (bForceReinit or RevInstances.bIsInitialized)
        bDoInit = (bDoUnInit or not RevInstances.bIsInitialized)

        if (bDoUnInit):
            print "PY:  Uninitializing Revolution Mod components"

            if (not RevInstances.AIAutoPlayInst == None):
                RevInstances.AIAutoPlayInst.removeEventHandlers()
                RevInstances.AIAutoPlayInst = None

            RevInstances.bIsInitialized = False

        # Initialize mod components
        if (bDoInit):
            print "PY:  Initializing Revolution Mod components"
            RevInstances.bIsInitialized = True

        revComponentsText = "AIAutoPlay mod running with the following components: <color=0,255,0,255>on<color=255,255,255,255>/<color=255,0,0,255>off\n"

        if (self.config.getboolean("AIAutoPlay", "Enable", True)):
            if (bDoInit):
                RevInstances.AIAutoPlayInst = AIAutoPlay.AIAutoPlay(
                    self.customEM, self.config)
            revComponentsText += "<color=0,255,0,255>" + "\nAIAutoPlay"
        else:
            revComponentsText += "<color=255,0,0,255>" + "\nAIAutoPlay"

        revComponentsText += "<color=255,255,255,255>"
        self.revComponentsText = revComponentsText

        if (bShowPopup and self.bShowActivePopup):
            self.showActivePopup()

        if (not self.bFoundConfig):
            popup = PyPopup.PyPopup()
            bodStr = "WARNING:  " + self.configFileName + " not found!  Revolution components using default settings."
            bodStr += "  Check mod installation directory, should be:\n\n" + CvPath.installActiveModDir
            bodStr += "\n\nOr:\n\n" + CvPath.userActiveModDir
            popup.setBodyString(bodStr)
            popup.launch()

        if (bDoInit):
            CyInterface().setDirty(InterfaceDirtyBits.MiscButtons_DIRTY_BIT,
                                   True)
            CyInterface().setDirty(InterfaceDirtyBits.CityScreen_DIRTY_BIT,
                                   True)
            CyInterface().setDirty(InterfaceDirtyBits.MiscButtons_DIRTY_BIT,
                                   True)
Ejemplo n.º 3
0
def configure(logging=None, noLogEvents=None):
    # """Sets the global event manager's logging options."""
    # if g_eventManager:
    # g_eventManager.setLogging(logging)
    # g_eventManager.setNoLogEvents(noLogEvents)
    # else:
    # BugUtil.error("BugEventManager - BugEventManager not setup before configure()")
    # K-Mod. I've expanded the purpose of this function.
    """Sets the global event manager's logging options. And registers some BUG events handlers."""

    if not g_eventManager:
        BugUtil.error(
            "BugEventManager - BugEventManager not setup before configure()")
        return

    g_eventManager.setLogging(logging)
    g_eventManager.setNoLogEvents(noLogEvents)

    # K-Mod. Don't use register BUG events for PitBoss host.
    # (Note: actually, if this is a PitBoss host, this function won't even be called
    #  because the BUG core will not initialize any mod components in PitBoss mode.)
    if CyGame().isPitbossHost():
        BugUtil.debug(
            "BugEventManager - skipping event registration for PitBoss host")
        return
    # K-Mod end

    # --------- Better BTS AI (2/2) (moved by K-Mod) -------------
    # K-Mod, only enable these features if the cheat mode is enabled.
    #if getChtLvl():
    # advc.127: Replacing the above. ChtLvl is always 0 in multiplayer.
    if getChtLvl() or (CyGame().isGameMultiPlayer()
                       and gc.getDefineINT("ENABLE_AUTOPLAY_MULTIPLAYER") > 0):
        AIAutoPlay.AIAutoPlay(g_eventManager)
        ChangePlayer.ChangePlayer(g_eventManager)
        Tester.Tester(g_eventManager)

    # advc.106c: Changed OnLoad handler
    g_eventManager.addEventHandler("kbdEvent", g_eventManager.onKbdEvent)
    g_eventManager.addEventHandler("OnLoad",
                                   g_eventManager.resetActiveTurnAfterLoad)
    g_eventManager.addEventHandler("GameStart", g_eventManager.resetActiveTurn)
    g_eventManager.addEventHandler("gameUpdate", g_eventManager.onGameUpdate)
Ejemplo n.º 4
0
def configure(logging=None, noLogEvents=None):
    # """Sets the global event manager's logging options."""
    # if g_eventManager:
    # g_eventManager.setLogging(logging)
    # g_eventManager.setNoLogEvents(noLogEvents)
    # else:
    # BugUtil.error("BugEventManager - BugEventManager not setup before configure()")
    # K-Mod. I've expanded the purpose of this function.
    """Sets the global event manager's logging options. And registers some BUG events handlers."""

    if not g_eventManager:
        BugUtil.error(
            "BugEventManager - BugEventManager not setup before configure()")
        return

    g_eventManager.setLogging(logging)
    g_eventManager.setNoLogEvents(noLogEvents)

    # K-Mod. Don't use register BUG events for PitBoss host.
    # (Note: actually, if this is a PitBoss host, this function won't even be called
    #  because the BUG core will not initialize any mod components in PitBoss mode.)
    if CyGame().isPitbossHost():
        BugUtil.debug(
            "BugEventManager - skipping event registration for PitBoss host")
        return
    # K-Mod end

    # --------- Better BTS AI (2/2) (moved by K-Mod) -------------
    AIAutoPlay.AIAutoPlay(g_eventManager)
    ChangePlayer.ChangePlayer(g_eventManager)
    Tester.Tester(g_eventManager)

    # advc.106c: Changed OnLoad handler
    g_eventManager.addEventHandler("kbdEvent", g_eventManager.onKbdEvent)
    g_eventManager.addEventHandler("OnLoad",
                                   g_eventManager.resetActiveTurnAfterLoad)
    g_eventManager.addEventHandler("GameStart", g_eventManager.resetActiveTurn)
    g_eventManager.addEventHandler("gameUpdate", g_eventManager.onGameUpdate)
Ejemplo n.º 5
0
    def onGameLoad(self, argsList, bForceReinit=False, bShowPopup=True):
        # Remove any running mod components
        bDoUnInit = (bForceReinit or RevInstances.bIsInitialized)
        bDoInit = (bDoUnInit or not RevInstances.bIsInitialized)

        if (bDoUnInit):
            print "PY:  Uninitializing Revolution Mod components"

            if (not RevInstances.BarbarianCivInst == None):
                RevInstances.BarbarianCivInst.removeEventHandlers()
                RevInstances.BarbarianCivInst = None
            if (not RevInstances.RevolutionInst == None):
                RevEvents.removeEventHandlers()
                RevInstances.RevolutionInst.removeEventHandlers()
                RevInstances.RevolutionInst = None
            if (not RevInstances.DynamicCivNamesInst == None):
                RevInstances.DynamicCivNamesInst.removeEventHandlers()
                RevInstances.DynamicCivNamesInst = None
            if (not RevInstances.TechDiffusionInst == None):
                RevInstances.TechDiffusionInst.removeEventHandlers()
                RevInstances.TechDiffusionInst = None
            if (not RevInstances.AIAutoPlayInst == None):
                RevInstances.AIAutoPlayInst.removeEventHandlers()
                RevInstances.AIAutoPlayInst = None
#			if( not RevInstances.TesterInst == None ) :
#				RevInstances.TesterInst.removeEventHandlers()
#				RevInstances.TesterInst = None
            if (not RevInstances.ChangePlayerInst == None):
                RevInstances.ChangePlayerInst.removeEventHandlers()
                RevInstances.ChangePlayerInst = None

            RevInstances.bIsInitialized = False

        # Initialize mod components
        if (bDoInit):
            print "PY:  Initializing Revolution Mod components"
            RevInstances.bIsInitialized = True

        # This component mainly contains test and debug routines
#		if( bDoInit ) : RevInstances.TesterInst = Tester.Tester( self.customEM, self.RevOpt )

### RevolutionDCM start
        bAIAutoPlay = RevOpt.isAIAutoPlayEnable()
        if (bAIAutoPlay):
            if (bDoInit):
                RevInstances.AIAutoPlayInst = AIAutoPlay.AIAutoPlay(
                    self.customEM, self.RevOpt)
#		if( not game.isOption(GameOptionTypes.GAMEOPTION_NO_BARBARIAN_CIV) ):#self.config.getboolean("BarbarianCiv", "Enable", True) ) :
#		if( game.isOption(GameOptionTypes.GAMEOPTION_REVOLUTIONS) ):#self.config.getboolean("BarbarianCiv", "Enable", True) ) :
#			if( bDoInit ) :
#				RevInstances.BarbarianCivInst = BarbarianCiv.BarbarianCiv(self.customEM, self.RevOpt)
        bChangePlayer = RevOpt.isChangePlayerEnable()
        if (bChangePlayer):
            if (bDoInit):
                RevInstances.ChangePlayerInst = ChangePlayer.ChangePlayer(
                    self.customEM, self.RevOpt)
        if (game.isOption(GameOptionTypes.GAMEOPTION_REVOLUTIONS)
            ):  #self.config.getboolean("Revolution", "Enable", True) ) :
            if (bDoInit):
                # RevEvents needs to service beginPlayerTurn events before Revolution
                RevEvents.init(self.customEM, self.RevOpt)
                RevInstances.RevolutionInst = Revolution.Revolution(
                    self.customEM, self.RevOpt)
#		if( not game.isOption(GameOptionTypes.GAMEOPTION_NO_TECH_DIFFUSION) ):#self.config.getboolean("TechDiffusion", "Enable", True) ) :
        if (game.isOption(GameOptionTypes.GAMEOPTION_ADVANCED_TACTICS)):
            if (bDoInit):
                RevInstances.TechDiffusionInst = TechDiffusion.TechDiffusion(
                    self.customEM, self.RevOpt)
#		if( game.isOption(GameOptionTypes.GAMEOPTION_START_AS_MINORS) ):
#			if( bDoInit ) :
#				StartAsMinors.init( self.customEM, self.RevOpt )
# lfgr enabled
        if (ScoreOpt.isDYNAMIC_CIV_NAMES()
            ):  #self.config.getboolean("DynamicCivNames", "Enable", True) ) :
            if (bDoInit):
                print "About to init DynamicCivNames"
                RevInstances.DynamicCivNamesInst = DynamicCivNames.DynamicCivNames(
                    self.customEM, self.RevOpt)
        ### RevolutionDCM end

        if (bShowPopup and self.bShowActivePopup):
            self.showActivePopup()

        if (bDoInit):
            CyInterface().setDirty(InterfaceDirtyBits.MiscButtons_DIRTY_BIT,
                                   True)
            CyInterface().setDirty(InterfaceDirtyBits.CityScreen_DIRTY_BIT,
                                   True)
            CyInterface().setDirty(InterfaceDirtyBits.MiscButtons_DIRTY_BIT,
                                   True)