Creating a custom game option

Joined
Jun 27, 2007
Messages
2,248
Location
Hamilton, Ontario
How do I create an option for custom games? This would likely require changing the interface and that may be too much work or too difficult, in which case I'd just have a way to turn it on and off in the GlobalDefinesAlt.xml file.
 
No need to modify the interface if you mean one of the things you can select during a Custom Game setup menu. But it does require that you modify the DLL. You have to add your option to the list in CvEnums.h and CyEnumsInterface.cpp, then add a new XML branch in CIV4GameOptionInfos.xml, making sure that all 3 times you keep it in the same order (so if you place it first in one, it has to be first in the other 2 as well).
 
In that case, it is time to clear some of the silly questions out the way.

Did you compile the code after you added the new lines? Did you use the new DLL after you compiled it?

Only silly question after that I guess is to inquire if you ran your new mod or accidentally ran something else.


If you did all of those, then the last thing to ask would be that you post the work you did in [ code ] blocks (including the 2 lines before & after what you wrote)
 
In that case, it is time to clear some of the silly questions out the way.

Did you compile the code after you added the new lines?
Yes
Did you use the new DLL after you compiled it?
Yes
Only silly question after that I guess is to inquire if you ran your new mod
Yes
or accidentally ran something else.
No
If you did all of those, then the last thing to ask would be that you post the work you did in [ code ] blocks (including the 2 lines before & after what you wrote)


CvEnums.h
Code:
	GAMEOPTION_NO_EVENTS,
	GAMEOPTION_NO_ESPIONAGE,
	GAMEOPTION_RISING_SEAS,

#ifdef _USRDLL
	NUM_GAMEOPTION_TYPES

CyEnumsInterface.cpp
Code:
		.value("GAMEOPTION_NO_EVENTS", GAMEOPTION_NO_EVENTS)
		.value("GAMEOPTION_NO_ESPIONAGE", GAMEOPTION_NO_ESPIONAGE)
		.value("GAMEOPTION_RISING_SEAS", GAMEOPTION_RISING_SEAS)
		.value("NUM_GAMEOPTION_TYPES", NUM_GAMEOPTION_TYPES)
		;
CIV4GameOptionInfos.xml
Code:
		<GameOptionInfo>
			<Type>GAMEOPTION_NO_EVENTS</Type>
			<Description>TXT_KEY_GAME_OPTION_NO_EVENTS</Description>
			<Help>TXT_KEY_GAME_OPTION_NO_EVENTS_HELP</Help>
			<bDefault>0</bDefault>
			<bVisible>1</bVisible>
		</GameOptionInfo>
		<GameOptionInfo>
			<Type>GAMEOPTION_NO_ESPIONAGE</Type>
			<Description>TXT_KEY_GAME_OPTION_NO_ESPIONAGE</Description>
			<Help>TXT_KEY_GAME_OPTION_NO_ESPIONAGE_HELP</Help>
			<bDefault>0</bDefault>
			<bVisible>1</bVisible>
		</GameOptionInfo>
		<GameOptionInfo>
			<Type>GAMEOPTION_RISING_SEAS</Type>
			<Description>TXT_KEY_GAME_OPTION_RISING_SEAS</Description>
			<Help>TXT_KEY_GAME_OPTION_RISING_SEAS_HELP</Help>
			<bDefault>0</bDefault>
			<bVisible>1</bVisible>
		</GameOptionInfo>
	</GameOptionInfos>
</Civ4GameOptionInfos>

I also added to CIV4GameText_BTS.xml
Code:
	<TEXT>
		<Tag>TXT_KEY_GRAPHICS_SETTINGS_MOVIE_QUALITY</Tag>
		<English>Movie Quality</English>
		<French>Qualité de Film</French>
		<German>Filmqualität</German>
		<Italian>Qualità di Film</Italian>
		<Spanish>Calidad de Película</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_GAME_OPTION_RISING_SEAS</Tag>
		<English>RISING SEAS</English>
		<French>MERS EN HAUSSE</French>
		<German>STEIGENDE MEERE</German>
		<Italian>MARI AUMENTANTI</Italian>
		<Spanish>MARES DE LEVANTAMIENTO</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_GAME_OPTION_RISING_SEAS_HELP</Tag>
		<English>Global warming can raise sea level.</English>
		<French>Le rechauffement global peut soulever le niveau de la mer.</French>
		<German>Die globale Erwarmung kann Meeresspiegel anheben.</German>
		<Italian>Il riscaldamento globale puo sollevare il livello del mare.</Italian>
		<Spanish>El calentamiento del planeta puede levantar nivel del mar.</Spanish>
	</TEXT>
</Civ4GameText>
 
I think people have mentioned holding shift while you click on your shortcut to force it to clear. Or you could just go and add some spaces or tabs to the end of a few XML files and watch to make sure it loads non-cache next time you start up (generally detects it pretty nicely). Also a setting in the .ini file to disable all cache loading.
 
O.K. I tried switching NO ESPIONAGE and RISING SEAS, and rising seas appeared and no espionage didn't. So I must have missed some part of the code where it says "there are X number of game options and anyone who says differently is a liar!" and it's not counting anything past that number.
Any idea where something like that would be?
 
It worked. Now I just have to have the option do something.
So are there any other situation where I have to do a complete rebuild to get something to work?
 
Generally anytime you modify a *.h file it will be forced to do a complete rebuild by the interlinking of the files. I guess Enums.h is a special case (Haven't ever actually modified it without also modifying other .h files as well to make the new option or whatnot functional)
 
Top Bottom