GameTextMgr.cpp : text string won't display

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,588
Location
Gent, Belgium
I'd like to use a trait's short description instead of the full one when showing trait production boni for units/buildings/etc. However I can't get it to work:

This is an example of code using the full description:

Code:
			if (kBuilding.getProductionTraits((TraitTypes)i) != 0)
			{
				if (kBuilding.getProductionTraits((TraitTypes)i) == 100)
				{
					szBuffer.append(NEWLINE);
					szBuffer.append(gDLL->getText("TXT_KEY_DOUBLE_SPEED_TRAIT", GC.getTraitInfo((TraitTypes)i).getTextKeyWide()));
				}
				else
				{
					szBuffer.append(NEWLINE);
					szBuffer.append(gDLL->getText("TXT_KEY_PRODUCTION_MODIFIER_TRAIT", kBuilding.getProductionTraits((TraitTypes)i), GC.getTraitInfo((TraitTypes)i).getTextKeyWide()));
				}
			}

If I try to change getTextKeyWide() to getShortDescription(), no text shows up at all. See the attached screenshot.

I also tried getShortDescription().getCString(), but then I get an error when compiling.

Anyone know how to get this to work?
 
Try

CvWString szTemp = GC.getTraitInfo((TraitTypes)i).getShortDescription();


Then use szTemp.GetCString() in your output string. Normal outputs use the CString on these type of objects. I can't see where it uses TCHAR for output at all, so I'm not sure how to directly use it, but this might auto-type cast for you.
 
Try creating a new TEXT entity. I think that the _<item> after the %sX placeholder may cause it to try to look up the value as another TEXT entity.

Remove "_trait" in each of the languages and give it a shot:

Code:
<Tag>TXT_KEY_DOUBLE_SPEED_TRAIT</Tag>
<English>[ICON_BULLET]Double production speed for %s1[s][B]_trait[/B][/s] leaders</English>
...
 
Try CvWString szTemp = GC.getTraitInfo((TraitTypes)i).getShortDescription(); Then use szTemp.GetCString() in your output string.

Thanks, that did the trick!

For the record, when I first tried it with getCString() (with small letter), I got the compiler error again. It seems getCString() and GetCString() are two different things... (They're both used in the gametext file)

Try creating a new TEXT entity.

I don't understand what you mean with that. But no matter, the problem got solved already. :)
 
I never even noticed that there were two versions :)


EF was saying to change the text from:

<English>Cheaper for %s1_TraitDesc</English>

to

<English>Cheaper for %s1</English>


But to my knowledge that shouldn't have any effect, everything that isn't a recognized key in that kind of a string is just ignored (if it works like the standard text format framework, which it ought to)
 
Top Bottom