The Great Apple
Big Cheese
Actually I prefer the radical way.SimCutie said:Code:More conventional way: def EventHandlerRegister(evt_mgr, unused): evt_mgr.addEventHandler('Init', onInit) evt_mgr.addEventHandler('UnInit', onUnInit, evt_mgr.PRIORITY_HIGH) Radical way: def EventHandlerRegister(evt_mgr, unused): return { 'Init' : onInit , 'UnInit+': onUnInit }
I'm getting slightly confused here. Does this method actively search for mods with events, or do you have to define them in one specific file? The note at the top of CvSimCutieEventManager.py seemed to imply that it would search for any event manager in the mod file, and use these.
I disagree. While what you are saying is true, that doesn't mean it's the right thing to do. There are many advantages of having all your events and functions listed out - you can see at a glance what all the events available to you are, and what functions each event calls. If there is a none result, then nothing gets handled, and there is no problem. It's clear, easy to understand, and easy to alter. It may be less clever, or neat, but I think it's better.SimCutie said:It should install event handler for only events that the mod has need to handle. Leave alone for event that the mod doesn't care. The list itself is readily available in any modder's and player's installation folder.
It would perhaps be even better if they could attach multiple functions in a list inside the dictionary, so that it's even clearer. For example:
PHP:
def EventHandlerRegister( evt_mgr, unused = None ):
EventHandlerMap = {
...
'EndGameTurn' : handleEndGameTurn,
'BeginPlayerTurn' : (handleBeginPlayerTurn1, handleBeginPlayerTurn 2),
'EndPlayerTurn' : None,
...
}
return EventHandlerMap
As mentioned above, I think we should make it as clear as we can to the user how to use the mod. This is the clearest method I can think of - it has the names of the events, and the names of the functions so it you can see at a glance what happens when. It has the names of the events you can use, so you add new functions at a glance.