Improving Our Buttons Using a Theme

EmperorFool

Deity
Joined
Mar 2, 2007
Messages
9,633
Location
Mountain View, California
Dresden pointed me to a thread that shows how to use a theme to create our own buttons that behave just like Civ's minimap/advisor buttons, meaning they

  • Highlight when you hover
  • Can be prettier: no scaling means no blurriness
  • Can be cooler: different images for the different states (hover, click, toggled)
The downside? They require modifying the Theme files either a) in the Civ4 install folder itself or b) in BUG installed as a mod. Themes do not work from CustomAssets. :(

Note that we would add button definitions to the Civ4 theme files under (a) without affecting the game when not running BUG or using a different mod. We won't replace any Civ4 objects. You would only see a difference when running BUG. In the (b) case, this isn't even an issue since all the files would be in the BUG Mod folder.

How do users feel about this? I know that even though we can assert that our changes won't affect the regular game, people may feel skittish about modifying core Civ4 files. We would of course make a backup of the file.

And it would of course be up to you, NikNaks, to create these new buttons, but I think you're game if it means no more blurry buttons, right? Also, the buttons should be easier to make as the base button background is separate from the image that goes on the individual button--just like you were proposing for a font-symbol-based button. And they're TGAs allowing non-power-of-2 sizes.

Making the Change

We need to add a single line to the file "Resource/Themes/Civ4/Civ4Theme.thm":

include "Civ4Theme_BUG.thm";​

And then add a new file to that same directory: "Civ4Theme_BUG.thm". We should be able to make the installer act differently depending on how they install BUG.
 
Going to be a PITA to install it since people use different locations for the actual program. Mine is in C:\Program Files\Games\Civ4\BTS for example.
 
Actually, BUG can do it the first time it starts up, but they'll have to restart Civ4 to see the buttons. From Python I can get the full path to the Civ4 EXE and from that the Themes folder. In fact, that's better because then using Python I can append our include to the existing file, so if they have some other mod that did the same thing, they won't lose their existing changes.

I can even have BUG check for the changes and put up a message saying they must restart Civ if they aren't there. I need to clean up CvModName (create a new one I think now) to specify whether BUG is running as a mod or via CA folder. Unfortunately, there's no way to tell this from Python. :(
 
Only just noticed this. How would this affect Locked Modified Assets (LMA) or people using the HOF mod which requires LMA? If it caused the CRC checks to fail then I think you should restrict this to BUG installed as a mod.
 
I believe NikNaks is correct. It's been a while since I played a HoF game, but I think I was using BlueMarble at the time. These buttons would be installed the same way as BM's HUD graphics.

That being said, thanks for pointing out a necessary test case. If it does affect LMA, we will have to dump it. I don't want to have the CA vs. Mods code for BUG be that different, so it's either all or none I'm afraid.
 
That's why I said, an interface change would be ~40-50MB.

Adding new buttons won't take much space: a few hundred kilobytes or so for the images. The size explosion comes from replacing all the panels a la the tutorial linked to from the tutorial you posted.
 
Of course, this won't be as easy as I had hoped. I hadn't thought about the ramifications of SVN and ZIP users. The problem is that we'll need to install files into two locations for use with CustomAssets, and I'm not sure how to make this as easy as possible for SVN users.

Pure-SVN Method

Have two repo locations: Mod (holds CustomAssets and PublicMaps) and Themes (holds theme). To initially checkout BUG, you'd have to checkout the two folders into the correct locations: "My Games\BTS" and "BTS", respectively.

Then you'd have to remember to update both places to get all changes. If I finish auto-update, this part would be handled for the user.

Update-and-Copy Method

Checkout files into a single location as now. Then everything Civ4 was launched, BUG would check to see if any of the theme files were different (compare file sizes) and copy those that were changed.

I prefer the first solution, but I'll need to complete auto-update. I suppose this is a good incentive to finish it.

Note: I did test out having the theme files in the CustomAssets folder successfully. The problem is that the .thm file must point to all the graphic files using absolute file names. This would require BUG to modify the file after the user did an install/update, and I really really really want to avoid modifying files in-line and messing around further with paths. Besides, I have no idea how Civ4 would handle file paths that require unicode characters in the .thm file.
 
Top Bottom