UI Modifications / Unit & Resource Layer Pips

sqwishy

Chieftain
Joined
Jul 27, 2014
Messages
45
Hi I'm interested in making some UI modifications to see how far I can get in improving things for higher resolution and pixel density displays. I'm working off of the files in this mod so that's why I'm posting in this forum.

Lately I have been struggling to figure out how to change the appearance of the resource and unit pips that appear on the 3d world map when the resource/unit layers are turned on using the buttons near the minimap. I'm wondering if anybody has any pointers?

I'm using the CvGameCoreDLL files from Realism Invictus' repository since my copy of the game (from Steam) doesn't appear to ship them. I can't find anything that implements CvDLLEngineIFaceBase and it looks like it has something to do with these layers, I assume it was never made public? But I'm a bit in over my head here so I'm just curious if someone with more experience can clarify.

Also, if anybody knows of similar efforts to make changes to improve the UI for high pixel density displays, or just more generally appealing, I'd be curious to hear about them. I don't really know how far I will get or if anything I do will be worth trying to contribute upstream, but I hope I'll have a bit more success if I engage with the community a bit.
 
Also, if anybody knows of similar efforts to make changes to improve the UI for high pixel density displays, or just more generally appealing, I'd be curious to hear about them. I don't really know how far I will get or if anything I do will be worth trying to contribute upstream, but I hope I'll have a bit more success if I engage with the community a bit.
I've written a post on that subject last month in the subforum of my own mod. As for the HUD, I set all the widget sizes (panels, buttons) in CvMainInterface.py dynamically based on the screen dimensions, but porting that to another major mod would be very laborious, and my understanding is that Realism Invictus already sets reasonable sizes for the HUD widgets in a static manner. The font size is probably also already increased about as much as it can be without running out of space in help text and on Advisor screens.

This thread (also quoted from in my post), addresses the Resource and Unit Display. The DLL can shrink those pins by modifying the code of the (closed-source) EXE at runtime. It's a few hundred lines of code, but mostly in a single place, so it shouldn't be too laborious to merge that into other mods if one knows how to compile the DLL. This view shows my code changes. (The plotindicator-breakpoints.xml isn't needed, I've included that only for documentation purposes.) It's not my latest and greatest code but should do the job. I had some concerns at first about compatibility with various editions of the game and about virus detection, but I've been using it in my mod for a year now without any reported issues. If the DLL changes are, at least for now, too difficult to adopt, then modifying Civ4BeyondSword.exe on disk with a hex editor is an alternative; this post (2nd spoiler box) describes how to do that. There's also still a modified EXE attached to this post, ready for use. The problem with this approach is that players have to alter (after creating a backup) a file of the original game, manually or through an installer. I'm also not sure if CFC endorses modified versions of the EXE being shared by users; well, I guess it is tolerated. The rest of my post from June just names some (few) other mods that have made Ui modifications to accommodate large displays - mainly MNAI (maximized Advisor screens) and the Civ 4 Remaster (and my own AdvCiv). The others are arguably too far removed from BtS to be useful in this context.
I'm using the CvGameCoreDLL files from Realism Invictus' repository since my copy of the game (from Steam) doesn't appear to ship them.
Might be that Steam doesn't come with source code. Here's an upload of the BtS 3.19 DLL sources, but you'll need to work with the latest Realism Invictus sources anyway, or otherwise you'll lose all the DLL changes made by Realism Invictus.
I can't find anything that implements CvDLLEngineIFaceBase and it looks like it has something to do with these layers, I assume it was never made public? But I'm a bit in over my head here so I'm just curious if someone with more experience can clarify.
The CvDLL...IFaceBase headers are a means of letting the DLL call functions in the EXE (through virtual function tables). Yes, the implementation, presumably a class named CvEngine, exists only in the EXE. (CvDLLEventReporterIFaceBase.h is unused since patch 3.19, which moved CvEventReporter.h/cpp from the EXE into the DLL.)
 
This thread (also quoted from in my post), addresses the Resource and Unit Display. The DLL can shrink those pins by modifying the code of the (closed-source) EXE at runtime
That's super interesting. I've seen mods from other games do similar things so I'll definitely look into that more. Thanks for sharing.
I set all the widget sizes (panels, buttons) in CvMainInterface.py dynamically based on the screen dimensions, but porting that to another major mod would be very laborious
Yeah skimming over and LayoutDict.py RectLayout.py it seems like you've refactored stuff a lot already. It might even be easier to apply the RI changes to CvMainInterface on top of your implementation. When I read the unit plot list stuff in RI I noticed three implementations, vanilla, BUG, and PLE. But it appears you've updated PLE in your mod already. Maybe I'll take a look at this a little more and see what it looks like on my system. And how much it diverges from RI.

For fun, I tried an object (ScaledScreen) that wraps a CyGInterfaceScreen instance and forwards calls to it but applies a scaling factor to x, y, height, and width parameters and a reciprocal to `getXResolution()` and `getYResolution()`. It looks a bit better than I expected (though, I don't know what I'm doing with `centerX()`). It's a bit nicer than scaling the window at the graphics driver level because that does horrible things to font rendering. I'll attach some screenshots.

It's using a factor of 150% which is a little higher than I'd probably want and is a bit big for the font size used. I increased the font size slightly over what RI uses but it could probably be bigger. I also increased instances of `Size_CellHeight` in Civ4Theme_Custom.thm from 24 to 36 for all screenshots. So the screenshots compare with and without this naive scaling to the CyGInterfaceScreen. Notably, the icons from fonts, used in the scoreboard for example, are not scaled and I'm not 100% sure there's a nice way to do that since it comes from a tga file somewhere or something?

Anyway, that's about the laziest attempt I could think of but doesn't change much existing code so that's nice. I'll probably look over the stuff in your mod though because that seems like a much nicer starting point.
 

Attachments

  • 20230705021136_1.jpg
    20230705021136_1.jpg
    2.6 MB · Views: 44
  • 20230705021409_1.jpg
    20230705021409_1.jpg
    2.1 MB · Views: 41
  • 20230705021701_1.jpg
    20230705021701_1.jpg
    2.2 MB · Views: 37
  • 20230705021725_1.jpg
    20230705021725_1.jpg
    2.8 MB · Views: 43
Yeah skimming over and LayoutDict.py RectLayout.py it seems like you've refactored stuff a lot already. It might even be easier to apply the RI changes to CvMainInterface on top of your implementation.
Either way, I reckon it's an awful amount of work. I did have to refactor a lot, which is unfortunate because I don't know Python that well, so the result is still not somehow great.
When I read the unit plot list stuff in RI I noticed three implementations, vanilla, BUG, and PLE. But it appears you've updated PLE in your mod already. Maybe I'll take a look at this a little more and see what it looks like on my system. And how much it diverges from RI.
Ugh, yes those three drawing methods with a lot of redundant code (iirc) did cause a lot of extra work. The PLE mod apparently started before Firaxis released the DLL source code (i.e. before update 1.61), and 12monkeys did some pretty ambitious things just through Python, resulting in a large volume of code. In particular, he implemented his own help text area (UNIT_INFO_PANE in PLE.py). This might actually still find a wider use if the Firaxis help text area can't be enlarged by hacking the EXE. (Access to CvGameTextMgr in the DLL has made it easy to modify the text that is displayed, which, I think, is all that 12monkeys wanted; having control over the size was probably just a side benefit.)
For fun, I tried an object (ScaledScreen) that wraps a CyGInterfaceScreen instance and forwards calls to it but applies a scaling factor to x, y, height, and width parameters and a reciprocal to `getXResolution()` and `getYResolution()`. It looks a bit better than I expected (though, I don't know what I'm doing with `centerX()`). It's a bit nicer than scaling the window at the graphics driver level because that does horrible things to font rendering. I'll attach some screenshots.
That does look surprisingly good. I (probably should) wish that I had had that idea – sounds like far less work and much more easily portable than what I did.
Notably, the icons from fonts, used in the scoreboard for example, are not scaled and I'm not 100% sure there's a nice way to do that since it comes from a tga file somewhere or something?
Should come from the Res\Fonts folder. I don't know if one could (easily) create a GameFont.tga with a higher resolution. Letting the engine enlarge the icons sounds challenging – and might look too blurry anyway. Personally, I feel lucky not having dealt with the game fonts much. My understanding is that the city names also are printed in the game font. When I open the tga (in LibreOffice Draw), I don't see any letters, I suppose they might be white on white in those seemingly empty boxes at the top. :hmm:
 
If you could make the end results of what you did available to be incorporated into RI, it would be great. Gamefont files are notoriously capricious, so I doubt they could be upscaled easily, but that's an interesting challenge I'm willing to try. I'll let you know how it went. Unfortunately from my previous experiments, a lot of stuff about gamefont files is hardcoded, and moreover hardcoded sloppily.

When I open the tga (in LibreOffice Draw), I don't see any letters, I suppose they might be white on white in those seemingly empty boxes at the top. :hmm:
Yep, they're drawn with the alpha channel. It long felt to me that the fonts in tga are far too low-res for modern resolutions, but somehow the idea of simply upscaling those never crossed my mind.
 
I don't know if one could (easily) create a GameFont.tga with a higher resolution. Letting the engine enlarge the icons sounds challenging – and might look too blurry anyway. Personally, I feel lucky not having dealt with the game fonts much. My understanding is that the city names also are printed in the game font.
It long felt to me that the fonts in tga are far too low-res for modern resolutions, but somehow the idea of simply upscaling those never crossed my mind.
Yeah if I open that file in GIMP the white text is visible; it resembles the text on the citybar in the world.

1688642689622.png


I think upscaling the text might not look super great. Obviously, scaling up any image isn't great for detail in the image. But I think the aliasing and blurry edges are much more noticable when text is scaled up compared to blur in normal graphics and icons. So even if there was an easy way to just 2x the citybar (by editing the nif or something) it might not look super appealing -- in my opinion. Though it looks pretty bad as it is currently so maybe it's a low bar to beat.

The kerning is a bit unfortunate too. (Not to mention the color contrast of white on orange.) The Q-i or the W-a here or like in "Washington". (Though it's an older game so it's not super surprising.)

1688643439114.png


But I have a sense that the text in the tga file is not super easy to change because of the way those packed atlases tend to work. I think usually they're generated with a data structure that associates characters to their locations in the atlas. And I bet that was a function or array of structs somewhere in the source code that we don't have. Changing the character locations or sizes in the atlas would require changing that mapping. That's my guess at least.

Regarding the unit/resource plot indicator balloon thing. I think things are a little different in the version of civ that Realism Invictus uses? At least when I played Rise of Mankind A New Dawn, some of the religion icons didn't work until I switched to a "original_release_unsupported" version of the game in Steam. But I think Realism Invictus has issues with that version and runs better with the default version on Steam -- I can't remember why though. With AdvCiv, the resource balloon sizing failed with a little red warning message in the game until I switched over to the "original_release_unsupported".

I had a few issues with my debugger, it seemed Civ would close if I ever tried to do anything with breakpoints. But on the default steam release, using Realism Invictus, a `push 42280000h` shows up at address 0x00465058. (Kind of near where where your patch applies I think?) It looks like I'm able to change that value and toggle balloons and their size updates. For both resources and units and at globe view.

Screenshot 2023-07-06 044828.png
Screenshot 2023-07-06 044911.png


I think your patch doesn't work on this version because the surrounding code/needle is different? I didn't look closely at the other version where it works so I'm just speculating. Anyway maybe this is interesting to you. Thanks for linking the work in your mod. Having something like this in RI would be neat, especially configurable from the BUG Options like you've done. I should look into that further.

I don't really remember why I was using this exe version for Realism Invictus but not for other mods, or why there's two versions on Steam anyway. I think the default one had gamespy removed or something.

I also attached the Python module I made for the scaling. (The forum doesn't like attachments with .py so I gave it a different file suffix.) I use it with font sizes 18, 20, 22, and 24 and in Civ4Theme_Custom.thm under GFC_Control_Table I've been trying `.Size_CellHeight = 30` up from 24 -- maybe 32 is better. Sorry if that's ad-hoc. I should just put diffs somewhere so the changes are obvious to see but when I tried to check out RI's repo it asked me for a username and password and I gave up. I'll try again later if I get the nerve to try and port some of the resource balloon stuff.
 

Attachments

  • ScaledScreen.py.txt
    30.4 KB · Views: 11
Last edited:
But I have a sense that the text in the tga file is not super easy to change because of the way those packed atlases tend to work. I think usually they're generated with a data structure that associates characters to their locations in the atlas. And I bet that was a function or array of structs somewhere in the source code that we don't have. Changing the character locations or sizes in the atlas would require changing that mapping. That's my guess at least.
A user from – I surmise – Russia once shared with me a tga file with cyrillic letters, but his EXE was at least the exact same size as mine apart from a missing digital signature. But if the pixel offsets aren't part of the EXE, then I don't know where else they would be. Perhaps the EXE scans the tga files in search of pink lines and light blue dots. Well, "not super easy" seems safe to say in any case. I guess replacing the letters with a font that isn't larger but better optimized for readability should be technically easy – but obviously time-consuming. The Civ 4 Remaster has removed the food bar under the city name; this does help, but losing the food bar seems undesirable. CvGameTextMgr gets asked by the EXE for the city billboard string; might possibly be a useful entry point for reverse-engineering if needs be.
At least when I played Rise of Mankind A New Dawn, some of the religion icons didn't work until I switched to a "original_release_unsupported" version of the game in Steam. But I think Realism Invictus has issues with that version and runs better with the default version on Steam -- I can't remember why though. With AdvCiv, the resource balloon sizing failed with a little red warning message in the game until I switched over to the "original_release_unsupported".
I had assumed that all DLL mods require the original release, or at least the complex ones. Evidently, you're able to run RI with the Steam EXE, and you might be right that this is indeed recommended. Sounds like my code at least detected that the binary didn't look as expected.
I think your patch doesn't work on this version because the surrounding code/needle is different?
Yes, apparently the code segment that I had hypothesized to exist even in some slightly different build of the EXE is not in fact present in the Steam EXE. Though I do find that little bit of machine code visible in your screenshot also in the EXE that I have installed (i.e. the original release), just at a higher address, so, yes, apparently you've found the correct spot, and maybe my approach of searching for a chunk of code bytes and calculating an offset could be salvaged. If I had the Steam version installed, I'd look into that, but doing so without disassembly generated by the debugger – and without the ability to immediately test my changes – sounds painful. At the least, I should add a warning to my post in that "Shrinking the bubbles" thread.
I had a few issues with my debugger, it seemed Civ would close if I ever tried to do anything with breakpoints.
No real idea why that could be. Since you're able to attach a debugger, it seems that you've already worked around the cheat protection that Steam supposedly has. I've tripped myself up a couple of times by inserting breakpoints in the very code that I was searching/ modifying at runtime. That way I came to realize that breakpoints in native code are implemented through interrupts inserted at runtime.
It looks like I'm able to change that value and toggle balloons and their size updates. For both resources and units and at globe view.
Also Globe view? Right, works that way for me too. May still be a good thought to (statically) shrink them a bit more in Globe view through CIV4DetailManager.xml.
[...] or why there's two versions on Steam anyway. I think the default one had gamespy removed or something.
That's what I've heard too. Maybe GameSpy replaced with some sort of Steam lobby.
I also attached the Python module I made for the scaling.
Thanks, looks proficient for a thing you tried "for fun". :thumbsup:
 
Perhaps the EXE scans the tga files in search of pink lines and light blue dots.
I didn't even see those. I was trying to figure out where you got those images with think pink in that thread you linked and realized they're the colours of the transparent pixels in the tga. Like some invisible ink thing. Crazy. It looks like swapping out a character for a more narrow one and it seemed to work right. I'm curious if height works also. I'll look at that more.
 
OK, so as I suspected, the attempt to upscale the tga file failed miserably. I think the height of the "cells" in those is fixed. The width isn't, but that's little help in this particular case.

A user from – I surmise – Russia once shared with me a tga file with cyrillic letters, but his EXE was at least the exact same size as mine apart from a missing digital signature. But if the pixel offsets aren't part of the EXE, then I don't know where else they would be. Perhaps the EXE scans the tga files in search of pink lines and light blue dots. Well, "not super easy" seems safe to say in any case. I guess replacing the letters with a font that isn't larger but better optimized for readability should be technically easy – but obviously time-consuming. The Civ 4 Remaster has removed the food bar under the city name; this does help, but losing the food bar seems undesirable. CvGameTextMgr gets asked by the EXE for the city billboard string; might possibly be a useful entry point for reverse-engineering if needs be.
Yeah, that's a thing I've been meaning to do for a long while now. Changing the font there is a time-consuming and boring task, but it is possible with the right tools. This discussion has prompted me to resume, and I'm roughly half done (the half being I've finished all the capital letters). Here's the result so far, using Century Gothic:

1688762675180.png

I had assumed that all DLL mods require the original release, or at least the complex ones. Evidently, you're able to run RI with the Steam EXE, and you might be right that this is indeed recommended. Sounds like my code at least detected that the binary didn't look as expected.
To my understanding, from the point of dll modding, the differences between versions aren't that big. RI seems to work in more or less the same way on both.
I didn't even see those. I was trying to figure out where you got those images with think pink in that thread you linked and realized they're the colours of the transparent pixels in the tga. Like some invisible ink thing. Crazy. It looks like swapping out a character for a more narrow one and it seemed to work right. I'm curious if height works also. I'll look at that more.
Height doesn't, but one can offset the letters up/down (Q for example in the default charset). And yes, the engine reads the pink grid (and cyan dots) and alpha channels. And goes bonkers if even one pixel of those is out of place.
 
Here's the result so far, using Century Gothic:
That looks pretty cute.

How have you been editing the tga image? I wasted a few hours trying to wrangle GIMP into altering the rgb channels layer. A lot of operations, like cutting a selection, sets the alpha channel to zero but leaves the rgb channels as they were instead of clearing them. And when pasting a region the pixels with zero alpha values are not preserved. I've just been trying to test the height thing but can't edit the image correctly even by hand ._. So I'm curious how you tested changing the height?

Edit: I also was meaning to ask if you had all the characters used in that font atlas? The first couple rows are easy but after the first capital German ẞ thing it starts getting wild. I don't think it quite exactly matches any common codepage like windows-1252 or something. It shouldn't take too long to figure out myself but I haven't gotten around to it because I'm mostly just trying to manually test the font atlas height thing.
 
Last edited:
How have you been editing the tga image? I wasted a few hours trying to wrangle GIMP into altering the rgb channels layer. A lot of operations, like cutting a selection, sets the alpha channel to zero but leaves the rgb channels as they were instead of clearing them. And when pasting a region the pixels with zero alpha values are not preserved. I've just been trying to test the height thing but can't edit the image correctly even by hand ._. So I'm curious how you tested changing the height?
Well, I've been messing with Civ 4 graphics for... over 15 years now? I'm somewhat handy with Photoshop. And as I mentioned, this particular file is capricious as hell - there's no "easy" way of editing it. One has to keep stuff pixel perfect, keep all the lines perfectly intact and alpha channels tidy and never overlapping with the lines. Even after all these years, I'm almost never able to produce a working gamefont file on the first try. It's not just for fonts - as you probably saw, it's also all the small icons used in the game, resources, religions and such, so I've been editing that file quite a lot in my time. Unless you really need something from those files, like adding a new resource, I'd steer clear.
Edit: I also was meaning to ask if you had all the characters used in that font atlas? The first couple rows are easy but after the first capital German ẞ thing it starts getting wild. I don't think it quite exactly matches any common codepage like windows-1252 or something. It shouldn't take too long to figure out myself but I haven't gotten around to it because I'm mostly just trying to manually test the font atlas height thing.
I've been literally pasting the letters one by one into the file from an image: https://upload.wikimedia.org/wikipedia/commons/f/fb/Inkscape_Fonts_-_Century_Gothic.png (proper anti-aliasing is also a pain to set up when you're downscaling, but that's a separate thing). I haven't reached the special symbols yet, but I have no doubt Google has a sheet with them too, somewhere. Haven't checked thoroughly, but this probably has all I need: https://bestqfiles837.weebly.com/century-gothic-download-mac-free.html. Helps that I chose a relatively popular font.
 
One has to keep stuff pixel perfect, keep all the lines perfectly intact and alpha channels tidy and never overlapping with the lines.
I managed to double the height of the first row and manually replace each character in that row by hand. It's awful to do manually; I had to go back and fix several mistakes that I overlooked because it's precise and not easy to get right the first try. I think it's probably worth automating if it's valuable to have a tga available with larger characters for folks wanting to use larger fonts. Assuming it would work; which I'm not certain either way yet based on this result.

The city is building a "Storyteller Circle". It almost looks like for the text portion of the atlas, it expects the rows to have the same height. But there are some discrepancies that make me not sure about this. One thing is that the icons in the font atlast, like production and food, do appear to work fine shown in the tooltip. They're not altered except that their position in the texture atlas moved down a bit to make room for the expanded first row. However, their indexes in the atlas remain the same.

1688774069330.png


I attached the atlas but had to change the file extension because forum software. Also I didn't have the good sense to use a nice font like you did.
 

Attachments

  • GameFont.tga.txt
    4.2 MB · Views: 10
The city is building a "Storyteller Circle". It almost looks like for the text portion of the atlas, it expects the rows to have the same height. But there are some discrepancies that make me not sure about this. One thing is that the icons in the font atlast, like production and food, do appear to work fine shown in the tooltip. They're not altered except that their position in the texture atlas moved down a bit to make room for the expanded first row. However, their indexes in the atlas remain the same.
That's because there are two files. I don't recall if the font from gamefont_75 is used anywhere under normal circumstances, but icons certainly are, as your screenshot shows. All icons in your gamefont file are broken; easiest to see around the citybar which is supposed to have some icons, but probably easily verifiable in the pedia too. I'm not seeing them being displayed at all, which means the game likely failed to read further rows.
 
I'm not seeing them being displayed at all, which means the game likely failed to read further rows.
Well, I showed the info pane in the corner thinking the icons were taken the gamefont tga I modified. Since some were showing there correctly, then I figured at least those were loading with the modified file. But icons on the city bar are messed up as you pointed out. My last screenshot was a bad example because that city had no text or anything above its city bar. But in other cases, the city defense icon was using a revolutions icon 16 icons later in the atlas. And using a Judaism icon 12 icons before in place of Taoism. So something isn't right.

But I'd expect that if using larger cells in the atlas didn't work at all, that the larger cells in the first row would not render as they do. I'd expect them to at least be clipped. So it seems to me like it might work under some conditions, like all cells and rows have the same height. Obviously, doing that manually is time consuming. I made a testing grid of 256 cells each sized 23x23 and contains its index in hexadecimal as to see what cell is being rendered in the game.

1688821274932.png


The icons in the info text are unchanged, so they're probably using the other tga like you mentioned. Same with most of the UI like the spending in the top left and the scoreboard (not shown here).

Here's what it looks like stock Realism Invictus.

1688821939455.png


This is the test atlas, just to supplement my description of it earlier. Second image shows without alpha channel, so what the image would look like with every pixel totally opaque. The tga is attached as GameFont_testgrid23.tga.txt.

1688822239117.png
1688822256671.png


I forgot to mention it but earlier it appeared that spaces between words didn't increase with the larger first row height. I thought they might be hard coded because they also don't appear to be using a cell from the atlas. But I'm noticing now, in comparing the two images of the game, the space width is significantly different between the images in the production text of the city bar. So my guess is that it's half the width of some other character.

Anyway, if changing the cell height didn't work at all, I don't think it would behave like this. I would be surprised if the atlas worked with varying row heights. If they were, I wouldn't expect icons to be broken in my last post in the way that they were as you pointed out. So worst case is that increasing the font size in this atlas requires increasing the icon cells. Then keeping them smol and aligning them or trying to scale up with xBRZ or something might be options.

I think I'm going to look more into building the atlas with a script. (Assuming that's not been done yet?) And if it's useful for folks just trying to add icons for religions or concepts too then that would be a nice bonus. Which maybe doesn't come up that often, but if you think it could possibly be useful let me know what you want out of it. I'm assuming a Python 3 script that requires people to install the interpreter might not be as convenient as a windows executable. But maybe command line program that uses a text file and loose images to build the atlas might be nice?
 

Attachments

  • GameFont_testgrid23.tga.txt
    576 KB · Views: 8
I'm taking back the "different cells can't have different height" bit after further experimentation. I've managed to build a gamefont file that only scales up the font bits; it's not 100% there yet (some issues with later icons), but it's definitely possible, and I'll post it here after I'm done with it.
 
Yeah, that's a thing I've been meaning to do for a long while now. Changing the font there is a time-consuming and boring task, but it is possible with the right tools. This discussion has prompted me to resume, and I'm roughly half done (the half being I've finished all the capital letters). Here's the result so far, using Century Gothic:
For my part, I didn't mean to prompt any drudgery – but will be happy to utilize the results. Looks like at least one of you two is going to get somewhere. If the height can be increased after all, it's worth bearing mind that a higher billboard will have edges that can't be clicked or moused over – as is already the case with BUG's wider city bars (not adopted by K-Mod, neither by RI, it seems). Seems that the region that gets tested for mouse contact is somehow hardcoded in the EXE. A clever graphical design of an enlarged city bar might at least convey this limitation to the player. But, then, slighly higher letters may still fit onto the original city bar. On a related note, the position at which the Event log (Alt+Tab) appears by default also seems fixed in the EXE, meaning that it'll overlap the commerce sliders if the uper left corner of the HUD is enlarged past a certain point. If the player drags the log to a different position, the game will remember that position - but only for the current session. Similarly, the position of off-screen balloons/ pins, e.g. when the currently selected unit is not on the screen, appears to be set in the EXE. I expect that the enlarged minimap will cover it up if the unit is located toward the southeast. But none of these are a major problem, I think. If the height has to remain as it is, then the Gothic Century demo looks promising. Well, as I'm typing ...
I've managed to build a gamefont file that only scales up the font bits; it's not 100% there yet (some issues with later icons), but it's definitely possible, and I'll post it here after I'm done with it.

Perhaps @Nightinggale's GameFont Display could be useful while experimenting with the tga files. I guess, if so, then only at a later point as it doesn't show letters. But I had also meant to ping him because I doubt that he ventures this deep into the BtS modding subforums, and the CyGInterfaceScreen wrapper class (end of this post) might interest him; screenshots (before/ after) at the end of this post:
For fun, I tried an object (ScaledScreen) that wraps a CyGInterfaceScreen instance and forwards calls to it but applies a scaling factor to x, y, height, and width parameters and a reciprocal to `getXResolution()` and `getYResolution()`.
Nightinggale had also recently suggested enlarging the game font:
Size of GameFontIcons.
Isn't that just resizing the boxes in the tga file? I never tried it, but vanilla has BULLET_CHAR smaller than the other ones and indeed it has a different size ingame.

I think I'm going to look more into building the atlas with a script. (Assuming that's not been done yet?) And if it's useful for folks just trying to add icons for religions or concepts too then that would be a nice bonus. Which maybe doesn't come up that often, but if you think it could possibly be useful let me know what you want out of it. I'm assuming a Python 3 script that requires people to install the interpreter might not be as convenient as a windows executable. But maybe command line program that uses a text file and loose images to build the atlas might be nice?
Not aware of such a tool; yes, sounds nice. Not a great deal of Civ 4 modding happening anymore, of course.
 
Last edited:
There actually is a good tool for working with gamefont files; it's not useful for this particular task, but makes swapping out icons in an existing file much less of a chore and can even automatically repair mildly damaged files. Can't find it in the Downloads now, so just attaching it here.
 

Attachments

  • GameFontEditor.7z
    896.6 KB · Views: 11
There are a few xml settings I will like to point out as they may or may not be super useful for this topic. I will admit I haven't tried to change them so I have no real insights other than knowing they are there.

Assets\XML\Misc\CIV4DetailManager.xml
Has some constants, which might be useful for resizing billboards

Assets\XML\Art\CIV4ArtDefines_Misc.xml
Code:
		<MiscArtInfo>
			<Type>CITY_BILLBOARDS</Type>
			<Path>None</Path>
			<!-- positive scale: city billboards use fonts from GameFont.tga -->
			<!-- negative scale: GFC billboards (uses the interface font) -->
			<fScale>1.0</fScale>
			<NIF>None</NIF>
			<KFM>None</KFM>
		</MiscArtInfo>

With AdvCiv, the resource balloon sizing failed with a little red warning message in the game until I switched over to the "original_release_unsupported".
I added an error message to WTP at startup if steam is detected and not switched to original_release_unsupported because not switching results in several unpredictable glitches. The default steam version has worse mod support and there is nothing we can do about that.

I had a few issues with my debugger, it seemed Civ would close if I ever tried to do anything with breakpoints.
You are digging into the memory and is clearly installing some wallhack or similar. Steam detects this and crashes the game to prevent cheating. The solution is to either use the GOG version (or discs) or if you want to stick with the steam version, apply Steamless.

But if the pixel offsets aren't part of the EXE, then I don't know where else they would be. Perhaps the EXE scans the tga files in search of pink lines and light blue dots.
When I started modding ages ago, one of my relatively early tasks was cleaning up the tga in Medieval Conquest. I learned that pink is indeed how the exe tells the different icons apart as messing up pink had merged two icons. The dot is vertical offset. This can be used to make letters, which starts further down, like g is lower than d.

Yes, apparently the code segment that I had hypothesized to exist even in some slightly different build of the EXE is not in fact present in the Steam EXE.
Opening the steam and GOG exe files in something as simple as notepad++ (or hex editor obviously) reveals that the first few lines look really different due to the steam loader. I imagine the rest of the code is more or less the same, through it's plausible that the code will have different offsets or something like that. I hope that CD and DVD versions are identical to GOG, but I haven't investigated that part (yet?).

I don't think it quite exactly matches any common codepage like windows-1252 or something.
It is in fact trying to be codepage 1252, but it's not bug free. Which code page the game will use depends on the system locale so if you have players in say France, Poland and Russia you will technically get 3 different games as the system locales will provide 3 different code pages. It's a mess.

Even worse there are cases where the code assumes the character value to be the same as in unicode. This is fine for 1252 (and only that one) except for lines 8_ and 9_. I think it's billboards, which can mess up in this regard. Can't remember for sure through.

That's because there are two files. I don't recall if the font from gamefont_75 is used anywhere under normal circumstances, but icons certainly are, as your screenshot shows.
The one without a number is the default one used on billboards. The the 75 one is used if the font size is below 3 (or whatever it is). In fact I think there is an xml setting to control what the threshold is for changing the file. In essence it's a way to scale down icons to match tiny text. It is used in various locations with small text, such as help popup.

Perhaps @Nightinggale's GameFont Display could be useful while experimenting with the tga files. I guess, if so, then only at a later point as it doesn't show letters.
It has a loop to display icons. Rewriting that loop to cover the text values instead shouldn't be hard.

But I had also meant to ping him because I doubt that he ventures this deep into the BtS modding subforums
It happens, but certainly not often enough to make me notice this new thread. It is certainly an interesting one for multiple reasons.
 
Assets\XML\Art\CIV4ArtDefines_Misc.xml
Use of interface font would be great in theory, and would eliminate the need to mess with gamefont, but unfortunately it has hardcoded (low) width, so you could only use ridiculously short city names (like ~8 characters without clipping).
The one without a number is the default one used on billboards. The the 75 one is used if the font size is below 3 (or whatever it is). In fact I think there is an xml setting to control what the threshold is for changing the file. In essence it's a way to scale down icons to match tiny text. It is used in various locations with small text, such as help popup.
Yep, that's it. Do you recall if the font characters from the _75 are used anywhere? Or for that matter if the font characters are used anywhere at all other than the city billboard? I don't recall any other places I've seen them.
 
Yep, that's it. Do you recall if the font characters from the _75 are used anywhere? Or for that matter if the font characters are used anywhere at all other than the city billboard? I don't recall any other places I've seen them.
Signs too, through I believe that's it. I suspect _75 has to have the font characters in order to handle the non-font symbols (offset issue), but if they aren't actually used anywhere, updating them seems like a waste of time.
 
Top Bottom