Ok, I have been looking around the SDK. I have a good idea of what needs to be done and how to do it. So far I have a setName function:
Code:
void CvPlayer::setName(wchar name){
szLeaderName = name
}
Now I haven't changed the getName but that should be simple enough, so I just need to know where my variable szLeaderName should go in the CvPlayer.cpp file, are there any other files that I should change (do I have to add something to the CvPlayer.h?), how do I open the setName function to python, will the game save the new name, and lastly how do I read from and use the information from the XML (not important). Sorry that I have so many questions. Now I think to open the setName to python I need to change the CvPlayerInterface file, am I right?
If you have a new variable called szLeaderName that will be a member of the CvPlayer class, then you will need to add this code to the CvPlayer.h file...
I'd recommend naming the variable m_szLeaderName instead, just to go along with the general convention of placing "m_" at the front of variables that will be members of the class (in this case, the CvPlayer class), so the code would be...
Code:
CvWString m_szLeaderName;
You'll want to put that somewhere in the private section of the class in CvPlayer.h. If you're not too picky, you can put it right below the line that says...
Also, you'll have to add the function declaration for the setLeaderName in the CvPlayer.h file.
There is a tutorial that shows how to make python functions callable from python, but here's a quick overview..
You will need to change CyPlayer.h, CyPlayer.cpp, and CyPlayerInterface.cpp. Take a look at how they do getUnitName and setUnitName for the unit, and it should be pretty similar.
Edit:
BTW, I almost forgot.
Because you're making a new variable, you'll probably want to make sure that it's saved when a player saves a game.
For this, you can pretty much add this line to CvPlayer::read(FDataStreamBase* pStream)...
Code:
pStream->ReadString(m_szLeaderName);
And this to CvPlayer::write(FDataStreamBase* pStream)...
Code:
pStream->WriteString(m_szLeaderName);
Make sure you put them in the same place, because the order in which data is read/written matters.