def resetName(self, iPlayer, bVerbose=True): pPlayer = gc.getPlayer(iPlayer) civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType()) origDesc = civInfo.getDescription() origShort = civInfo.getShortDescription(0) origAdj = civInfo.getAdjective(0) if not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV): if not self.bLeaveHumanName or not ( pPlayer.isHuman() or game.getActivePlayer() == iPlayer): if pPlayer.getLeaderType( ) in LeaderCivNames.LeaderCivNames.keys(): [origDesc, origShort, origAdj ] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()] newDesc = CvUtil.convertToStr(origDesc) newShort = CvUtil.convertToStr(origShort) newAdj = CvUtil.convertToStr(origAdj) newDesc = CvUtil.remove_diacriticals(newDesc) newShort = CvUtil.remove_diacriticals(newShort) newAdj = CvUtil.remove_diacriticals(newAdj) gc.getPlayer(iPlayer).setCivName(newDesc, newShort, newAdj)
def setNewNameByCivics(self, iPlayer): [newCivDesc, newCivShort, newCivAdj] = self.newNameByCivics(iPlayer) if gc.getPlayer( iPlayer).isHuman() or game.getActivePlayer() == iPlayer: if self.bLeaveHumanName: CvUtil.pyPrint(" Name - Leaving name for human player") return newDesc = CvUtil.convertToStr(newCivDesc) newShort = CvUtil.convertToStr(newCivShort) newAdj = CvUtil.convertToStr(newCivAdj) newDesc = CvUtil.remove_diacriticals(newDesc) newShort = CvUtil.remove_diacriticals(newShort) newAdj = CvUtil.remove_diacriticals(newAdj) if not newDesc == gc.getPlayer(iPlayer).getCivilizationDescription(0): szMessage = BugUtil.getText("TXT_KEY_MOD_DCN_NEWCIV_NAME_DESC", newDesc) CyInterface().addMessage( iPlayer, False, gc.getEVENT_MESSAGE_TIME(), szMessage, None, InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"), -1, -1, False, False) gc.getPlayer(iPlayer).setCivName(newDesc, newShort, newAdj) return
def onSetPlayerAlive(self, argsList): iPlayerID = argsList[0] bNewValue = argsList[1] if bNewValue and iPlayerID < gc.getMAX_PC_PLAYERS(): pPlayer = gc.getPlayer(iPlayerID) if (pPlayer.isHuman() or game.getActivePlayer() == iPlayerID): if (self.bLeaveHumanName): CvUtil.pyPrint(" Name - Leaving name for human player") return [newCivDesc, newCivShort, newCivAdj] = self.nameForNewPlayer(iPlayerID) newDesc = CvUtil.convertToStr(newCivDesc) newShort = CvUtil.convertToStr(newCivShort) newAdj = CvUtil.convertToStr(newCivAdj) newDesc = CvUtil.remove_diacriticals(newDesc) newShort = CvUtil.remove_diacriticals(newShort) newAdj = CvUtil.remove_diacriticals(newAdj) # Pass to pPlayer seems to require a conversion to 'ascii' pPlayer.setCivName(newDesc, newShort, newAdj)
def handleAutomatedBuildCheckboxClicked(argsList): bValue, szName = argsList print "szName for Option is %s" % szName GC = CyGlobalContext() iPlayer = CyGame().getActivePlayer() CyPlayer = GC.getPlayer(iPlayer) import CvUtil iNumBuildInfos = GC.getNumBuildInfos() for CyCity in CyPlayer.cities(): if szName.rfind(CvUtil.remove_diacriticals(CyCity.getName())) > -1: iCityID = CyCity.getID() for k in range(iNumBuildInfos): if szName.rfind(GC.getBuildInfo(k).getDescription()) > -1: import AutomatedSettings CyMessageControl().sendModNetMessage( AutomatedSettings.getCanAutoBuildEventID(), iPlayer, iCityID, k, int(bValue)) return 1 return 0
def create(self, screen): tab = self.createTab(screen) panel = self.createMainPanel(screen) #Standard Settings self.addLabel(screen, panel, "AutomatedSettings__AutomatedSettings") column = self.addOneColumnLayout(screen, panel, panel) left, right = self.addTwoColumnLayout(screen, column, "Options", False) screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Pillage Options self.addLabel(screen, left, "AutomatedSettings__PillageSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Pillage") self.addCheckbox(screen, col1, "AutomatedSettings__AvoidEnemyUnits") self.addCheckbox(screen, col2, "AutomatedSettings__AvoidBarbarianCities") self.addCheckbox(screen, col3, "AutomatedSettings__HideAutomatePillage") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Hunt Options self.addLabel(screen, left, "AutomatedSettings__HuntSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Hunt") self.addCheckbox(screen, col1, "AutomatedSettings__NoCapturingCities") self.addCheckbox(screen, col2, "AutomatedSettings__AllowUnitSuiciding") self.addCheckbox(screen, col3, "AutomatedSettings__AutoHuntReturnForUpgrades") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutomateHunt") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__AutoHuntMinimumAttackOdds", True, "RIGHT") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Patrol Options: self.addLabel(screen, left, "AutomatedSettings__PatrolSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Patrol") self.addCheckbox(screen, col1, "AutomatedSettings__CanLeaveBorders") self.addCheckbox(screen, col2, "AutomatedSettings__AllowPatrolUnitSuiciding") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutomatePatrol") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__AutoPatrolMinimumAttackOdds", True, "RIGHT") self.addCheckbox(screen, col3, "AutomatedSettings__NoPatrolCapturingCities") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Defense Options: self.addLabel(screen, left, "AutomatedSettings__DefenseSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Defense") self.addCheckbox(screen, col1, "AutomatedSettings__CanLeaveCity") self.addCheckbox(screen, col2, "AutomatedSettings__HideAutomateDefense") self.addIntDropdown(screen, col3, col3, "AutomatedSettings__AutoDefenseMinimumAttackOdds", True, "RIGHT") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Air Options: self.addLabel(screen, left, "AutomatedSettings__AirSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Air") self.addCheckbox(screen, col1, "AutomatedSettings__AirUnitCanDefend") self.addCheckbox(screen, col2, "AutomatedSettings__AirUnitCanRebase") self.addCheckbox(screen, col3, "AutomatedSettings__HideAirAutomations") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Explore Options: self.addLabel(screen, left, "AutomatedSettings__ExploreSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Explore") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoExplore") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Spread Options: self.addLabel(screen, left, "AutomatedSettings__SpreadSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Spread") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoSpread") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Caravan Options: self.addLabel(screen, left, "AutomatedSettings__CaravanSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Caravan") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoCaravan") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Protect Options: self.addLabel(screen, left, "AutomatedSettings__ProtectSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Protect") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoProtect") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Pirate Options: self.addLabel(screen, left, "AutomatedSettings__PirateSettings") col1, col2, col3 = self.addMultiColumnLayout(screen, right, 3, "Automate_Pirate") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoPirate") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__AutoPirateMinimumAttackOdds", True, "RIGHT") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Upgrading Options: self.addLabel(screen, left, "AutomatedSettings__UpgradingSettings") col1, col2 = self.addMultiColumnLayout(screen, right, 2, "Automate_Upgrading") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoUpgrade") self.addIntDropdown(screen, col2, col2, "AutomatedSettings__MinimumUpgradeGold", True, "RIGHT") self.addCheckbox(screen, col1, "AutomatedSettings__MostExpensive") self.addCheckbox(screen, col2, "AutomatedSettings__MostExpierenced") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Promote Options: self.addLabel(screen, left, "AutomatedSettings__PromoteSettings") col1, col2 = self.addMultiColumnLayout(screen, right, 2, "Automate_Promote") self.addCheckbox(screen, col1, "AutomatedSettings__HideAutoPromote") screen.attachHSeparator(column, column + "SepInterface1") left, right = self.addTwoColumnLayout(screen, column, "Options", False) #Automate Worker Options: self.addLabel(screen, left, "AutomatedSettings__WorkerSettings") self.addCheckbox(screen, left, "AutomatedSettings__ShowCityAutomations") bFirst = True import CvUtil GC = CyGlobalContext() if self.buildNames is None: iNumBuilds = GC.getNumBuildInfos() self.buildNames = [(0, 0)] * iNumBuilds # Strip the <link="IMPROVEMENT_FOOBAR"> and </link> pair from the description while retaining the bit between them for iI in range(iNumBuilds): szDescription = CvUtil.remove_diacriticals( GC.getBuildInfo(iI).getDescription()) szNewDescription = "" iStartIndex = szDescription.rfind("<link") iEndIndex = szDescription.rfind("'>") + 2 if iStartIndex > -1: szNewDescription = szDescription[ 0:iStartIndex] + szDescription[ iEndIndex:len(szDescription)] iStartIndex2 = szNewDescription.rfind("</link>") szNewDescription = szNewDescription[ 0:iStartIndex2] + szNewDescription[iStartIndex2 + 7:len(szDescription )] else: szNewDescription = szDescription self.buildNames[iI] = szNewDescription GAME = GC.getGame() CyPlayer = GC.getPlayer(GAME.getActivePlayer()) CyTeam = GC.getTeam(GAME.getActiveTeam()) TRNSLTR = CyTranslator() iNumBuilds = GC.getNumBuildInfos() if self.ANewDawnOpt.isShowCityAutomations(): CyCity, i = CyPlayer.firstCity(False) while CyCity: if not bFirst: self.addSpacer(screen, left, "City Spacer") bFirst = False szCityName = CvUtil.remove_diacriticals(CyCity.getName()) self.addLabel( screen, left, TRNSLTR.getText("TXT_KEY_AUTOMATED_WORKERS_CAN_BUILD_CITY", (szCityName, )), TRNSLTR.getText("TXT_KEY_AUTOMATED_WORKERS_CAN_BUILD_CITY", (szCityName, )), None, False, True) col1, col2, col3, col4, col5 = self.addMultiColumnLayout( screen, left, 5, "Automate_Workers") iCount = 0 for j in range(iNumBuilds): CvBuildInfo = GC.getBuildInfo(j) if CyTeam.isHasTech(CvBuildInfo.getTechPrereq()): columnKey = (col1, col2, col3, col4, col5)[iCount % 5] control = str(szCityName + CvBuildInfo.getDescription() + "Check") bEnabled = CyCity.isAutomatedCanBuild(j) szNewDescription = self.buildNames[j] screen.attachCheckBox( columnKey, control, szNewDescription, "CvOptionsScreenCallbackInterface", "handleAutomatedBuildCheckboxClicked", control, bEnabled) screen.setToolTip( control, TRNSLTR.getText( "TXT_KEY_AUTOMATED_WORKERS_CAN_BUILD", (szCityName, szNewDescription))) iCount += 1 CyCity, i = CyPlayer.nextCity(i, False) self.addSpacer(screen, left, "City Spacer") self.addLabel(screen, left, "AutomatedSettings__NationalWorkerSettings") self.addLabel(screen, left, "AutomatedSettings__NationalWorkerSettingsHover") col1, col2, col3, col4, col5 = self.addMultiColumnLayout( screen, left, 5, "Automate_Workers") szNameKey = CyPlayer.getNameKey() iCount = 0 for i in range(iNumBuilds): CvBuildInfo = GC.getBuildInfo(i) if CyTeam.isHasTech(CvBuildInfo.getTechPrereq()): columnKey = (col1, col2, col3, col4, col5)[iCount % 5] control = CvUtil.remove_diacriticals( szNameKey + CvBuildInfo.getDescription() + "Check") bEnabled = CyPlayer.isAutomatedCanBuild(i) szNewDescription = self.buildNames[i] screen.attachCheckBox( columnKey, control, szNewDescription, "CvOptionsScreenCallbackInterface", "handleNationalAutomatedBuildCheckboxClicked", control, bEnabled) screen.setToolTip( control, TRNSLTR.getText( "TXT_KEY_NATIONAL_AUTOMATED_WORKERS_CAN_BUILD", (szNewDescription, ))) iCount += 1