Befor you start to use SDK DLL runtime DLL config and custom option screen described above, check if this is really what you want.
If your the runtime DLL configuration option should not changed from start of new game to final victory/defeat of the game (I'll call it one game match) and all player should playe under same option, and player should be able to choose the configuration option by game match by game match, at start of new game, my custom option is not what you want.
In such case, I recommand to use GC.getGameOptionInfo().
Player can choose the option from CUSTOM GAME menu of Civ4 Main menu -> Custom game OPTIONS screen.
To add new CvGameOptionInfo, do following step.
1) Add new option constant (like GAMEOPTION_MY_MOD_ENABLE) to "enum GameOptionTypes" definition in "CvEnum.h".
2) Add Python interface of the constant value to python::enum_<GameOptionTypes> in CyEnumInterface.cpp
.value("GAMEOPTION_COMPLETE_KILLS", GAMEOPTION_COMPLETE_KILLS)
3) Copy "Assets\XML\GameInfo\CIV4GameOptionInfos.xml" XML file to "CustomAssets\xml\gameinfo\"
folder.
Edit "CIV4GameOptionInfos.xml" and add your XML entry like this.
Code:
<GameOptionInfo>
<Type>GAMEOPTION_MY_MOD_ENABLE</Type>
<Description>TXT_KEY_GAME_OPTION_MY_MOD_ENABLE</Description>
<Help>TXT_KEY_GAME_OPTION_MY_MOD_ENABLE_HELP</Help>
<bDefault>0</bDefault>
</GameOptionInfo>
4) Add TXT_KEY_GAME_OPTION_MY_MOD_ENABLE, TXT_KEY_GAME_OPTION_MY_MOD_ENABLE_HELP
text info to Text XML file in \CustomAssets\xml\text. (like "CIV4GameText_EXTDLL.xml")
5) And recompile the DLL and install it to your CustomAssets folder.
That's it,
Then player can see the new Game option in the Custom game OPTIONS screen.
In C++ SDK, Modder can get/set the value these API. It has python counterpart too.
Code:
bool GC.getGameINLINE().isOption(GameOptionTypes eIndex) const
void GC.getGameINLINE().setOption(GameOptionTypes eIndex, bool bEnabled)
CyGame().isOption(GameOptionTypes eIndex)
CyGame().setOption(GameOptionTypes eIndex, bool bEnabled)
----------------------------------------
If your configuration can be changed freely in the middle of the game on runtime,
and it maybe choosen by player and maybe different from player by player. (like graphic option)
Then my runtime DLL config is not what you want. Then use CvPlayerOptionInfo.
To add new CvPlayerOptionInfo, do following step.
1) Add new option constant (like PLAYEROPTION_MY_MOD_ENABLE) to "enum PlayerOptionTypes" definition in "CvEnum.h".
2) Add Python interface of the constant value to python::enum_<PlayerOptionTypes> in CyEnumInterface.cpp
3) Copy "Assets\XML\GameInfo\CIV4PlayerOptionInfos.xml" XML file to "CustomAssets\xml\gameinfo\"
folder.
Edit "CIV4PlayerOptionInfos.xml" and add your XML entry like this.
Code:
<PlayerOptionInfo>
<Type>PLAYEROPTION_MY_MOD_ENABLE</Type>
<Description>TXT_KEY_PLAYEROPTION_MY_MOD_ENABLES</Description>
<Help>TXT_KEY_PLAYEROPTION_MY_MOD_ENABLE_HELP</Help>
<bDefault>0</bDefault>
</PlayerOptionInfo>
4) Add TXT_KEY_PLAYEROPTION_MY_MOD_ENABLES, TXT_KEY_PLAYEROPTION_MY_MOD_ENABLE_HELP
text info to Text XML file in \CustomAssets\xml\text. (like "CIV4GameText_EXTDLL.xml")
5) And recompile the DLL and install it to your CustomAssets folder.
That's it,
Then player can see the new Player option in the Game tab of Option Screen
In C++ SDK, Modder can get/set the value these API. It has python counterpart too.
Code:
bool CvPlayer::isOption(PlayerOptionTypes eIndex) const
void CvPlayer::setOption(PlayerOptionTypes eIndex, bool bEnabled)
getActvePlayer().isOption(PLAYEROPTION_MY_MOD_ENABLE)
getActvePlayer().setOption(PLAYEROPTION_MY_MOD_ENABLE, newValue)
You can access These in Python like this
Code:
UserProfile.getPlayerOption( gc.getInfoTypeForString("PLAYEROPTION_MY_MOD_ENABLE"))
UserProfile.getPlayerOption(gc.getInfoTypeForString("PLAYEROPTION_MY_MOD_ENABLE", newvalue )
If both Game Option and Player Option selction method doesn't meets Your needs,
Then try my run time DLL config and Custom option screen.