[Dev] GameFont.tga editing

I'm sorry i have a hard time understanding the code part. How did you found the offset to get to the first russian letter in the gamefont ?
I'll rewrite the _categories.parse to include conversions tags for languages, like:
Code:
<language name="russian">
    <letter name="1091">8771</letter>
</language>

So the document could be easily edited to add new languages based on the civ xml tages (<Russian>, <French>, etc.)
 
I'm sorry i have a hard time understanding the code part. How did you found the offset to get to the first russian letter in the gamefont ?
See the screenshot. I made columns and control the text in them. It consists of two parts (written in the last line of code)
Code:
 (u" %c" %  (iIndex+8483))
This is copy paste of vanilla code to display an icon from GameFont. I replaced getChar() with index+offset.

Code:
unicode(iIndex+8483)
This will print the number itself. Note that it is the same number as the one used for the icon.

I then loop iIndex from 0 to 999 and create a column and icon for each number. Scrolling through all those columns reveal which number tells the start of Russian. I still haven't figured out why it is that number, but this test reveals that it is and using it in XML works.

My reference to enter starting point of namespaces in XML was actually aimed at namespaces like yields and buildings. If we shift everything, it will solve that problem easily by changing a single line in XML. It will also solve the problem where adding too many yields will shift buildings and other issues like that.

The more I think about putting the conversion table inside the DLL, the more I love that idea. Right now the XML file will be unreadable while playing, but if the conversion is done at DLL startup, the XML itself will always be UTF-8 and hence readable.
 
I have added full support for Russian in Medieval Conquest. I pushed it to Sourceforge (git module).
https://sourceforge.net/p/colonizationmodcollection/Medieval_Conquest/ci/GameFont/tree/

Note that the actual source code is in a submodule.

The changes I have made:
  • Added Russian characters from the Russian version of Colonization.
  • Added uppercase &#1063;, which the Russians for some reason failed to include (they list this as a bug)
  • Moved all GameFont addressing to XML setup. Nothing is hardcoded by the exe anything (well, the DLL ignores the calls from the exe).
  • Can read Russian UTF-8 characters from XML and converts on the fly while reading the strings.


I'm still interested in the translation tool as the ability to merge vanilla and mod files looks interesting. Also the ability to detect unused strings sounds great too.
 
Good job ! I haven't worked on it yesterday but i'll try to figure it out tomorrow.
I've understood your previous instruction but i don't even know where i can put your code to create columns or row as i never read the python code for the game yet.

In Civ 4, the "micro" character replaced the "x" (multiplication) but this new method is way cleaner !
 
After some experimentation I have come back to answer the original questions.

- Do you think it's possible to call a letter from this file like you call an icon ?
You don't have to concern yourself with how to call the letters themselves. Just make sure the game gets the right int.

Code:
bool CvGameText::read(CvXMLLoadUtility* pXML)
In here there is setText(wszTextVal);
What you want to do is to modify wszTextVal before setText(). wszTextVal is a wstring, but in this case view it as an array of shorts (16 bit ints). If wszTextVal[4] = 8562, then the icon in slot with ID 8562 is displayed. If this is a letter, then it will print a letter.

I would recommend looking at (copying) static CvWString convertString(CvWString wszTextVal) in Medieval Conquest. It converts UTF-8 Russian characters into GameFont.tga IDs. It just needs to be told the ID of the first letter. M:C also contain a tga file with the complete Russian alphabet. One reason why copying the code is attractive is because modifying the string with numbers like that resulted in funny issues like it added a space between every single Russian character. I have fixed those issues with a bit of creativity.

The ID of the first slot is 8483 and increase one at a time. It goes row by row (left to right). Sometimes it skips empty slots. An easy solution is to use GameFontEditor to fill all slots. I have plenty of smilies to ensure everything stays at the right locations.

Be warned however. The exe appears to assume certain icons, such as BULLET_CHAR to be at specific IDs.

- Is there a limit of slot in this file ?
276 :(
For some reason this is the number of different icons the city billboards can handle. Any higher than that and it becomes questionmarks. This goes for both name/production and icons on top of the billboard.

It doesn't look like there is a limit besides this. That mean if you have icons you only use in python pages (city screen, pedia, etc), then place those icons after the 276 threshold.

If you are picky about what you put into those 276 slots and only add those icons you actually need for the billboards, then 276 appears to be plenty. It would however be a problem to add Japanese (2140 characters) or Chinese (even more). For comparison Russian has 64 characters and that is for both upper and lowercase.
 
Thank you for the feedback. I have tried to dive into the code, but i have so much things to learn that it is discouraging. I don't even know where the domestic advisor code is. I saw you used offsets in your xml files but there don't seems to be such code in the mod.
It will be easier to just mod the gamefont file to add russian :/ I didn't even plan to add japanese or chinese as there are no demands. Someone asked for Sinhala, but he only translated 100 lines out of 20000 so i don't think i'll add it soon.
 
I don't even know where the domestic advisor code is.
Assets\Python\Screens\CvDomesticAdvisor.py

I saw you used offsets in your xml files but there don't seems to be such code in the mod.
I added that file myself. It's easier to modify than if it is inside the DLL code. Also I aim to make one DLL fit multiple mods, hence the need not to hardcode anything like that. It could be an enum in the DLL if you just aim for the regular one DLL one mod approach ;)

It will be easier to just mod the gamefont file to add russian :/
If you want to keep it really simple, add Russian to GameFont, get the addresses (possibly through trial and error). Once you have the addresses, you can add convertString() and modify it to set the indexes you end up with for Russian chars. The only problem in that approach is that Russian chars (like other chars) aren't standard sized meaning it isn't as simple as copy paste in GameFontEditor.

I didn't even plan to add japanese or chinese as there are no demands.
It was more like an observation than a proposal.
 
Top Bottom