def onGameStart(self, argsList):
                'Called at the start of the game'
		
		sd.setup() # edead
                self.rnf.setup()
                self.rel.setup()
                self.pla.setup()
		self.dc.setup()
                self.aiw.setup()
		
		vic.setup()
		cong.setup()
		
		# area debug
		#sContinentDebug = ""
		#for y in range(con.iWorldY-1, 0, -1):
		#	for x in range(con.iWorldX):
		#		sContinentDebug += str(gc.getMap().plot(x, y).getArea()) + ", "
		#	sContinentDebug += "\n"
		##print sContinentDebug
		
		# Leoreth: set DLL core values
		for x in range(124):
			for y in range(68):
				plot = gc.getMap().plot(x, y)
				if plot.isWater(): continue
				for iPlayer in range(con.iNumPlayers):
					if utils.isPlotInArea((x, y), con.tCoreAreasTL[0][iPlayer], con.tCoreAreasBR[0][iPlayer], con.tExceptions[0][iPlayer]):
						plot.setCore(iPlayer, False, True)
					if utils.isPlotInArea((x, y), con.tCoreAreasTL[1][iPlayer], con.tCoreAreasBR[1][iPlayer], con.tExceptions[1][iPlayer]):
						plot.setCore(iPlayer, True, True)
                
                return 0
Exemple #2
0
    def onChangeWar(self, argsList):
        bWar, iTeam, iOtherTeam = argsList

        sta.onChangeWar(bWar, iTeam, iOtherTeam)
        self.up.onChangeWar(bWar, iTeam, iOtherTeam)

        if iTeam < iNumPlayers and iOtherTeam < iNumPlayers:
            cong.onChangeWar(bWar, iTeam, iOtherTeam)

        # don't start AIWars if they get involved in natural wars
        if bWar and iTeam < iNumPlayers and iOtherTeam < iNumPlayers:
            data.players[iTeam].iAggressionLevel = 0
            data.players[iOtherTeam].iAggressionLevel = 0
	def onChangeWar(self, argsList):
		bWar, iTeam, iOtherTeam = argsList
		
		sta.onChangeWar(bWar, iTeam, iOtherTeam)
		self.up.onChangeWar(bWar, iTeam, iOtherTeam)
		
		if iTeam < iNumPlayers and iOtherTeam < iNumPlayers:
			cong.onChangeWar(bWar, iTeam, iOtherTeam)
		
		# don't start AIWars if they get involved in natural wars
		if bWar and iTeam < iNumPlayers and iOtherTeam < iNumPlayers:
			data.players[iTeam].iAggressionLevel = 0
			data.players[iOtherTeam].iAggressionLevel = 0
	def onChangeWar(self, argsList):
		bWar, iTeam, iOtherTeam, bGlobalWar = argsList
		
		sta.onChangeWar(bWar, iTeam, iOtherTeam)
		self.up.onChangeWar(bWar, iTeam, iOtherTeam)
		
		if iTeam < con.iNumPlayers and iOtherTeam < con.iNumPlayers:
			cong.onChangeWar(argsList)
		
		# don't start AIWars if they get involved in natural wars
		if bWar and iTeam < con.iNumPlayers and iOtherTeam < con.iNumPlayers:
			sd.setAggressionLevel(iTeam, 0)
			sd.setAggressionLevel(iOtherTeam, 0)
    def __init__(self, *args, **kwargs):
        super(CvRFCEventManager, self).__init__(*args, **kwargs)
        # map the initial EventHandlerMap values into the new data structure
        for eventType, eventHandler in self.EventHandlerMap.iteritems():
            self.setEventHandler(eventType, eventHandler)

        self.CustomEvents = {
            7614 : ('RiseAndFallPopupEvent', self.rnfEventApply7614, self.rnfEventBegin7614),
            7615 : ('FlipPopupEvent', self.rnfEventApply7615, self.rnfEventBegin7615),
            7616 : ('VotePopupEvent', self.congEventApply7616, self.congEventBegin7616),
            7617 : ('AskCityPopupEvent', self.congEventApply7617, self.congEventBegin7617),
            7618 : ('DecisionPopupEvent', self.congEventApply7618, self.congEventBegin7618),
            7619 : ('InvitationPopupEvent', self.congEventApply7619, self.congEventBegin7619),
            7620 : ('BribePopupEvent', self.congEventApply7620, self.congEventBegin7620),
            7621 : ('GoldPopupEvent', self.congEventApply7621, self.congEventBegin7621),
            7622 : ('ResurrectionEvent', self.rnfEventApply7622, self.rnfEventBegin7622),
            7623 : ('AskNoCityPopupEvent', self.congEventApply7623, self.congEventBegin7623)
        }

        # --> INSERT EVENT HANDLER INITIALIZATION HERE <--
        CvRFCEventHandler.CvRFCEventHandler(self)
        self.rnf = RiseAndFall.RiseAndFall()
        self.cong = Congresses.Congresses()
        # Fierabras start
        Civ4lerts.Civ4lerts(self)
        def onBeginGameTurn(self, argsList):
                iGameTurn = argsList[0]
                
                self.rnf.checkTurn(iGameTurn)
                self.barb.checkTurn(iGameTurn)
                self.rel.checkTurn(iGameTurn)
                self.res.checkTurn(iGameTurn)
                self.up.checkTurn(iGameTurn)
                self.aiw.checkTurn(iGameTurn)
                self.pla.checkTurn(iGameTurn)
                self.com.checkTurn(iGameTurn)
		self.corp.checkTurn(iGameTurn)
		
		sta.checkTurn(iGameTurn)
		cong.checkTurn(iGameTurn)
		
		if iGameTurn % 10 == 0:
                        self.dc.checkTurn(iGameTurn)
			
                return 0
	def onGameStart(self, argsList):
		'Called at the start of the game'
		
		data.setup()
		
		self.rnf.setup()
		self.pla.setup()
		dc.setup()
		self.aiw.setup()
		
		vic.setup()
		cong.setup()
		
		# Leoreth: set DLL core values
		Modifiers.init()
		Areas.init()
		SettlerMaps.init()
		WarMaps.init()
		RegionMap.init()
		Civilizations.init()
		AIParameters.init()
		
		return 0
Exemple #8
0
    def onBeginGameTurn(self, argsList):
        iGameTurn = argsList[0]

        self.rnf.checkTurn(iGameTurn)
        self.barb.checkTurn(iGameTurn)
        self.rel.checkTurn(iGameTurn)
        self.res.checkTurn(iGameTurn)
        self.up.checkTurn(iGameTurn)
        self.aiw.checkTurn(iGameTurn)
        self.pla.checkTurn(iGameTurn)
        self.com.checkTurn(iGameTurn)
        self.corp.checkTurn(iGameTurn)

        sta.checkTurn(iGameTurn)
        cong.checkTurn(iGameTurn)

        if iGameTurn % 10 == 0:
            dc.checkTurn(iGameTurn)

        if utils.getScenario() == i3000BC and iGameTurn == getTurnForYear(600):
            for iPlayer in range(iVikings):
                Modifiers.adjustInflationModifier(iPlayer)

        return 0
Exemple #9
0
    def onGameStart(self, argsList):
        'Called at the start of the game'

        data.setup()

        self.rnf.setup()
        self.pla.setup()
        dc.setup()
        self.aiw.setup()
        self.up.setup()

        vic.setup()
        cong.setup()

        # Leoreth: set DLL core values
        Modifiers.init()
        Areas.init()
        SettlerMaps.init()
        WarMaps.init()
        RegionMap.init()
        Civilizations.init()
        AIParameters.init()

        return 0
	def onBeginGameTurn(self, argsList):
		iGameTurn = argsList[0]
		
		self.rnf.checkTurn(iGameTurn)
		self.barb.checkTurn(iGameTurn)
		self.rel.checkTurn(iGameTurn)
		self.res.checkTurn(iGameTurn)
		self.up.checkTurn(iGameTurn)
		self.aiw.checkTurn(iGameTurn)
		self.pla.checkTurn(iGameTurn)
		self.com.checkTurn(iGameTurn)
		self.corp.checkTurn(iGameTurn)
		
		sta.checkTurn(iGameTurn)
		cong.checkTurn(iGameTurn)
		
		if iGameTurn % 10 == 0:
			dc.checkTurn(iGameTurn)
			
		if utils.getScenario() == i3000BC and iGameTurn == getTurnForYear(600):
			for iPlayer in range(iVikings):
				Modifiers.adjustInflationModifier(iPlayer)
			
		return 0
Exemple #11
0
    def handleInput(self, inputClass):
        screen = CyGInterfaceScreen("WBGameDataScreen",
                                    CvScreenEnums.WB_GAMEDATA)
        global iChange
        global bHiddenOption
        global bRepeat
        global iSelectedCiv
        global iSelectedLeader
        global bRemove

        if inputClass.getFunctionName() == "CurrentPage":
            iIndex = screen.getPullDownData(
                "CurrentPage", screen.getSelectedPullDownID("CurrentPage"))
            if iIndex == 8:
                WBReligionScreen.WBReligionScreen().interfaceScreen(
                    self.top.m_iCurrentPlayer)
            elif iIndex == 9:
                WBCorporationScreen.WBCorporationScreen().interfaceScreen(
                    self.top.m_iCurrentPlayer)
            elif iIndex == 11:
                WBInfoScreen.WBInfoScreen().interfaceScreen(
                    self.top.m_iCurrentPlayer)
            elif iIndex == 12:
                WBStoredDataScreen.WBStoredDataScreen(
                    self.top).interfaceScreen()
            elif iIndex == 13:
                WBPlayerEnabledScreen.WBPlayerEnabledScreen(
                    self.top).interfaceScreen()

        elif inputClass.getFunctionName() == "ChangeBy":
            if bRemove:
                iChange = -screen.getPullDownData(
                    "ChangeBy", screen.getSelectedPullDownID("ChangeBy"))
            else:
                iChange = screen.getPullDownData(
                    "ChangeBy", screen.getSelectedPullDownID("ChangeBy"))

        elif inputClass.getFunctionName() == "ChangeType":
            bRemove = not bRemove
            iChange = -iChange

        elif inputClass.getFunctionName().find("StartYear") > -1:
            if inputClass.getData1() == 1030:
                CyGame().setStartYear(CyGame().getStartYear() + abs(iChange))
            elif inputClass.getData1() == 1031:
                CyGame().setStartYear(CyGame().getStartYear() - abs(iChange))
            self.placeStats()

        elif inputClass.getFunctionName().find("MaxCityElimination") > -1:
            if inputClass.getData1() == 1030:
                CyGame().setMaxCityElimination(
                    CyGame().getMaxCityElimination() + abs(iChange))
            elif inputClass.getData1() == 1031:
                CyGame().setMaxCityElimination(
                    max(0,
                        CyGame().getMaxCityElimination() - abs(iChange)))
            self.placeStats()

        elif inputClass.getFunctionName().find("GameTurn") > -1:
            if inputClass.getData1() == 1030:
                iChange = min(
                    abs(iChange),
                    CyGame().getMaxTurns() - CyGame().getElapsedGameTurns())
                CyGame().setGameTurn(CyGame().getGameTurn() + iChange)
                CyGame().changeMaxTurns(-iChange)
            elif inputClass.getData1() == 1031:
                iChange = min(CyGame().getGameTurn(), abs(iChange))
                CyGame().setGameTurn(CyGame().getGameTurn() - iChange)
                CyGame().changeMaxTurns(iChange)
            self.placeStats()

        elif inputClass.getFunctionName().find("TargetScore") > -1:
            if inputClass.getData1() == 1030:
                CyGame().setTargetScore(CyGame().getTargetScore() +
                                        abs(iChange))
            elif inputClass.getData1() == 1031:
                CyGame().setTargetScore(
                    max(0,
                        CyGame().getTargetScore() - abs(iChange)))
            self.placeStats()

        elif inputClass.getFunctionName().find("EstimateEndTurn") > -1:
            if inputClass.getData1() == 1030:
                CyGame().setEstimateEndTurn(CyGame().getEstimateEndTurn() +
                                            iChange)
            elif inputClass.getData1() == 1031:
                CyGame().setEstimateEndTurn(
                    max(0,
                        CyGame().getEstimateEndTurn() - iChange))
            self.placeStats()

        elif inputClass.getFunctionName().find("NukesExploded") > -1:
            if inputClass.getData1() == 1030:
                CyGame().changeNukesExploded(abs(iChange))
            elif inputClass.getData1() == 1031:
                CyGame().changeNukesExploded(
                    -min(CyGame().getNukesExploded(), abs(iChange)))
            self.placeStats()

        elif inputClass.getFunctionName().find("MaxTurns") > -1:
            if inputClass.getData1() == 1030:
                CyGame().changeMaxTurns(abs(iChange))
            elif inputClass.getData1() == 1031:
                CyGame().changeMaxTurns(
                    -min(CyGame().getMaxTurns(), abs(iChange)))
            self.placeStats()

        elif inputClass.getFunctionName().find("TradeRoutes") > -1:
            if inputClass.getData1() == 1030:
                CyGame().changeTradeRoutes(
                    min(
                        abs(iChange),
                        gc.getDefineINT("MAX_TRADE_ROUTES") -
                        gc.getDefineINT("INITIAL_TRADE_ROUTES") -
                        CyGame().getTradeRoutes()))
            elif inputClass.getData1() == 1031:
                CyGame().changeTradeRoutes(
                    -min(CyGame().getTradeRoutes(), abs(iChange)))
            self.placeStats()

        elif inputClass.getFunctionName().find("AIAutoPlay") > -1:
            if inputClass.getData1() == 1030:
                CyGame().setAIAutoPlay(CyGame().getAIAutoPlay() + abs(iChange))
            elif inputClass.getData1() == 1031:
                CyGame().setAIAutoPlay(
                    max(0,
                        CyGame().getAIAutoPlay() - abs(iChange)))
            self.placeStats()

        elif inputClass.getFunctionName() == "WBGameOptions":
            iGameOption = inputClass.getData2()
            if iGameOption < gc.getNumGameOptionInfos():
                CyGame().setOption(iGameOption,
                                   not CyGame().isOption(iGameOption))
                self.checkOptions(iGameOption)
            else:
                # Enabling/disabling secondary civs
                if iGameOption < 2000:
                    iItem = iGameOption - 1000
                    data.setPlayerEnabled(iItem,
                                          not data.isPlayerEnabled(iItem))
                # Enabling/disabling RFC options
                elif iGameOption == 2000:
                    data.bIgnoreAI = not data.bIgnoreAI
                elif iGameOption == 2001:
                    data.bUnlimitedSwitching = not data.bUnlimitedSwitching
                elif iGameOption == 2002:
                    data.bNoCongressOption = not data.bNoCongressOption
                elif iGameOption == 2003:
                    data.bNoPlagues = not data.bNoPlagues
                # Stored Variables
                elif iGameOption == 3001:
                    data.bAlreadySwitched = not data.bAlreadySwitched
                elif iGameOption == 3002 and cong.isCongressEnabled():
                    data.iCongressTurns = max(1, data.iCongressTurns + iChange)
            self.placeGameOptions()

        elif inputClass.getFunctionName() == "HiddenOptions":
            bHiddenOption = not bHiddenOption
            self.placeGameOptions()

        elif inputClass.getFunctionName() == "AllowsRepeat":
            bRepeat = not bRepeat
            iSelectedCiv = -1
            iSelectedLeader = -1
            self.placeNewPlayer()

        elif inputClass.getFunctionName() == "WBNewCiv":
            iSelectedCiv = inputClass.getData2()
            iSelectedLeader = -1
            self.interfaceScreen()

        elif inputClass.getFunctionName() == "WBNewLeader":
            iSelectedLeader = inputClass.getData2()
            self.interfaceScreen()

        elif inputClass.getFunctionName() == "CreatePlayer":
            for i in xrange(gc.getMAX_CIV_PLAYERS()):
                if not gc.getPlayer(i).isEverAlive():
                    CyGame().addPlayer(i, iSelectedLeader, iSelectedCiv)
                    break
            screen.hideScreen()
            self.top.m_iCurrentPlayer = i
            self.top.normalPlayerTabModeCB()

        elif inputClass.getFunctionName() == "GameEditScriptData":
            popup = Popup.PyPopup(4444, EventContextTypes.EVENTCONTEXT_ALL)
            popup.setHeaderString(CyTranslator().getText(
                "TXT_KEY_WB_SCRIPT", ()))
            popup.createEditBox(CyGame().getScriptData())
            popup.launch()

        return 1
Exemple #12
0
    def placeGameOptions(self):
        screen = CyGInterfaceScreen("WBGameDataScreen",
                                    CvScreenEnums.WB_GAMEDATA)
        sColor = CyTranslator().getText("[COLOR_WARNING_TEXT]", ())
        if bHiddenOption:
            sColor = CyTranslator().getText("[COLOR_POSITIVE_TEXT]", ())
        screen.setText(
            "HiddenOptions", "Background", "<font=3b>" + sColor +
            CyTranslator().getText("TXT_KEY_WB_SHOW_HIDDEN",
                                   ()) + "</color></font>",
            CvUtil.FONT_RIGHT_JUSTIFY,
            screen.getXResolution() - 20, self.iGameOption_Y - 30, -0.1,
            FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
        iWidth = screen.getXResolution() - 40
        iHeight = (screen.getYResolution() - self.iGameOption_Y -
                   40) / 24 * 24 + 2
        nColumns = 3
        iWidth1 = 80
        iWidth2 = iWidth / nColumns - iWidth1
        screen.addTableControlGFC("WBGameOptions", nColumns * 2, 20,
                                  self.iGameOption_Y, iWidth, iHeight, False,
                                  False, 24, 24,
                                  TableStyles.TABLE_STYLE_STANDARD)
        for i in xrange(nColumns):
            screen.setTableColumnHeader("WBGameOptions", i * 2, "", iWidth2)
            screen.setTableColumnHeader("WBGameOptions", i * 2 + 1, "",
                                        iWidth1)

        lList = []
        for item in xrange(gc.getNumGameOptionInfos()):
            Info = gc.getGameOptionInfo(item)
            if Info.getVisible() or bHiddenOption:
                lList.append([Info.getDescription(), item])
        lList.sort()

        # Merijn: Add extra DoC options
        lList2 = []
        lList2.append(
            [CyTranslator().getText("TXT_KEY_WB_IGNORE_AI_UHV", ()), 2000])
        lList2.append([
            CyTranslator().getText("TXT_KEY_WB_UNLIMITED_SWITCHING", ()), 2001
        ])
        lList2.append(
            [CyTranslator().getText("TXT_KEY_WB_NO_CONGRESS", ()), 2002])
        lList2.append(
            [CyTranslator().getText("TXT_KEY_WB_NO_PLAGUE", ()), 2003])
        lList2.sort()

        # Stored variables
        lList3 = []
        lList3.append(
            [CyTranslator().getText("TXT_KEY_WB_ALREADY_SWITCHED", ()), 3001])
        lList3.append(
            [CyTranslator().getText("TXT_KEY_WB_CONGRESS_TURNS", ()), 3002])
        lList3.sort()

        iNumRows = (len(lList) + nColumns - 1) / nColumns
        iNumRows2 = iNumRows + 3 + max(len(lSecondaryCivs), len(lList2),
                                       len(lList3))
        for i in xrange(iNumRows2):
            screen.appendTableRow("WBGameOptions")

        for i in xrange(len(lList)):
            iColumn = i / iNumRows
            iRow = i % iNumRows
            item = lList[i][1]

            bEnabled = CyGame().isOption(item)
            bDefault = False
            if item in [6, 11]:  # Aggressive AI, No Tech Brokering
                bDefault = True

            sText = self.colorText(lList[i][0], bEnabled)
            screen.setTableText("WBGameOptions", iColumn * 2, iRow, sText, "",
                                WidgetTypes.WIDGET_PYTHON, 1028, item,
                                CvUtil.FONT_LEFT_JUSTIFY)
            sText = self.colorText(
                CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault)
            screen.setTableText("WBGameOptions", iColumn * 2 + 1, iRow, sText,
                                "", WidgetTypes.WIDGET_GENERAL, -1, -1,
                                CvUtil.FONT_CENTER_JUSTIFY)

        # Merijn: extra rows for secondary civs and RFC options
        screen.setTableText(
            "WBGameOptions", 0, iNumRows + 2,
            CyTranslator().getText("TXT_KEY_WB_SECONDARY_CIVS", ()), "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
        screen.setTableText(
            "WBGameOptions", 2, iNumRows + 2,
            CyTranslator().getText("TXT_KEY_WB_RFC_OPTIONS", ()), "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
        screen.setTableText(
            "WBGameOptions", 4, iNumRows + 2,
            CyTranslator().getText("TXT_KEY_WB_RFC_VARIABLES", ()), "",
            WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

        iRow = iNumRows + 3
        for iCiv in lSecondaryCivs:
            bEnabled = data.isPlayerEnabled(iCiv)
            bDefault = True
            if iCiv in [iHarappa, iPolynesia]:
                bDefault = False

            sText = self.colorText(
                gc.getPlayer(iCiv).getCivilizationShortDescription(0),
                bEnabled)
            screen.setTableText("WBGameOptions", 0, iRow, sText, "",
                                WidgetTypes.WIDGET_PYTHON, 1028, 1000 + iCiv,
                                CvUtil.FONT_LEFT_JUSTIFY)
            sText = self.colorText(
                CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault)
            screen.setTableText("WBGameOptions", 1, iRow, sText, "",
                                WidgetTypes.WIDGET_GENERAL, -1, -1,
                                CvUtil.FONT_CENTER_JUSTIFY)
            iRow += 1

        for i in xrange(len(lList2)):
            item = lList2[i][1]
            iRow = iNumRows + 3 + i

            bEnabled = False
            bDefault = False

            if item == 2000:
                bEnabled = data.bIgnoreAI
                bDefault = True
            elif item == 2001:
                bEnabled = data.bUnlimitedSwitching
            elif item == 2002:
                bEnabled = data.bNoCongressOption
            elif item == 2003:
                bEnabled = data.bNoPlagues

            sText = self.colorText(lList2[i][0], bEnabled)
            screen.setTableText("WBGameOptions", 2, iRow, sText, "",
                                WidgetTypes.WIDGET_PYTHON, 1028, item,
                                CvUtil.FONT_LEFT_JUSTIFY)
            sText = self.colorText(
                CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault)
            screen.setTableText("WBGameOptions", 3, iRow, sText, "",
                                WidgetTypes.WIDGET_GENERAL, -1, -1,
                                CvUtil.FONT_CENTER_JUSTIFY)

        for i in xrange(len(lList3)):
            item = lList3[i][1]
            iRow = iNumRows + 3 + i

            bEnabled = False
            bWhite = False

            if item == 3001:
                bEnabled = data.bAlreadySwitched
            elif item == 3002:
                bWhite = True

            sText = self.colorText(lList3[i][0], bEnabled, bWhite)
            screen.setTableText("WBGameOptions", 4, iRow, sText, "",
                                WidgetTypes.WIDGET_PYTHON, 1028, item,
                                CvUtil.FONT_LEFT_JUSTIFY)
            if item == 3002:
                if not cong.isCongressEnabled():
                    iTurns = -1
                else:
                    iTurns = data.iCongressTurns
                sText = self.colorText(str(iTurns), True, True)
                screen.setTableText("WBGameOptions", 5, iRow, sText, "",
                                    WidgetTypes.WIDGET_PYTHON, 1028, item,
                                    CvUtil.FONT_CENTER_JUSTIFY)
	def handleInput(self, inputClass):
		screen = CyGInterfaceScreen("WBGameDataScreen", CvScreenEnums.WB_GAMEDATA)
		global iChange
		global bHiddenOption
		global bRepeat
		global iSelectedCiv
		global iSelectedLeader
		global bRemove

		if inputClass.getFunctionName() == "CurrentPage":
			iIndex = screen.getPullDownData("CurrentPage", screen.getSelectedPullDownID("CurrentPage"))
			if iIndex == 8:
				WBReligionScreen.WBReligionScreen().interfaceScreen(self.top.m_iCurrentPlayer)
			elif iIndex == 9:
				WBCorporationScreen.WBCorporationScreen().interfaceScreen(self.top.m_iCurrentPlayer)
			elif iIndex == 11:
				WBInfoScreen.WBInfoScreen().interfaceScreen(self.top.m_iCurrentPlayer)
			elif iIndex == 12:
				WBStoredDataScreen.WBStoredDataScreen(self.top).interfaceScreen()

		elif inputClass.getFunctionName() == "ChangeBy":
			if bRemove:
				iChange = -screen.getPullDownData("ChangeBy", screen.getSelectedPullDownID("ChangeBy"))
			else:
				iChange = screen.getPullDownData("ChangeBy", screen.getSelectedPullDownID("ChangeBy"))

		elif inputClass.getFunctionName() == "ChangeType":
			bRemove = not bRemove
			iChange = -iChange

		elif inputClass.getFunctionName().find("StartYear") > -1:
			if inputClass.getData1() == 1030:
				CyGame().setStartYear(CyGame().getStartYear() + abs(iChange))
			elif inputClass.getData1() == 1031:
				CyGame().setStartYear(CyGame().getStartYear() - abs(iChange))
			self.placeStats()

		elif inputClass.getFunctionName().find("MaxCityElimination") > -1:
			if inputClass.getData1() == 1030:
				CyGame().setMaxCityElimination(CyGame().getMaxCityElimination() + abs(iChange))
			elif inputClass.getData1() == 1031:
				CyGame().setMaxCityElimination(max(0, CyGame().getMaxCityElimination() - abs(iChange)))
			self.placeStats()

		elif inputClass.getFunctionName().find("GameTurn") > -1:
			if inputClass.getData1() == 1030:
				iChange = min(abs(iChange), CyGame().getMaxTurns() - CyGame().getElapsedGameTurns())
				CyGame().setGameTurn(CyGame().getGameTurn() + iChange)
				CyGame().changeMaxTurns(- iChange)
			elif inputClass.getData1() == 1031:
				iChange = min(CyGame().getGameTurn(), abs(iChange))
				CyGame().setGameTurn(CyGame().getGameTurn() - iChange)
				CyGame().changeMaxTurns(iChange)
			self.placeStats()

		elif inputClass.getFunctionName().find("TargetScore") > -1:
			if inputClass.getData1() == 1030:
				CyGame().setTargetScore(CyGame().getTargetScore() + abs(iChange))
			elif inputClass.getData1() == 1031:
				CyGame().setTargetScore(max(0, CyGame().getTargetScore() - abs(iChange)))
			self.placeStats()

		elif inputClass.getFunctionName().find("EstimateEndTurn") > -1:
			if inputClass.getData1() == 1030:
				CyGame().setEstimateEndTurn(CyGame().getEstimateEndTurn() + iChange)
			elif inputClass.getData1() == 1031:
				CyGame().setEstimateEndTurn(max(0, CyGame().getEstimateEndTurn() - iChange))
			self.placeStats()

		elif inputClass.getFunctionName().find("NukesExploded") > -1:
			if inputClass.getData1() == 1030:
				CyGame().changeNukesExploded(abs(iChange))
			elif inputClass.getData1() == 1031:
				CyGame().changeNukesExploded(- min(CyGame().getNukesExploded(), abs(iChange)))
			self.placeStats()

		elif inputClass.getFunctionName().find("MaxTurns") > -1:
			if inputClass.getData1() == 1030:
				CyGame().changeMaxTurns(abs(iChange))
			elif inputClass.getData1() == 1031:
				CyGame().changeMaxTurns(- min(CyGame().getMaxTurns(), abs(iChange)))
			self.placeStats()

		elif inputClass.getFunctionName().find("TradeRoutes") > -1:
			if inputClass.getData1() == 1030:
				CyGame().changeTradeRoutes(min(abs(iChange), gc.getDefineINT("MAX_TRADE_ROUTES") - gc.getDefineINT("INITIAL_TRADE_ROUTES") - CyGame().getTradeRoutes()))
			elif inputClass.getData1() == 1031:
				CyGame().changeTradeRoutes(- min(CyGame().getTradeRoutes(), abs(iChange)))
			self.placeStats()

		elif inputClass.getFunctionName().find("AIAutoPlay") > -1:
			if inputClass.getData1() == 1030:
				CyGame().setAIAutoPlay(CyGame().getAIAutoPlay() + abs(iChange))
			elif inputClass.getData1() == 1031:
				CyGame().setAIAutoPlay(max(0, CyGame().getAIAutoPlay() - abs(iChange)))
			self.placeStats()

		elif inputClass.getFunctionName() == "WBGameOptions":
			iGameOption = inputClass.getData2()
			if iGameOption < gc.getNumGameOptionInfos():
				CyGame().setOption(iGameOption, not CyGame().isOption(iGameOption))
				self.checkOptions(iGameOption)
			else:
				# Enabling/disabling secondary civs
				if iGameOption < 2000:
					iItem = iGameOption - 1000
					data.setPlayerEnabled(iItem, not data.isPlayerEnabled(iItem))
				# Enabling/disabling RFC options
				elif iGameOption == 2000:
					data.bNoAIStability = not data.bNoAIStability
				elif iGameOption == 2001:
					data.bNoHumanStability = not data.bNoHumanStability
				elif iGameOption == 2002:
					data.bIgnoreAI = not data.bIgnoreAI
				elif iGameOption == 2003:
					data.bUnlimitedSwitching = not data.bUnlimitedSwitching
				elif iGameOption == 2004:
					data.bNoCongressOption = not data.bNoCongressOption
				elif iGameOption == 2005:
					data.bNoPlagues = not data.bNoPlagues
				# Stored Variables
				elif iGameOption == 3001:
					data.bAlreadySwitched = not data.bAlreadySwitched
				elif iGameOption == 3002 and cong.isCongressEnabled():
					data.iCongressTurns = max(1, data.iCongressTurns+iChange)
			self.placeGameOptions()

		elif inputClass.getFunctionName() == "HiddenOptions":
			bHiddenOption = not bHiddenOption
			self.placeGameOptions()

		elif inputClass.getFunctionName() == "AllowsRepeat":
			bRepeat = not bRepeat
			iSelectedCiv = -1
			iSelectedLeader = -1
			self.placeNewPlayer()

		elif inputClass.getFunctionName() == "WBNewCiv":
			iSelectedCiv = inputClass.getData2()
			iSelectedLeader = -1
			self.interfaceScreen()

		elif inputClass.getFunctionName() == "WBNewLeader":
			iSelectedLeader = inputClass.getData2()
			self.interfaceScreen()

		elif inputClass.getFunctionName() == "CreatePlayer":
			for i in xrange(gc.getMAX_CIV_PLAYERS()):
				if not gc.getPlayer(i).isEverAlive():
					CyGame().addPlayer(i, iSelectedLeader, iSelectedCiv)
					break
			screen.hideScreen()
			self.top.m_iCurrentPlayer = i
			self.top.normalPlayerTabModeCB()

		elif inputClass.getFunctionName() == "GameEditScriptData":
			popup = Popup.PyPopup(4444, EventContextTypes.EVENTCONTEXT_ALL)
			popup.setHeaderString(CyTranslator().getText("TXT_KEY_WB_SCRIPT", ()))
			popup.createEditBox(CyGame().getScriptData())
			popup.launch()

		return 1
	def placeGameOptions(self):
		screen = CyGInterfaceScreen( "WBGameDataScreen", CvScreenEnums.WB_GAMEDATA)
		sColor = CyTranslator().getText("[COLOR_WARNING_TEXT]", ())
		if bHiddenOption:
			sColor = CyTranslator().getText("[COLOR_POSITIVE_TEXT]", ()) 
		screen.setText("HiddenOptions", "Background", "<font=3b>" + sColor + CyTranslator().getText("TXT_KEY_WB_SHOW_HIDDEN",()) + "</color></font>", CvUtil.FONT_RIGHT_JUSTIFY, screen.getXResolution() - 20, self.iGameOption_Y - 30, -0.1, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		iWidth = screen.getXResolution() - 40
		iHeight = (screen.getYResolution() - self.iGameOption_Y - 40) /24 * 24 + 2
		nColumns = 3
		iWidth1 = 80
		iWidth2 = iWidth / nColumns - iWidth1
		screen.addTableControlGFC("WBGameOptions", nColumns * 2, 20, self.iGameOption_Y, iWidth, iHeight, False, False, 24, 24, TableStyles.TABLE_STYLE_STANDARD)
		for i in xrange(nColumns):
			screen.setTableColumnHeader("WBGameOptions", i * 2, "", iWidth2)
			screen.setTableColumnHeader("WBGameOptions", i * 2 + 1, "", iWidth1)

		lList = []
		for item in xrange(gc.getNumGameOptionInfos()):
			Info = gc.getGameOptionInfo(item)
			if Info.getVisible() or bHiddenOption:
				lList.append([Info.getDescription(), item])
		lList.sort()

		# Merijn: Add extra DoC options
		lList2 = []
		lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_STABILITY", ()), 2000])
		lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_HUMAN_STABILITY", ()), 2001])
		lList2.append([CyTranslator().getText("TXT_KEY_WB_IGNORE_AI_UHV", ()), 2002])
		lList2.append([CyTranslator().getText("TXT_KEY_WB_UNLIMITED_SWITCHING", ()), 2003])
		lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_CONGRESS", ()), 2004])
		lList2.append([CyTranslator().getText("TXT_KEY_WB_NO_PLAGUE", ()), 2005])
		lList2.sort()
		
		# Stored variables
		lList3 = []
		lList3.append([CyTranslator().getText("TXT_KEY_WB_ALREADY_SWITCHED", ()), 3001])
		lList3.append([CyTranslator().getText("TXT_KEY_WB_CONGRESS_TURNS", ()), 3002])
		lList3.sort()

		iNumRows = (len(lList) + nColumns - 1) / nColumns
		iNumRows2 = iNumRows + 3 + max(len(lSecondaryCivs), len(lList2), len(lList3))
		for i in xrange(iNumRows2):
			screen.appendTableRow("WBGameOptions")

		for i in xrange(len(lList)):
			iColumn = i / iNumRows
			iRow = i % iNumRows
			item = lList[i][1]

			bEnabled = CyGame().isOption(item)
			bDefault = False
			if item in [6, 11]: # Aggressive AI, No Tech Brokering
				bDefault = True

			sText = self.colorText(lList[i][0], bEnabled)
			screen.setTableText("WBGameOptions", iColumn * 2, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY)
			sText = self.colorText(CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault)
			screen.setTableText("WBGameOptions", iColumn * 2 + 1, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)

		# Merijn: extra rows for secondary civs and RFC options
		screen.setTableText("WBGameOptions", 0, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_SECONDARY_CIVS", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
		screen.setTableText("WBGameOptions", 2, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_RFC_OPTIONS", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
		screen.setTableText("WBGameOptions", 4, iNumRows + 2, CyTranslator().getText("TXT_KEY_WB_RFC_VARIABLES", ()), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)

		iRow = iNumRows + 3
		for iCiv in lSecondaryCivs:
			bEnabled = data.isPlayerEnabled(iCiv)
			bDefault = True
			if iCiv in [iHarappa, iPolynesia]:
				bDefault = False

			sText = self.colorText(gc.getPlayer(iCiv).getCivilizationShortDescription(0), bEnabled)
			screen.setTableText("WBGameOptions", 0, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, 1000+iCiv, CvUtil.FONT_LEFT_JUSTIFY)
			sText = self.colorText(CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault)
			screen.setTableText("WBGameOptions", 1, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)
			iRow += 1

		for i in xrange(len(lList2)):
			item = lList2[i][1]
			iRow = iNumRows + 3 + i

			bEnabled = False
			bDefault = False

			if item == 2000:
				bEnabled = data.bNoAIStability
			elif item == 2001:
				bEnabled = data.bNoHumanStability
			elif item == 2002:
				bEnabled = data.bIgnoreAI
				bDefault = True
			elif item == 2003:
				bEnabled = data.bUnlimitedSwitching
			elif item == 2004:
				bEnabled = data.bNoCongressOption
			elif item == 2005:
				bEnabled = data.bNoPlagues

			sText = self.colorText(lList2[i][0], bEnabled)
			screen.setTableText("WBGameOptions", 2, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY)
			sText = self.colorText(CyTranslator().getText("TXT_KEY_WB_DEFAULT", ()), bDefault)
			screen.setTableText("WBGameOptions", 3, iRow, sText, "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)
						
		for i in xrange(len(lList3)):
			item = lList3[i][1]
			iRow = iNumRows + 3 + i

			bEnabled = False
			bWhite = False
			
			if item == 3001:
				bEnabled = data.bAlreadySwitched
			elif item == 3002:
				bWhite = True

			sText = self.colorText(lList3[i][0], bEnabled, bWhite)
			screen.setTableText("WBGameOptions", 4, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_LEFT_JUSTIFY)
			if item == 3002:
				if not cong.isCongressEnabled():
					iTurns = -1
				else:
					iTurns = data.iCongressTurns
				sText = self.colorText(str(iTurns), True, True)
				screen.setTableText("WBGameOptions", 5, iRow, sText, "", WidgetTypes.WIDGET_PYTHON, 1028, item, CvUtil.FONT_CENTER_JUSTIFY)