Changing the UI

HaloTru7h

Chieftain
Joined
Jan 5, 2008
Messages
31
I got this mod last night and loved it. So far i've merged it with all the other mods I have, and it works great. But there is a small, minor annoyance.

The Revolution Watch button. I wish it was up on the bar with the other buttons, possibly left to the Domestics Advisor.

So my question is, is there anyway to change it's location?

And, on an unrelated note, is there a fix to the "can't find revolution.ini" file? It's in the location it should be but it wont load it.

Thanks for any help.
 
I got this mod last night and loved it. So far i've merged it with all the other mods I have, and it works great. But there is a small, minor annoyance.

The Revolution Watch button. I wish it was up on the bar with the other buttons, possibly left to the Domestics Advisor.

So my question is, is there anyway to change it's location?

And, on an unrelated note, is there a fix to the "can't find revolution.ini" file? It's in the location it should be but it wont load it.

Thanks for any help.

Yes the RevWatch button can be moved, it's location is set in Revolution\Assets\Python\Screens\CvMainInterface.py on line 145. To put it to the left of the DA button, change the line to:

screen.setImageButton("RevWatchButton1", "", xResolution - 277 - 25, 27, 28, 28, WidgetTypes.WIDGET_GENERAL, -1, -1 )

As for the Revolution.ini warning, what two paths are in the popup and which one has the file? Also, if you've been merging .ini files make sure that the "FoundConfig = True' line is still in a section under the 'RevConfig' heading as this is the hack I use to determine if the config file was found.

Anyway, glad you like it! What other mods did you merge it with?
 
In an almost related comment.
I really like the rev. watch having a button.
Its brilliant thanks.
 
Sorry it has taken me so long to reply, i've been away a bit.

Anyway, I did what you said. I made sure the FoundConfig was under RevConfig. Still doesn't work. Whenever the mod loads, it pretty much clears out half of the .ini file except for a few options.

I have the mod folder in only one path, the "MyDocuments/MyGames/BeyondTheSword/MODS/Revolution" one, and not the actual game folder (Fireaxis/Civilization).

Any other ideas?

And for your final question, I merged it with the MAD Nukes Mod, and took a few units from History in the Making and added them in.
 
It fixed it. But now i'm having another problem. >_>

Every turn these "python exceptions" pop up in 3 windows. I took screenshots. I'm experimenting around to see if there's an exact trigger for these errors, and I can't find one. Any ideas?

http://img258.imageshack.us/img258/4422/error1ts1.jpg
http://img222.imageshack.us/my.php?image=error2sx3.jpg
http://img222.imageshack.us/img222/44/error3qg3.jpg

Update: Hmm, these error messages are now appearing in an infinite loop. I first though they only showed up in debug mode, but now they're showing up during normal play.
 
Hm. Well, it appears I didn't even merge it right to begin with. Fault is on my side. Luckily I saved older versions, even the original Revolution mod folder before adding custom content. I still don't know how I overlooked putting in the DLL, or how it worked for so long without a DLL... >_>

Hopefully I should be able to completely fix it now.
 
Well, placing in the DLL from the original Revolution folder worked. Just still one minor python exception popping up.

http://i31.tinypic.com/1zelggi.jpg(Imageshack wouldn't load)

This one occurs every four turns. Problem with the DLL? Something else? I wish I knew how to solve these problems myself, but I know very little about python, C++, SDK, or DLL files. :\

Edit: I just realised the revolution watch feature disappeared. I think i'm just going to rebuild all the additions I made, because apparently i've messed up too many times in too many places.
 
I've already rebuilt it before I got around to reading your reply. But, I made sure to note all the .py files I had to merge from the other mods I combined with it.

There's only two. CvCustomEventManager.py, and the CvEventInterface.py.

No errors on loadup. No errors when starting a game. Toggled debug mode on and advanced 1 turn. No error so far. Error after 4 turns. Same error I described above:

"File "CvAppInterface", line47, in onSave
AttributeError: 'module' object has no attribute 'onEvent'"

Also, the RevWatch Ctrl Shift W feature is also killed. The problem would be in the two files I listed above correct? The ones I had to merge with other mods.

Edit: I shifted out the two files for ones from the .zip. Unedited ones. RevWatch features are back, but it cannot find the .ini again. Back to stage one. But, I believe I can get it from here. Thank you for all your help. <_<

Edit #2: Well... I can't get it. It use to work fine, but now I can't get it to work no matter what. I've attempted 6 times, saving all the failed attempts on my desktop.

I'm posting the files that I need merged. If you can figure it out, let me know. I'll keep trying to work with it.

Cv Custom Event Manager for MAD Nukes Mod
Spoiler :
## Copyright (c) 2005-2006, Gillmer J. Derge.

## This file is part of Civilization IV MAD Nukes Mod
##
## Civilization IV MAD Nukes Mod is free software; you can redistribute
## it and/or modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation; either
## version 2 of the License, or (at your option) any later version.
##
## Civilization IV MAD Nukes Mod is distributed in the hope that it will
## be useful, but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Civilization IV MAD Nukes Mod; if not, write to the Free
## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
## 02110-1301 USA


import CvEventManager
import CvMADNukesEventManager

class CvCustomEventManager(CvEventManager.CvEventManager, object):

def __init__(self, *args, **kwargs):
super(CvCustomEventManager, 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)
# --> INSERT EVENT HANDLER INITIALIZATION HERE <--
CvMADNukesEventManager.CvMADNukesEventManager(self)

def addEventHandler(self, eventType, eventHandler):
"""Adds a handler for the given event type.

A list of supported event types can be found in the initialization
of EventHandlerMap in the CvEventManager class.

"""
self.EventHandlerMap[eventType].append(eventHandler)

def removeEventHandler(self, eventType, eventHandler):
"""Removes a handler for the given event type.

A list of supported event types can be found in the initialization
of EventHandlerMap in the CvEventManager class. It is an error if
the given handler is not found in the list of installed handlers.

"""
self.EventHandlerMap[eventType].remove(eventHandler)

def setEventHandler(self, eventType, eventHandler):
"""Removes all previously installed event handlers for the given
event type and installs a new handler .

A list of supported event types can be found in the initialization
of EventHandlerMap in the CvEventManager class. This method is
primarily useful for overriding, rather than extending, the default
event handler functionality.

"""
self.EventHandlerMap[eventType] = [eventHandler]

def handleEvent(self, argsList):
"""Handles events by calling all installed handlers."""
self.origArgsList = argsList
flagsIndex = len(argsList) - 6
self.bDbg, self.bMultiPlayer, self.bAlt, self.bCtrl, self.bShift, self.bAllowCheats = argsList[flagsIndex:]
eventType = argsList[0]
return {
"kbdEvent": self._handleConsumableEvent,
"mouseEvent": self._handleConsumableEvent,
"OnSave": self._handleOnSaveEvent,
"OnLoad": self._handleOnLoadEvent
}.get(eventType, self._handleDefaultEvent)(eventType, argsList[1:])

def _handleDefaultEvent(self, eventType, argsList):
if self.EventHandlerMap.has_key(eventType):
for eventHandler in self.EventHandlerMap[eventType]:
# the last 6 arguments are for internal use by handleEvent
eventHandler(argsList[:len(argsList) - 6])

def _handleConsumableEvent(self, eventType, argsList):
"""Handles events that can be consumed by the handlers, such as
keyboard or mouse events.

If a handler returns non-zero, processing is terminated, and no
subsequent handlers are invoked.

"""
if self.EventHandlerMap.has_key(eventType):
for eventHandler in self.EventHandlerMap[eventType]:
# the last 6 arguments are for internal use by handleEvent
result = eventHandler(argsList[:len(argsList) - 6])
if (result > 0):
return result
return 0

# TODO: this probably needs to be more complex
def _handleOnSaveEvent(self, eventType, argsList):
"""Handles OnSave events by concatenating the results obtained
from each handler to form an overall consolidated save string.

"""
result = ""
if self.EventHandlerMap.has_key(eventType):
for eventHandler in self.EventHandlerMap[eventType]:
# the last 6 arguments are for internal use by handleEvent
result = result + eventHandler(argsList[:len(argsList) - 6])
return result

# TODO: this probably needs to be more complex
def _handleOnLoadEvent(self, eventType, argsList):
"""Handles OnLoad events."""
return self._handleDefaultEvent(eventType, argsList)


Cv Custom Event Manager for Revolution
Spoiler :
## Copyright (c) 2005-2006, Gillmer J. Derge.

## This file is part of Civilization IV Alerts mod.
##
## Civilization IV Alerts mod is free software; you can redistribute
## it and/or modify it under the terms of the GNU General Public
## License as published by the Free Software Foundation; either
## version 2 of the License, or (at your option) any later version.
##
## Civilization IV Alerts mod is distributed in the hope that it will
## be useful, but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## 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 CvConfigParser
# --------- Revolution mod (1/2) -------------
import RevolutionInit

class CvCustomEventManager(CvEventManager.CvEventManager, object):

"""Extends the standard event manager by adding support for multiple
handlers for each event.

Methods exist for both adding and removing event handlers. A set method
also exists to override the default handlers. Clients should not depend
on event handlers being called in a particular order.

This approach works best with mods that have implemented the design
pattern suggested on Apolyton by dsplaisted.

http://apolyton.net/forums/showthread.php?threadid=142916

The example given in the 8th post in the thread would be handled by adding
the following lines to the CvCustomEventManager constructor. The RealFort,
TechConquest, and CulturalDecay classes can remain unmodified.

self.addEventHandler("unitMove", rf.onUnitMove)
self.addEventHandler("improvementBuilt", rf.onImprovementBuilt)
self.addEventHandler("techAcquired", rf.onTechAcquired)
self.addEventHandler("cityAcquired", tc.onCityAcquired)
self.addEventHandler("EndGameTurn", cd.onEndGameTurn)

Note that the naming conventions for the event type strings vary from event
to event. Some use initial capitalization, some do not; some eliminate the
"on..." prefix used in the event handler function name, some do not. Look
at the unmodified CvEventManager.py source code to determine the correct
name for a particular event.

Take care with event handlers that also extend CvEventManager. Since
this event manager handles invocation of the base class handler function,
additional handlers should not also call the base class function themselves.

"""

def __init__(self, *args, **kwargs):
super(CvCustomEventManager, 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)
# --> INSERT EVENT HANDLER INITIALIZATION HERE <--

# --------- Revolution mod (2/2) -------------
revConfigFile = "Revolution.ini"
RevolutionInit.RevolutionInit( self, revConfigFile )

def addEventHandler(self, eventType, eventHandler):
"""Adds a handler for the given event type.

A list of supported event types can be found in the initialization
of EventHandlerMap in the CvEventManager class.

Throws LookupError if the eventType is not valid.

"""
if eventType not in self.EventHandlerMap:
raise LookupError(eventType)
self.EventHandlerMap[eventType].append(eventHandler)

def removeEventHandler(self, eventType, eventHandler):
"""Removes a handler for the given event type.

A list of supported event types can be found in the initialization
of EventHandlerMap in the CvEventManager class. It is an error if
the given handler is not found in the list of installed handlers.

Throws LookupError if the eventType is not valid.

"""
if eventType not in self.EventHandlerMap:
raise LookupError(eventType)
self.EventHandlerMap[eventType].remove(eventHandler)

def setEventHandler(self, eventType, eventHandler):
"""Removes all previously installed event handlers for the given
event type and installs a new handler.

A list of supported event types can be found in the initialization
of EventHandlerMap in the CvEventManager class. This method is
primarily useful for overriding, rather than extending, the default
event handler functionality.

Throws LookupError if the eventType is not valid.

"""
if eventType not in self.EventHandlerMap:
raise LookupError(eventType)
self.EventHandlerMap[eventType] = [eventHandler]

def setPopupHandler(self, eventType, popupHandler):
"""Removes all previously installed popup handlers for the given
event type and installs a new handler.

The eventType should be an integer. It must be unique with respect
to the integers assigned to built in events. The popupHandler should
be a list made up of (name, beginFunction, applyFunction). The name
is used in debugging output. The begin and apply functions are invoked
by beginEvent and applyEvent, respectively, to manage a popup dialog
in response to the event.

"""
self.Events[eventType] = popupHandler

def handleEvent(self, argsList):
"""Handles events by calling all installed handlers."""
self.origArgsList = argsList
flagsIndex = len(argsList) - 6
self.bDbg, self.bMultiPlayer, self.bAlt, self.bCtrl, self.bShift, self.bAllowCheats = argsList[flagsIndex:]
eventType = argsList[0]
return {
"kbdEvent": self._handleConsumableEvent,
"mouseEvent": self._handleConsumableEvent,
"OnSave": self._handleOnSaveEvent,
"OnLoad": self._handleOnLoadEvent
}.get(eventType, self._handleDefaultEvent)(eventType, argsList[1:])

def _handleDefaultEvent(self, eventType, argsList):
if self.EventHandlerMap.has_key(eventType):
for eventHandler in self.EventHandlerMap[eventType]:
# the last 6 arguments are for internal use by handleEvent
eventHandler(argsList[:len(argsList) - 6])

def _handleConsumableEvent(self, eventType, argsList):
"""Handles events that can be consumed by the handlers, such as
keyboard or mouse events.

If a handler returns non-zero, processing is terminated, and no
subsequent handlers are invoked.

"""
if self.EventHandlerMap.has_key(eventType):
for eventHandler in self.EventHandlerMap[eventType]:
# the last 6 arguments are for internal use by handleEvent
result = eventHandler(argsList[:len(argsList) - 6])
if (result > 0):
return result
return 0

# TODO: this probably needs to be more complex
def _handleOnSaveEvent(self, eventType, argsList):
"""Handles OnSave events by concatenating the results obtained
from each handler to form an overall consolidated save string.

"""
result = ""
if self.EventHandlerMap.has_key(eventType):
for eventHandler in self.EventHandlerMap[eventType]:
# the last 6 arguments are for internal use by handleEvent
result = result + eventHandler(argsList[:len(argsList) - 6])
return result

# TODO: this probably needs to be more complex
def _handleOnLoadEvent(self, eventType, argsList):
"""Handles OnLoad events."""
return self._handleDefaultEvent(eventType, argsList)


Cv Event Interface for MAD Nukes Mod
Spoiler :
# Sid Meier's Civilization 4
# Copyright Firaxis Games 2005
#
# CvEventInterface.py
#
# These functions are App Entry Points from C++
# WARNING: These function names should not be changed
# WARNING: These functions can not be placed into a class
#
# No other modules should import this
#
import CvUtil

from CvPythonExtensions import *

import CvCustomEventManager

normalEventManager = CvCustomEventManager.CvCustomEventManager()

def getEventManager():
return normalEventManager

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)


Cv Event Interface for Revolution
Spoiler :
# Sid Meier's Civilization 4
# Copyright Firaxis Games 2005
#
# CvEventInterface.py
#
# These functions are App Entry Points from C++
# WARNING: These function names should not be changed
# WARNING: These functions can not be placed into a class
#
# No other modules should import this


import CvCustomEventManager

# **********************************
# GJD modifications start here
# **********************************

customEventManager = CvCustomEventManager.CvCustomEventManager()

def getEventManager():
return customEventManager

# **********************************
# 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)
 
Well, this CustomEventManager should do the trick. Just use the event interface file from Revolution.

It's possible that the CvMADNukesEventManager doesn't share events ... if Ctrl+Shift+W doesn't work now, that's the cause. Solving this would take a bit more work, but I don't think it will happen.

As for the .ini file not found, that can be caused either by not having the mod in main \BTS\Mods\ folder or having changed the name of the mod (the folder name). The CvModName.py file must contain the name of the folder the mod files are in, so "Revolution" for the base mod or "RevNukes" if it's in BTS\Mods\RevNukes.

If you're still getting .ini problems, zip up the Python folder and upload it to CivFanatics and I can probably take a look at it.
 
Same thing I was doing. kills both RevWatch and MadNukes. I'm trying to figure out how I got them to work together for so long before I began to work out some of the bugs.

Anyway, Thank you for all your help. If you want to continue tinkering with it, go ahead, here's the broken .py files that need merged. If not, that's fine.

http://forums.civfanatics.com/uploads/134703/Things.rar
 
Top Bottom