For a yet another trip to CS geek land, I present to you:
Adventures with color palettes in Campaign Series
Revising the remaining dialogs and creating the new Unit List, it became obvious that one of the areas where CS code was not optimized was the various definitions and uses of color, which were hardcoded throughout the codebase.
For our games, we have a neat set of standard colors based on US Army camo
MERDC standard of the past. This was properly followed in many places, though still often implemented using hardcoded RGB number value sets.
Misc.h provided a solid starting point to enforce the standards once and for all, as it is the header file for most of the hardcoded values used in the game engine. I added the following section there. In future, change any of the RGB sets here and only here for a global effect within all game executables:
Code: Select all
// PHN46: CS Camo color standards
// MERDC camo colors
#define MERDCWHITECOLOR PALETTERGB(242, 241, 234) // MERDC White
#define MERDCDESERTSANDCOLOR PALETTERGB(183, 157, 138) // MERDC Desert Sand
#define MERDCSANDCOLOR PALETTERGB(176, 161, 131) // MERDC Sand
#define MERDCEARTHYELLOWCOLOR PALETTERGB(195, 155, 105) // MERDC Earth Yellow
#define MERDCEARTHREDCOLOR PALETTERGB(135, 72, 64) // MERDC Earth Red
#define MERDCFIELDDRABCOLOR PALETTERGB(123, 105, 78) // MERDC Field Drab
#define MERDCEARTHBROWNCOLOR PALETTERGB(137, 103, 80) // MERDC Earth Brown
#define MERDCOLIVEDRABCOLOR PALETTERGB(85, 79, 68) // MERDC Olive Drab
#define MERDCLIGHTGREENCOLOR PALETTERGB(113, 112, 72) // MERDC Light Green
#define MERDCDARKGREENCOLOR PALETTERGB(99, 103, 80) // MERDC Dark Green
#define MERDCFORESTGREENCOLOR PALETTERGB(89, 92, 78) // MERDC Forest Green
#define MERDCBLACKCOLOR PALETTERGB(66, 66, 67) // MERDC Black
// Subdued highlight colors
#define W3HIGHWAYBROWNCOLOR PALETTERGB(99, 53, 23) // FS595 (10055) w3-highway-brown
#define W3HIGHWAYREDCOLOR PALETTERGB(166, 0, 26) // FS595 (11086) w3-highway-red
#define W3HIGHWAYORANGECOLOR PALETTERGB(224, 96, 0) // FS595 (12243) w3-highway-orange
#define W3HIGHWAYSCHOOLBUSCOLOR PALETTERGB(238, 150, 0) // FS595 (13415) w3-highway-schoolbus
#define W3HIGHWAYYELLOWCOLOR PALETTERGB(255, 171, 0) // FS595 (13507) w3-highway-yellow
#define W3HIGHWAYGREENCOLOR PALETTERGB(0, 77, 51) // FS595 (14066) w3-highway-green
#define W3HIGHWAYBLUECOLOR PALETTERGB(0, 71, 126) // FS595 (15065) w3-highway-blue
// Subdued basic colors
#define OFFWHITECOLOR MERDCWHITECOLOR
#define OFFBLACKCOLOR MERDCBLACKCOLOR
#define OFFREDCOLOR W3HIGHWAYREDCOLOR
#define OFFBLUECOLOR W3HIGHWAYBLUECOLOR
#define OFFGREENCOLOR W3HIGHWAYGREENCOLOR
#define OFFYELLOWCOLOR PALETTERGB (255,204,0) // Our yellow font color
I adapted the MERDC FS 595 codes to hex and RGB values using the Encycolorpedia site. I used to build models as a kid - didn't we all - so I also looked through various modeler guides for further assistance. See this
guideline document for instance, it lists the MERDC color sets for various applications. This
modeler site was a revelation as well. Ah, MERDC. So overly complicated. Love it!
For the Middle East game, dialog borders use the Sand color from the Desert Grey MERDC pattern, while the dialog backgrounds use Field Drab. Dialog text is rendered in MERDC White for a matching feel. See the Scenario launcher, for instance:
(To be precise, I let the windows controls such as titlebars and buttons use system colors, while the text background - and text - for radio buttons and checkboxes follow the OFFWHITECOLOR / OFFBLACKCOLOR definitions that in turn redirect to MERDCWHITECOLOR and MERDCBLACKCOLOR hues.)
For the Vietnam game, the MERDC tropic pattern suggested the Forest Green / Dark Green pairing. But since both colors are quite dark, I decided to tint the dialog borders three steps lighter from MERDC Dark Green. This creates a matching light-border / dark-background dialog look, consistent with the Middle East game:
Now you know.
For the basic border and background colors, the definitions are now clearly stated. Previously, they looked like this, at best:
Code: Select all
#define MEDIUMSANDCOLOR PALETTERGB (176,161,131) // ScenInfo.bmp frame
#define DARKSANDCOLOR PALETTERGB (127,100,75) // ScenInfo.bmp background
Now, what was previously defined in a standardized way but often by using raw number sequences, all that is now replaced with references to the above basic set of standard colors.
For instance, the above example in this new format:
Code: Select all
#define MEDIUMSANDCOLOR MERDCSANDCOLOR
#define DARKSANDCOLOR MERDCFIELDDRABCOLOR
... or:
Code: Select all
#define OFFWHITECOLOR MERDCWHITECOLOR
#define OFFBLACKCOLOR MERDCBLACKCOLOR
With the above basic set established, I then reviewed areas in the code where "PALETTERGB" was still being used. This indicated hardcoded color values that needed to be replaced with one of the standardized color definitions.
For instance, the section where map labels are drawn now reads:
Code: Select all
case BorderLabel:
switch (color) {
case Black :
dc.SetTextColor(OFFBLACKCOLOR); // (PALETTERGB(0, 0, 0)); // black
break;
case Red :
dc.SetTextColor(OFFREDCOLOR); //(PALETTERGB(255, 0, 0)); // red
break;
case Green :
dc.SetTextColor(OFFGREENCOLOR); //(PALETTERGB(0, 102, 0)); // dark green
break;
case Blue :
dc.SetTextColor(OFFBLUECOLOR); //(PALETTERGB(0, 0, 255)); // blue
break;
}
One of the many places with locally hardcoded RGB palettes. Now commented out, and replaced by the global define sets per above.
Again, the key improvement was this:
- dc.SetTextColor(OFFBLACKCOLOR); instead of
- dc.SetTextColor(PALETTERGB(0, 0, 0));
This is much easier to read, and it ensures a consistent, centralized color definition that uses more subdued shades of colors. In this example: a subdued black rather than pure, deep black, which blends better with the overall palette.
Here’s a screenshot showing label text colors updated from Pure Blue to Highway Blue, Red to Offcolorred, and Green to Highway Green

- labels3.jpg (1.15 MiB) Viewed 2264 times
(Highway colors? Yes, there’s a set of standard colors that highway signs are meant to use, and there’s a neat connection to our text and label rendering in many places. They’re also nicely subdued and pleasing to the eye. I came across them while browsing through the various camo sets listed on this
w3school website, which covers several national color standards including the US FS 595 standard.)
That’s the Transparent Enhanced frosted font (which introduces a noticeable overhead, btw), but it used to be the most aesthetic option.
A pleasant surprise: the Transparent map label texts now render quite nicely as well. They’ve become a genuine option with the new, more subdued color palette in use. To improve performance (over the frosted font), I reintroduced the Opaque Map Labels as well:

- labels4.jpg (1.09 MiB) Viewed 2264 times
(^ opaque text background reintroduces the issue where burning wreck animations in 3D interfere with them. Not a too steep a price to be paid for them, I hope.)
In a related note, while reviewing various 8-bit 256-color bitmaps still used by the game engine, I came across Colors.bmp, a file I had never quite figured out the purpose of. Since 8-bit files don’t support a full color palette, I’ve been gradually removing them as part of the UI revamp.
Turns out, Colors.bmp is actually used for outline drawing. The unit outline files (the Op*.BIT files) are black-and-white images, with the unit outline in black and the background in white. The code takes the BIT file, uses the selected highlight color index, and pulls the corresponding color from Colors.bmp and then displays the black outline using that selected cell color.

- Colors.jpg (3.67 KiB) Viewed 2263 times
Colors.bmp was originally 1600×100 pixels in size, and that turned out to be the clue behind some of the outline discoloration: some of the newer Up/Op pairings are taller, up to 128 pixels even. Then I found out it many cases it was not the height but width that was the issue.
To resolve this, I enlarged Colors.bmp to 2240×140 pixels, which fixed the issue nicely, confirmed with this rather wide unit image of an Egyptian D-46 gun. Previously, the gun barrel extended into the neon green cell to the right of the selected yellow highlight cell. No longer! A most satisfying little win!

- outline_x.jpg (64.99 KiB) Viewed 2263 times