Is it possible to add new characters/icons to gamefont.tga and use them in-game?

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,603
Location
Gent, Belgium
If so, what changes would need to be done in the SDK to enable them?

I have seen some changes in the Planetfall SDK files. I'm wondering if these are sufficient. If not, what else needs to be done?

CyEnumsInterface.cpp has this added (see last couple lines):

Code:
	python::enum_<FontSymbols>("FontSymbols")
		.value("HAPPY_CHAR", HAPPY_CHAR)
		.value("UNHAPPY_CHAR", UNHAPPY_CHAR)
		.value("HEALTHY_CHAR", HEALTHY_CHAR)
		.value("UNHEALTHY_CHAR", UNHEALTHY_CHAR)
		.value("BULLET_CHAR", BULLET_CHAR)
		.value("STRENGTH_CHAR", STRENGTH_CHAR)
		.value("MOVES_CHAR", MOVES_CHAR)
		.value("RELIGION_CHAR", RELIGION_CHAR)
		.value("STAR_CHAR", STAR_CHAR)
		.value("SILVER_STAR_CHAR", SILVER_STAR_CHAR)
		.value("TRADE_CHAR", TRADE_CHAR)
		.value("DEFENSE_CHAR", DEFENSE_CHAR)
		.value("GREAT_PEOPLE_CHAR", GREAT_PEOPLE_CHAR)
		.value("BAD_GOLD_CHAR", BAD_GOLD_CHAR)
		.value("BAD_FOOD_CHAR", BAD_FOOD_CHAR)
		.value("EATEN_FOOD_CHAR", EATEN_FOOD_CHAR)
		.value("GOLDEN_AGE_CHAR", GOLDEN_AGE_CHAR)
		.value("ANGRY_POP_CHAR", ANGRY_POP_CHAR)
		.value("OPEN_BORDERS_CHAR", OPEN_BORDERS_CHAR)
		.value("DEFENSIVE_PACT_CHAR", DEFENSIVE_PACT_CHAR)
		.value("MAP_CHAR", MAP_CHAR)
		.value("OCCUPATION_CHAR", OCCUPATION_CHAR)
		.value("POWER_CHAR", POWER_CHAR)
		.value("PLANET_GOOD_CHAR", PLANET_GOOD_CHAR)
		.value("PLANET_BAD_CHAR", PLANET_BAD_CHAR)
		.value("PLANET_GLOBAL_CHAR", PLANET_GLOBAL_CHAR)
		.value("MAX_NUM_SYMBOLS", MAX_NUM_SYMBOLS)
		;

CvEnums.h has this added to the last couple lines:

Code:
enum DllExport FontSymbols					// Exposed to Python
{
	// 'OTHER' symbols
	HAPPY_CHAR = 0,
	UNHAPPY_CHAR,
	HEALTHY_CHAR,
	UNHEALTHY_CHAR,
	BULLET_CHAR,
	STRENGTH_CHAR,
	MOVES_CHAR,
	RELIGION_CHAR,
	STAR_CHAR,
	SILVER_STAR_CHAR,
	TRADE_CHAR,
	DEFENSE_CHAR,
	GREAT_PEOPLE_CHAR,
	BAD_GOLD_CHAR,
	BAD_FOOD_CHAR,
	EATEN_FOOD_CHAR,
	GOLDEN_AGE_CHAR,
	ANGRY_POP_CHAR,
	OPEN_BORDERS_CHAR,
	DEFENSIVE_PACT_CHAR,
	MAP_CHAR,
	OCCUPATION_CHAR,
	POWER_CHAR,
	MAP_X_CHAR,
	PLANET_GOOD_CHAR = MAP_CHAR,
	PLANET_GLOBAL_CHAR = MAP_CHAR,
	PLANET_BAD_CHAR = MAP_X_CHAR,

#ifdef _USRDLL
	MAX_NUM_SYMBOLS
#endif
};

Would changing
PLANET_GOOD_CHAR = MAP_CHAR,
PLANET_GLOBAL_CHAR = MAP_CHAR,
PLANET_BAD_CHAR = MAP_X_CHAR,
to
PLANET_GOOD_CHAR,
PLANET_GLOBAL_CHAR,
PLANET_BAD_CHAR,
and adding three new icons after the Power CHAR in gamefont.tga be sufficient to enable new icons in the game?

And what could MAP_X_CHAR be about?? In an unmodded gamefont.tga, such a CHAR does not exist. :confused:
 
I notice two changes between vanilla and BtS:

1) def finishText(argsList): has been commented out (#) in BtS.

2) The BtS CvEnums.h file says this:

#ifdef _USRDLL
MAX_NUM_SYMBOLS
#endif

instead of just this:

MAX_NUM_SYMBOLS


No idea what that means, but I guess it's worth the try to see if it works now.
 
If you just want to use the new symbols in Python (and maybe the C++ DLL), you don't necessarily have to define new symbol names in C++. Check out the BUG mod in my sig that includes the Attitude Icons mod, or search for that mod itself. It adds faces for the various AI attitudes and puts them into the scoreboard using only Python. See Python/BUG/Scores.py for how it's done.
 
I'm afraid a look at ScoreBoard.py doesn't make me any wiser. Don't see anything relating to new gamefont icons there. :confused: Then again, I don't understand the file in the first place.

Though from the Attitude Icons thread I understand that in python you can just say
CyGame().getSymbolID(FontSymbols.POWER_CHAR) + x
for a higher icon value?
 
Sorry, I was heading out when I wrote that. I do see that Scoreboard.py doesn't do the shifting part you mentioned (it's in CvMainInterface.py in BUG). Your formula is correct, though. To put that into a string for display, you can use

PHP:
str = "Attitude = %c" % (CyGame().getSymbolID(FontSymbols.POWER_CHAR) + x)
 
As I've done some more work with the fonts for BUG and the new BUG DLL, I can answer more of these questions.

MAP_X_CHAR defines a constant with a new value (since it isn't given the value of another constant). This means that they must have added an icon after the power icon.

The three other PLANET_ constants are given values of other icons, so they are not new. They only define new C++ names to point to other icons. The reason to do this is so that all the code can refer to PLANET_GOOD_CHAR and use the MAP_CHAR for now. When you add a new icon just for that, all you have to do is change the value that gets assigned to the constant. You don't have to change any other code that uses it--just recompile.

For BUG I created a new module, FontUtil, that adds definitions to FontSymbols for new icons in Python without needing to modify the DLL. It also has a function to get the symbol as a unicode string directly to make it easier to build strings with them.

The only downside is that you cannot embed them in XML text strings like [ICON_FOOD]. I was going to modify BugUtil.getText() to do that replacement, but I just haven't gotten around to it yet.

As for splitting the TGA into a bunch of images, that would require modifying the EXE graphics engine which only Firaxis can do. :(
 
Back
Top Bottom