def CGEWarning(self): config = CvConfigParser.CvConfigParser("Civ IV Gameplay Enhancements Config.ini") if (config != None): self.CFG_Debug_CGE = config.getboolean("Civ IV Gameplay Enhancements", "Debug", False) if (not self.CFG_Debug_CGE): popup = PyPopup.PyPopup(-1) popup.setHeaderString("Civ IV Gameplay Enhancements Setup Warning !!!") popup.setBodyString(localText.getText("TXT_KEY_CGE_CONFIG_WARNING", ())) popup.launch(true, PopupStates.POPUPSTATE_IMMEDIATE) # BtS本体のバージョンが違う場合に正常動作しないことに対する警告。 if (gc.getDefineINT("CIV4_VERSION") != 319): popup = PyPopup.PyPopup(-1) popup.setHeaderString("Civ IV Gameplay Enhancements Version Warning !!!") popup.setBodyString("This Civ IV Gameplay Enhancements does not work with this BtS version.") popup.launch(true, PopupStates.POPUPSTATE_IMMEDIATE) if (version.CGETestVersion): Civconfig = CvConfigParser.CvConfigParser("CivilizationIV.ini") bShowPythonExceptions = Civconfig.getint("CONFIG", "HidePythonExceptions", 1) if (bShowPythonExceptions != 0): popup = PyPopup.PyPopup(CvUtil.EventTestWarning, EventContextTypes.EVENTCONTEXT_SELF) popup.setHeaderString("Civ IV Gameplay Enhancements Test Version Warning !!!") popup.setBodyString("Set \"HidePythonExceptions\" to 0 in CivilizationIV.ini.") popup.setBodyString("Please do not use this test version if you will not cooperate to test.") popup.launch(True, PopupStates.POPUPSTATE_QUEUED)
def __init__(self, customEM, configFileName=None): CvUtil.pyPrint("Initializing Revolution Mod") self.EventKeyDown = 6 self.customEM = customEM self.configFileName = configFileName config = CvConfigParser.CvConfigParser(configFileName) self.config = config self.bFoundConfig = config.getboolean("RevConfig", "FoundConfig", False) self.bShowActivePopup = config.getboolean("RevConfig", "ActivePopup", True) self.revComponentsText = "" customEM.addEventHandler("kbdEvent", self.onKbdEvent) customEM.addEventHandler('GameStart', self.onGameStart) customEM.addEventHandler('OnLoad', self.onGameLoad) #customEM.addEventHandler( 'Init', self.onInit ) # Determine if game is already running and Python has just been reloaded if (game.isFinalInitialized()): #print "Game initialized!" self.onGameLoad(None, bShowPopup=False)
def setCGEDLLOptions(self): bHasCGEDLL = False #try: # if (gc.isCGEBuild()): # bHasCGEDLL = True #except: # return config = CvConfigParser.CvConfigParser( "Civ IV Gameplay Enhancements Config.ini") if (config != None and bHasCGEDLL): for Option in CGEDLLOptions.items(): Value = config.getboolean("CGEDLL", Option[1]['Key'], Option[1]['Default']) gc.getGame().setCGEOption(Option[0], Value)
def __init__(self, eventManager, CGEManager, *args, **kwargs): super(CGEEvent, self).__init__(eventManager, *args, **kwargs) eventManager.addEventHandler("EndPlayerTurn", self.onEndPlayerTurn) eventManager.addEventHandler("techAcquired", self.onTechAcquired) eventManager.addEventHandler("unitBuilt", self.onUnitBuilt) eventManager.addEventHandler("setPlayerAlive", self.onSetPlayerAlive) eventManager.addEventHandler("cityDoTurn", self.onCityDoTurn) eventManager.addEventHandler("OnLoad", self.onLoadGame) eventManager.addEventHandler("GameStart", self.onGameStart) eventManager.addEventHandler("BeginPlayerTurn", self.onBeginPlayerTurn) eventManager.addEventHandler("victory", self.onVictory) eventManager.addEventHandler("kbdEvent", self.onKbdEvent) eventManager.addEventHandler("EndGameTurn", self.OnEndGameTurn) eventManager.addEventHandler("OnPreSave", self.onPreSave) eventManager.addEventHandler("firstContact", self.onFirstContact) eventManager.addEventHandler("selectionGroupPushMission", self.onSelectionGroupPushMission) eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt) self.eventMgr = eventManager self.CGEManager = CGEManager global CFG_Alert_Interference config = CvConfigParser.CvConfigParser( "Civ IV Gameplay Enhancements Config.ini") if (config != None): CFG_Alert_Interference = config.getboolean("CGE Alerts", "Interference", True) CFG_Alert_Obsolete = config.getboolean("CGE Alerts", "Obsolete", True) CFG_Alert_SpyStealTech = config.getboolean("CGE Alerts", "SpyStealTech", True) self.hasCGEDLL = False try: if (gc.isCGEBuild()): self.hasCGEDLL = True except: pass self.iStealTechMission = -1
def loadConfigurationData(): global g_bRouteDestructionThroughAirBombs global g_bExperienceGainByDestroyingImprovements global g_bExperienceGainByDestroyingRoutes global g_bExperienceGainByAttackingCities global g_bExperienceGainByAttackingUnits global g_bBombNoMansLand config = CvConfigParser.CvConfigParser("Air Combat Experience Config.ini") if (config != None): g_bRouteDestructionThroughAirBombs = config.getboolean( "Air Combat Experience", "Route Destruction Through Air Bombs", true) g_bExperienceGainByDestroyingImprovements = config.getboolean( "Air Combat Experience", "Experience Gain By Destroying Improvements", true) g_bExperienceGainByDestroyingRoutes = config.getboolean( "Air Combat Experience", "Experience Gain By Destroying Routes", true) g_bExperienceGainByAttackingCities = config.getboolean( "Air Combat Experience", "Experience Gain By Attacking Cities", true) g_bExperienceGainByAttackingUnits = config.getboolean( "Air Combat Experience", "Experience Gain By Attacking Units", true) g_bBombNoMansLand = config.getboolean("Air Combat Experience", "Bomb No Mans Land", true) gc.getGame().setRouteDestructionThroughAirBombs( g_bRouteDestructionThroughAirBombs) gc.getGame().setExperienceGainByDestroyingImprovements( g_bExperienceGainByDestroyingImprovements) gc.getGame().setExperienceGainByDestroyingRoutes( g_bExperienceGainByDestroyingRoutes) gc.getGame().setExperienceGainByAttackingCities( g_bExperienceGainByAttackingCities) gc.getGame().setExperienceGainByAttackingUnits( g_bExperienceGainByAttackingUnits) gc.getGame().setBombNoMansLand(g_bBombNoMansLand)
## You should have received a copy of the GNU General Public License ## along with Civilization IV Alerts mod; if not, write to the Free ## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ## 02110-1301 USA __version__ = "$Revision: 1.4 $" # $Source: /usr/local/cvsroot/Civ4lerts/src/main/python/CvCustomEventManager.py,v $ import CvEventManager import CGEEventManager import CvGreatPersonModEventManager import Civ4lerts import MoreCiv4lerts import CvConfigParser #---unitstats addition 1/2----------------------- config_US = CvConfigParser.CvConfigParser("Unit Statistics Mod Config.ini") CFG_Unit_Statistics = config_US.getboolean("Unit Statistics Mod", "Enabled", False) try: import CvUnitStatisticsEventManager except ImportError: CFG_Unit_Statistics = False #/---unitstats addition 1/2----------------------- #import AIAutoPlay #import autologEventManager import RevolutionInit class CvCustomEventManager(CvEventManager.CvEventManager, object): """Extends the standard event manager by adding support for multiple handlers for each event.
ObsoleteBonus = dict() ObsoleteBuilding = dict() gSpyMoveToList = [] gSpyMovingList = dict() gEspionagePoint = dict() gAutoRecon = dict() gAutoReconUnit = -1 gAutoReconSetMode = False gAutoReconDest = (-1, -1) gWonderPrereqBuilding = dict() gWonderPrereqBuildingSet = set() gAutoOrder = False gAutoOrderCombatTypeList = dict() gAUtoOrderUnitClassList = dict() config = CvConfigParser.CvConfigParser( "Civ IV Gameplay Enhancements Config.ini") CFG_Spy_Detect = config.getboolean('Spy Detect', 'Enabled', False) class CGEUtils: def resetCGEUtils(self): global gSpyAlert global ObsoleteBonus global ObsoleteBuilding global gEspionagePoint global gAutoRecon global gAutoReconUnit global gAutoReconSetMode global gAutoReconDest global gWonderPrereqBuilding global gWonderPrereqBuildingSet
def InitValue(self): global gOptionDict global CGEDLLOptions gOptionDict = {} config = CvConfigParser.CvConfigParser( "Civ IV Gameplay Enhancements Config.ini") if (config != None): for Option in CGEOptionCheckBox.items(): #CvUtil.pyPrint("CGEOption: " + Option[0] + ", " + Option[1]['Section'] + ", " + Option[1]['Key']) Value = config.getboolean(Option[1]['Section'], Option[1]['Key'], Option[1]['Default']) gOptionDict[Option[0]] = { 'Section': Option[1]['Section'], 'Key': Option[1]['Key'], 'Default': Option[1]['Default'], 'Tab': Option[1]['Tab'], 'Value': Value, 'Modified': False } for Option in CGEOptionInt.items(): #CvUtil.pyPrint("CGEOption: " + Option[0] + ", " + Option[1]['Section'] + ", " + Option[1]['Key']) Value = config.getint(Option[1]['Section'], Option[1]['Key'], Option[1]['Default']) gOptionDict[Option[0]] = { 'Section': Option[1]['Section'], 'Key': Option[1]['Key'], 'Default': Option[1]['Default'], 'Tab': Option[1]['Tab'], 'Value': Value, 'Modified': False } for Option in CGEOptionFloat.items(): #CvUtil.pyPrint("CGEOption: " + Option[0] + ", " + Option[1]['Section'] + ", " + Option[1]['Key']) Value = config.getfloat(Option[1]['Section'], Option[1]['Key'], Option[1]['Default']) gOptionDict[Option[0]] = { 'Section': Option[1]['Section'], 'Key': Option[1]['Key'], 'Default': Option[1]['Default'], 'Tab': Option[1]['Tab'], 'Value': Value, 'Modified': False } for Option in CGEOptionDropDown.items(): #CvUtil.pyPrint("CGEOption: " + Option[0] + ", " + Option[1]['Section'] + ", " + Option[1]['Key']) Value = config.getint(Option[1]['Section'], Option[1]['Key'], Option[1]['Default']) gOptionDict[Option[0]] = { 'Section': Option[1]['Section'], 'Key': Option[1]['Key'], 'Default': Option[1]['Default'], 'Tab': Option[1]['Tab'], 'Value': Value, 'Modified': False } for Option in CGEOptionDropDownColor.items(): #CvUtil.pyPrint("CGEOption: " + Option[0] + ", " + Option[1]['Section'] + ", " + Option[1]['Key']) Value = config.get(Option[1]['Section'], Option[1]['Key'], Option[1]['Default']) gOptionDict[Option[0]] = { 'Section': Option[1]['Section'], 'Key': Option[1]['Key'], 'Default': Option[1]['Default'], 'Tab': Option[1]['Tab'], 'Value': Value, 'Modified': False } bHasCGEDLL = False #try: # if (gc.isCGEBuild()): # bHasCGEDLL = True #except: # bHasCGEDLL = False if (bHasCGEDLL): CGEDLLOptions = { CGEOptionTypes.CGE_OPTION_DISPLAY_CURRENT_CIVICS: { 'Key': "Display Current Civics", 'Default': True }, CGEOptionTypes.CGE_OPTION_ADDITIONAL_CITY_HELP: { 'Key': "Display Additional City Help", 'Default': True }, CGEOptionTypes.CGE_OPTION_CITY_RANK_ON_PRODUCTION_MENU: { 'Key': "Display City Rank On Production Menu", 'Default': True }, CGEOptionTypes.CGE_OPTION_TOTAL_YIELD_FROM_CITY_FAT_CROSS: { 'Key': "Total Yield From City Fat Cross", 'Default': True }, } config_US = CvConfigParser.CvConfigParser( "Unit Statistics Mod Config.ini") if (config_US != None): for Option in CGEOptionCheckBox.items(): if (Option[1]['Section'] == "Unit Statistics Mod"): #CvUtil.pyPrint("CGEOption: " + Option[0] + ", " + Option[1]['Section'] + ", " + Option[1]['Key']) Value = config_US.getboolean(Option[1]['Section'], Option[1]['Key'], Option[1]['Default']) gOptionDict[Option[0]] = { 'Section': Option[1]['Section'], 'Key': Option[1]['Key'], 'Default': Option[1]['Default'], 'Tab': Option[1]['Tab'], 'Value': Value, 'Modified': False } for Option in CGEOptionDropDown.items(): if (Option[1]['Section'] == "Unit Statistics Mod"): #CvUtil.pyPrint("CGEOption: " + Option[0] + ", " + Option[1]['Section'] + ", " + Option[1]['Key']) Value = config_US.getint(Option[1]['Section'], Option[1]['Key'], Option[1]['Default']) gOptionDict[Option[0]] = { 'Section': Option[1]['Section'], 'Key': Option[1]['Key'], 'Default': Option[1]['Default'], 'Tab': Option[1]['Tab'], 'Value': Value, 'Modified': False }
def writeINIFile(self): config = CvConfigParser.CvConfigParser( "Civ IV Gameplay Enhancements Config.ini") bConfigModified = False if (config != None and config.getINIFileName() != ""): for Option in CGEOptionCheckBox.items(): if (gOptionDict[Option[0]]['Modified'] and gOptionDict[Option[0]]['Section'] != "Unit Statistics Mod"): #CvUtil.pyPrint("CGE Write option: %s, %s, %s"%(Option[0], gOptionDict[Option[0]], gOptionDict[Option[0]]['Value'])) config.setOption(gOptionDict[Option[0]]['Section'], gOptionDict[Option[0]]['Key'], str(gOptionDict[Option[0]]['Value'])) bConfigModified = True for Option in CGEOptionInt.items(): if (gOptionDict[Option[0]]['Modified']): #CvUtil.pyPrint("CGE Write option: %s, %s, %s"%(Option[0], gOptionDict[Option[0]], gOptionDict[Option[0]]['Value'])) config.setOption(gOptionDict[Option[0]]['Section'], gOptionDict[Option[0]]['Key'], str(gOptionDict[Option[0]]['Value'])) bConfigModified = True for Option in CGEOptionFloat.items(): if (gOptionDict[Option[0]]['Modified']): #CvUtil.pyPrint("CGE Write option: %s, %s, %s"%(Option[0], gOptionDict[Option[0]], gOptionDict[Option[0]]['Value'])) config.setOption(gOptionDict[Option[0]]['Section'], gOptionDict[Option[0]]['Key'], str(gOptionDict[Option[0]]['Value'])) bConfigModified = True for Option in CGEOptionDropDown.items(): if (gOptionDict[Option[0]]['Modified'] and gOptionDict[Option[0]]['Section'] != "Unit Statistics Mod"): #CvUtil.pyPrint("CGE Write option: %s, %s, %s"%(Option[0], gOptionDict[Option[0]], gOptionDict[Option[0]]['Value'])) config.setOption(gOptionDict[Option[0]]['Section'], gOptionDict[Option[0]]['Key'], str(gOptionDict[Option[0]]['Value'])) bConfigModified = True for Option in CGEOptionDropDownColor.items(): if (gOptionDict[Option[0]]['Modified']): #CvUtil.pyPrint("CGE Write option: %s, %s, %s"%(Option[0], gOptionDict[Option[0]], gOptionDict[Option[0]]['Value'])) config.setOption(gOptionDict[Option[0]]['Section'], gOptionDict[Option[0]]['Key'], str(gOptionDict[Option[0]]['Value'])) bConfigModified = True if (bConfigModified): config.writeINIfile() bHasCGEDLL = False #try: # if (gc.isCGEBuild()): # bHasCGEDLL = True #except: # bHasCGEDLL = False if (bHasCGEDLL): bConfigModified = False config_US = CvConfigParser.CvConfigParser( "Unit Statistics Mod Config.ini") if (config_US != None and config_US.getINIFileName() != ""): for Option in CGEOptionCheckBox.items(): if (gOptionDict[Option[0]]['Modified'] and gOptionDict[Option[0]]['Section'] == "Unit Statistics Mod"): #CvUtil.pyPrint("CGE Write option: %s, %s, %s"%(Option[0], gOptionDict[Option[0]], gOptionDict[Option[0]]['Value'])) config_US.setOption( gOptionDict[Option[0]]['Section'], gOptionDict[Option[0]]['Key'], str(gOptionDict[Option[0]]['Value'])) bConfigModified = True for Option in CGEOptionDropDown.items(): if (gOptionDict[Option[0]]['Modified'] and gOptionDict[Option[0]]['Section'] == "Unit Statistics Mod"): #CvUtil.pyPrint("CGE Write option: %s, %s, %s"%(Option[0], gOptionDict[Option[0]], gOptionDict[Option[0]]['Value'])) config_US.setOption( gOptionDict[Option[0]]['Section'], gOptionDict[Option[0]]['Key'], str(gOptionDict[Option[0]]['Value'])) bConfigModified = True if (bConfigModified): config_US.writeINIfile()