Afforess
The White Wizard
I'm trying to merge Strategyonlys updated Mercanaries Modcomp with RoM, which uses BUG 4.0. I'm have some questions about CvEventInterface.py, and how to merge it, as the Mercanaries mod uses a CustomEventManager. Hopefully you'll forgive my ignorance, I'm terrible with python.
The Merc Mod uses this EventInterface:
And BUG 4.0 uses this one.
Now, the problem is the bolded areas. Both mods seems to use the same function a different way, and I am not sure how to merge these files without damaging one of the mods.
The Merc Mod uses this EventInterface:
Code:
import CvUtil
from CvPythonExtensions import *
#<MERC START>
[B]import CvCustomEventManager
normalEventManager = CvCustomEventManager.CvCustomEventManager()[/B]
#<MERC END>
[B]def getEventManager():
return normalEventManager[/B]
def onEvent(argsList):
'Called when a game event happens - return 1 if the event was consumed'
return getEventManager().handleEvent(argsList)
def applyEvent(argsList):
context, playerID, netUserData, popupReturn = argsList
return getEventManager().applyEvent(argsList)
def beginEvent(context, argsList=-1):
return getEventManager().beginEvent(context, argsList)
And BUG 4.0 uses this one.
Code:
import BugEventManager
# **********************************
# GJD modifications start here
# **********************************
[B]
eventManager = BugEventManager.BugEventManager()
def getEventManager():
return eventManager[/B]
# **********************************
# GJD modifications end here
# **********************************
def onEvent(argsList):
"""Called when a game event happens - return 1 if the event was consumed."""
return getEventManager().handleEvent(argsList)
def applyEvent(argsList):
context, playerID, netUserData, popupReturn = argsList
return getEventManager().applyEvent(argsList)
def beginEvent(context, argsList = -1):
return getEventManager().beginEvent(context, argsList)
def initAfterReload():
"""
Initialize BUG and fires PythonReloaded event after reloading Python modules while game is still running.
The first time this module is loaded after the game launches, the global context is not yet ready,
and thus BUG cannot be initialized. When the Python modules are reloaded after being changed, however,
this will reinitialize BUG and the main interface.
"""
import BugInit
if BugInit.init():
try:
import CvScreensInterface
CvScreensInterface.reinitMainInterface()
except:
import BugUtil
BugUtil.error("BugInit - failure rebuilding main interface after reloading Python modules")
getEventManager().fireEvent("PythonReloaded")
# initialize BUG after Python modules have been reloaded
initAfterReload()
Now, the problem is the bolded areas. Both mods seems to use the same function a different way, and I am not sure how to merge these files without damaging one of the mods.