Questions on the DLL

CvTechChooser.py is the screen that shows the tech tree. I assume the tech screen you're talking about is the one in the Civilopedia, which I don't know anything about since all the modding I do involving the Civilopedia is superceded by the BUG mod, not sure how vanilla civ4 handles that.
 
The idea is that if a tech changes commerce in your cities, then there should be some icon on the tech's panel in the tech tree to indicate that it happens. If you can build a new unit, there is an icon for it. If you get +1 move on roads, there is an icon for it. And so on. Each icon has hover text that explains what it means. You could use 4 separate icons, one per commerce type, and display the appropriate icons for what is changed by that tech ("increases research rate in every city" or whatever). It might be possible to display just one and have the hover text dynamically display the specific values for the selected text, or it might not be possible (or it could be possible but more complicated that you want to mess with).

You should also adjust the hovers used by the city screen so that it displays the modifiers with an explanation when you hover on the stuff in the upper left for research and espionage and gold, and down in the lower left for culture.
 
What would I have to add in CvTechChooser.py?

You should also adjust the hovers used by the city screen so that it displays the modifiers with an explanation when you hover on the stuff in the upper left for research and espionage and gold, and down in the lower left for culture.

What file would this be in and, again, what would I need to add?
 
What would I have to add in CvTechChooser.py?
What file would this be in and, again, what would I need to add?

Generally speaking, the easiest way to add a new UI feature is to find an existing, similar feature, copy it and make the necessary changes. Even if you don't know all the details, it'll usually get you what you need.

Specifically, in CvTechChooser - look for example for the health bonus which the future tech gives (search for "HealthRate"). This should be similar enough to what you're trying to add.

Note that the call there includes the appropriate 'widget' for this (WIDGET_HELP_HEALTH_RATE). You should probably create a widget (or a few widgets) of your own. You should add then in the SDK (look for the health widget name in the SDK source code to get a sense of what you should add).

You should probably also add a new art definition for the image displayed in CIV4ArtDefines_Interface.xml (look at the python code to see how to make the connection).

Reg. the hovers - all (or at least most) of the hovers (tool tips) are created in the SDK code in the CvGameTextMgr.
I think what God Emperor was refering to can be changed in CvGameTextMgr::setCommerceHelp(), but you'll have to check this.

Good luck :goodjob:
 
Specifically, in CvTechChooser - look for example for the health bonus which the future tech gives (search for "HealthRate"). This should be similar enough to what you're trying to add.

What should my entry look like? I copied from the health bonus, and got this:

Code:
if ( gc.getTechInfo(i).getHealth() != 0 ):
	szHealthRateButton = "HealthRate" + str(i)
	screen.addDDSGFCAt( szHealthRateButton, szTechRecord, ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_HEALTH").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_HEALTH_RATE, i, -1, False )
	fX += X_INCREMENT

I tried to change the first line to this:

Code:
if ( gc.getTechInfo(i).getCommerceChange() != 0 ):

and now when I start a game it brings up the Tech Advisor screen with nothing in it. What needs to be there?
 
Probably, you are getting a python error because there is no such function getCommerceChange for a techinfo.

Please confirm if you have python alerts and logging turned on. Please also confirm if you have access to the python API documentation, which lists the available functions. If you have added this type of function to the Cv*.cpp files already, please check if you have added it to the Cy*.cpp files.
 
Please confirm if you have python alerts and logging turned on. Please also confirm if you have access to the python API documentation, which lists the available functions.

Sorry for my ignorance; how do you do that?

If you have added this type of function to the Cv*.cpp files already, please check if you have added it to the Cy*.cpp files.

I added this in CyInfoInterface.cpp:

Code:
.def("getCommerceChange", &CvTechInfo::getCommerceChange, "int (int i)")

Do I need to add something else somewhere else (CyGameTextMgr maybe)?
 
Exceptions + logging you can enable in My Documents\My Games\BtS\Civilization4.ini by changing the following values:
PHP:
; Set to 1 for no python exception popups
HidePythonExceptions = 1

[...]

; Create a dump file if the application crashes
GenerateCrashDumps = 0

; Enable the logging system
LoggingEnabled = 0

; Enable synchronization logging
SynchLog = 0

; Overwrite old network and message logs
OverwriteLogs = 0

; Enable rand event logging
RandLog = 0

; Enable message logging
MessageLog = 0
 
Code:
if ( gc.getTechInfo(i).getCommerceChange() != 0 ):

and now when I start a game it brings up the Tech Advisor screen with nothing in it. What needs to be there?

I suspect that it wants an argument to specify which type of commerce, like:
Code:
if ( gc.getTechInfo(i).getCommerceChange(CommerceTypes.COMMERCE_GOLD) != 0 ):
Checking for each type like that, or looping over them all via something like
Code:
for iCommerceType in range( CommerceTypes.NUM_COMMERCE_TYPES ):
is probably necessary.
 
I suspect that it wants an argument to specify which type of commerce.

What he said. Once you have exceptions enabled as mentioned by The_J, you will clearly see the error which tells you that you have a function argument mismatch. Your function declaration in the .def line requires an int argument, and you did not provide one.

It is painful and unnecessary to debug python with exceptions disabled.
 
I fixed the problem, and made an entry in Civ4ArtDefines_Interface using the Espionage button in the Beyond the Sword atlas. However, in the tech tree it shows up as a pink square. Do I need to make a widget for it to work?
 
This is almost always due to a spelling error in the xml file. You may wish to use civcheck, which can report this type of error.

CivCheck didn't find any undefined symbols. Here is my python entry:

Code:
if ( gc.getTechInfo(i).getCommerceChange(CommerceTypes.COMMERCE_ESPIONAGE) != 0 ):
	szEspionageChangeButton = "EspionageChange" + str(i)
	screen.addDDSGFCAt( szEspionageChangeButton, szTechRecord, ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_ESPIONAGE_INCREASE").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_HEALTH_RATE, i, -1, False )
	fX += X_INCREMENT

and my XML entry:

Code:
<InterfaceArtInfo>
	<Type>INTERFACE_TECH_ESPIONAGE_INCREASE</Type>
	<Path>Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,16</Path>
</InterfaceArtInfo>

Do I maybe need to replace WIDGET_HELP_HEALTH_RATE with something else?
 
I think that when you use an atlas image you need to add a comma before the path:

Code:
<InterfaceArtInfo>
	<Type>INTERFACE_TECH_ESPIONAGE_INCREASE</Type>
	<Path>,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,16</Path>
</InterfaceArtInfo>

The new widget is so you can add specific code for the hover text in the DLL.
 
Normally the game expects to values for buttons, a single one and a reference to an atlas. No idea why, but only atlas does not always work. Try pointing it to a single button, that should fix the problem.

Yeah...the problem is I don't know where to find a single button for the espionage icon
 
Um...seems there is none.
Then do it the way Asaf suggests, or use a dummy button (will not get loaded) as the first one, like the civ4 programmers did it themselves:
PHP:
,Art/Interface/Buttons/Process/ProcessCulture.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,16
 
Is there some kind of rule that only allows one button from the same atlas at a time. I found buttons for the four commerces; Gold, Research, and Culture are all in the same atlas, and only one will show up in the tech tree at a time.
 
I think your point is that in the tech tree, you want to put four new icons of the same type, but only the first one appears. I have not looked into the code; but probably the code which puts in the icons is in a loop, which takes the first matching icon and then stops looking. The author of that loop did not expect to have multiple matches. Does that help any?
 
Back
Top Bottom