Trying ot change the "General" of the GG Bar to an icon...

draco963

Prince
Joined
Jan 26, 2007
Messages
451
Location
Earth
As the title says, that's what I'm trying to do. I'd much prefer a Great General icon instead of the word "General". Unfortunately, it's not as easy as just defining:
Code:
def getGreatGeneralText(iNeededExp):
	sGreatGeneralIcon = u"%c" % ArtFileMgr.getUnitArtInfo("ART_DEF_UNIT_WARLORD_COUNTER").getButton()
	return BugUtil.getText("INTERFACE_NEXT_GREAT_GENERAL_XP", (sGreatGeneralIcon, iNeededExp,))
in GGUtil.py and changing the "General" in the BUG_CIV4GameText.xml to "%s1". Doing this causes the GG Bar to not load at all. Yes, I have defined the art file. Any ideas?
 
Its not working because your trying to shove an art file into a text string. The only "pictures" you can use in strings are the ones from the GameFont.tga file.

Try something like this

Code:
def getGreatGeneralText(iNeededExp):
    icon = u"%c" % CyGlobalContext().getGame().getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR)
    text = icon + " : " + str(iNeededExp)
    return text
 
Wow! Three answers! Cool! :cool: :goodjob:

@ Doc, sorry I don't get you... :crazyeye:

@ Del69, that code looks (from my extremely limited understanding of Python) like it would probably work. One question though: GREAT_PEOPLE_CHAR defines slot 13,13 in the two GameFont files. And I know that in BtS, the FontButtonIndex tag of CIV4ArtDefines_Bonus.xml indicates which icon in GameFont to use for resources. But where are the definitions for everything else, and how to I tell the game that slot 13,24 (after the lightning bolt) is GREAT_GENERAL_CHAR?

@ NikNaks, I think I'm ok with the graphic. I was able to take the GG icon from WarlordsAtlas_1 slot 5,10, and take out the background, so it's just the Generals head, with the rest transparent. Looks nice, if I do say so myself :D. So I have a template to work from, and I think I should be ok. But thank-you for the offer, and if I have trouble sizing it down, I will definately take you up on it.
 
I tried this before, and you can embed images into text using "<img src=/Art/Foo/Bar.dds></img>" or something similar. The problem was that when doing so, images get shifted a bit above the baseline of the text, making it look ugly.

My next thought was to simply place an icon as an image next to the text, but I got side-tracked with other things. This would still work, but I think NikNaks's suggestion of putting the image you've yanked out into the font file is the best route. It will align nicely with the baseline and be quite easy. I think it would be useful elsewhere, too, e.g. the CDA for settled specialists.

Oh, I suppose you could embed the settled Military Instructor instead of the GG for the CDA thing, NN. Both is probably best. :)
 
Ok, here are the two GameFont files with a GG icon added in.

View attachment fonts.rar

I still odn't know how to tell the game where the new icon is located... I thought there would be a file somewhere in the BUG mod specifying the six new smilies on the last line of GameFont_75, but I can't find anything...
 

Attachments

  • GameFont.JPG
    GameFont.JPG
    44.4 KB · Views: 84
  • GameFont_75.JPG
    GameFont_75.JPG
    31.3 KB · Views: 83
OK, so I thought I had it figured out, when I saw all the FontSymbols definitions at the end of CvUtil.py. But no, it doesn't work either.

Adding the line
Code:
'great general' : FontSymbols.GREAT_GENERAL_CHAR,
at the end of the "OtherFontIcons =" argument causes the entire interface to not load at all. The game loads fine, but no interface, which you'll agree makes playing a trifle difficult.

So, commenting out the line in CvUtil.py, and using this
Code:
def getGreatGeneralText(iNeededExp):
	sGreatGeneralChar = u"%c" % CyGame().getSymbolID(FontSymbols.OCCUPATION_CHAR)
	return BugUtil.getText("INTERFACE_NEXT_GREAT_GENERAL_XP", (sGreatGeneralChar, iNeededExp,))
in GGUtil.py and this
Code:
	<TEXT>
		<Tag>INTERFACE_NEXT_GREAT_GENERAL_XP</Tag>
		<English>%s1 (%d2)</English>
in BUG_CIV4GameText.xml worked like a charm. I now have a lovely red fist in the GG Bar, instead of the word "General".

As you can see above, I have added a GG icon to the GameFont files, and the game seems fine loading those files instead of ones without the GG. But getting the game to recognize the existence of that icon is proving difficult. So, I don't know where to go from here. Any advice?
 
OK, so I thought I had it figured out, when I saw all the FontSymbols definitions at the end of CvUtil.py.

Those lines don't actually define the FontSymbols constants. Ah, if only it were that easy.

Well, now it is!

I present to you the new FontUtil module. I just committed this to our code repository, so you'll need to be using the latest version from SVN.

To define a constant, add the <symbol> tag to init.xml.

Code:
<symbol id="greatgeneral" name="GREAT_GENERAL" from="POWER" offset="1"/>

To use it in the game, sadly you cannot embed it directly into the <TEXT> XML element like you can with bullets (e.g. [ICON_BULLET]), but you can get close. Modify your code above like so:

Code:
sGreatGeneralChar = [B]FontUtil.getChar(FontSymbols.GREAT_GENERAL_CHAR)[/B]

and don't forget to "import FontUtil" at the top of your module.
 
BTW, the latest SVN version added some new font symbols itself, so just use your own file for your testing or modify my code above (offset = 2) if you put your icon next to the new Generic Citizen icon.
 
EmperorFool, firstly, you are a coding genius. Thank-you.

Secondly, if adding new icons to the GameFont files is so difficult, how did you guys get the game to recognize your new War & Peace icons used by the Advanced Scoreboard?

Thirdly, the download of the nightly update of BUG is broken. It presents this instead:
Code:
An error has been encountered in accessing this page. 

1. Server: civ4bug.sourceforge.net 
2. URL path: /daily_build/ 
3. Error notes: NONE 
4. Error type: 403 
5. Request method: GET 
6. Request query string: NONE 
7. Time: 2008-11-03 08:15:14 UTC (1225700114) 

Reporting this problem: The problem you have encountered is with a project web site hosted by SourceForge.net. This issue should be reported to the SourceForge.net-hosted project (not to SourceForge.net). 

If this is a severe or recurring/persistent problem, please do one of the following, and provide the error text (numbered 1 through 7, above): 

Contact the project via their designated support resources. 
Contact the project administrators of this project via email (see the upper right-hand corner of the Project Summary page for their usernames) at user-name@users.sourceforge.net
If you are a member of the project that maintains this web content, please refer to the Site Documentation regarding the project web service for further assistance. 

NOTE: As of 2008-10-23 directory index display has been disabled by default. This option may be re-enabled by the project by placing a file with the name ".htaccess" with this line: 


Options Indexes

Thanks again EmperorFool.
 
Hmm, I don't know why the nightly snapshot (a.k.a. daily build) is broken, but I highly recommend using SVN directly. It's not very difficult (easier than what you've done already I suspect), and the instructions are in the first post of the Download thread.

This will allow you to use a program like TortoiseSVN to get updates much more easily. In the meantime, however, to fix your code using the old way (the way I originally did the other new icons), change you code like so:

Code:
sGreatGeneralChar = u"%c" % [B]([/B] CyGame().getSymbolID(FontSymbols.OCCUPATION_CHAR)[B] + 2 )[/B]

The change is adding 2. getSymbolID() returns the unicode character value for the font symbol, and your icon is 2 to the right of the Occupation symbol IIRC.

Why did I add this new method of doing it in XML? Mostly for convenience and fun. The problem is that when merging other mods that might define their own new symbols, the positions in the files may clash. Moving those to XML makes it much easier for modders to merge font file constants--not the files themselves, though, but they're just images so that part isn't too bad.

I got sick of seeing font symbols for unrelated symbols, e.g. the War icon used to grab the CvYieldInfo object for :gold: and then offset it 25 positions in Python. That's a nightmare to explain to someone trying to do a merge that may have very limited Python skills. But telling them to modify an XML attribute from "25" to "26" is much safer.
 
EmperorFool, firstly, you are a coding genius. Thank-you.

Secondly, if adding new icons to the GameFont files is so difficult, how did you guys get the game to recognize your new War & Peace icons used by the Advanced Scoreboard?

Thirdly, the download of the nightly update of BUG is broken. It presents this instead:
Code:
An error has been encountered in accessing this page. 

1. Server: civ4bug.sourceforge.net 
2. URL path: /daily_build/ 
3. Error notes: NONE 
4. Error type: 403 
5. Request method: GET 
6. Request query string: NONE 
7. Time: 2008-11-03 08:15:14 UTC (1225700114) 

Reporting this problem: The problem you have encountered is with a project web site hosted by SourceForge.net. This issue should be reported to the SourceForge.net-hosted project (not to SourceForge.net). 

If this is a severe or recurring/persistent problem, please do one of the following, and provide the error text (numbered 1 through 7, above): 

Contact the project via their designated support resources. 
Contact the project administrators of this project via email (see the upper right-hand corner of the Project Summary page for their usernames) at user-name@users.sourceforge.net
If you are a member of the project that maintains this web content, please refer to the Site Documentation regarding the project web service for further assistance. 

NOTE: As of 2008-10-23 directory index display has been disabled by default. This option may be re-enabled by the project by placing a file with the name ".htaccess" with this line: 


Options Indexes

Thanks again EmperorFool.

Fixed the issue with the daily build.
 
Back
Top Bottom