Logging with the SDK

deepwater

Chieftain
Joined
Apr 17, 2011
Messages
30
Hi,
I have a question about the SDK. How can you log e.g. variables either to an own file or to an ingame message?
In Python you have this, but how can you do this in the SDK?
PHP:
CyInterface().addImmediateMessage("xxx", "")
Thanks for your help!:)
 
For an in-game message sent to the list of scrolling messages in the center part of the top of the display, the call is this sort of thing:
Code:
			szBuffer = gDLL->getText("TXT_KEY_CITY_CELEBRATE", getNameKey(), GC.getCivicInfo(eCivic).getWeLoveTheKing());
			DLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_WELOVEKING", MESSAGE_TYPE_MINOR_EVENT, ARTFILEMGR.getInterfaceArtInfo("INTERFACE_HAPPY_PERSON")->getPath(), (ColorTypes)GC.getInfoTypeForString("COLOR_WHITE"), getX_INLINE(), getY_INLINE(), true, true);
That was taken from CvCity.cpp, lines 7209 & 7210. It is what shows the "we love the king day" message.

If you want to know what all those arguments are...
The prototype for the function is in CvDLLInterfaceIFaceBase.h:
Code:
	virtual void addMessage(PlayerTypes ePlayer, bool bForce, int iLength, CvWString szString, LPCTSTR pszSound = NULL,
		InterfaceMessageTypes eType = MESSAGE_TYPE_INFO, LPCSTR pszIcon = NULL, ColorTypes eFlashColor = NO_COLOR,
		int iFlashX = -1, int iFlashY = -1, bool bShowOffScreenArrows = false, bool bShowOnScreenArrows = false) = 0;
Combined with looking at examples, you should be able to figure out what they are for. (For example, "iLength" is not the length of the message, it is duration to show the message which is why that example passes GC.getEVENT_MESSAGE_TIME() for that.)
 
Thanks, this will help a lot. :hatsoff:
And is there a possibility to get to know how to log in a file? :)
 
it's pretty easy to use the logging system
Code:
CvString szMessage="CvGame::doTurn Begin()";
gDLL->logMsg("debug.log", szMessage,true,true);
just make sure the logging system is enabled in the civilization ini file. you find the log file in the logs folder
 
OK, problem: How can I "cast" e.g. a bool to this "CvWString" for ingame messages? I tried it this way
PHP:
CvWString szBuffer = (CvWString) mybool
But it did not work. Even with with this did not work.
PHP:
char temp = mybool
CvWString = (CvWString) temp
Is there kind of a function that converts any variable into a CvWString? Or how can I manage this?
 
search the SDK for .Format and you should get a lot of examples.
 
Back
Top Bottom