summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-25 19:59:56 +0000
committerrubidium <rubidium@openttd.org>2010-12-25 19:59:56 +0000
commit1d21903eb40cc4463c3fd01a4e14129a14b07445 (patch)
tree8fe70454fc44571d398d0f7638c4b4533fd5d160
parentd2564a3e56aca3ca6b253eb2b2c8f4911102d498 (diff)
downloadopenttd-1d21903eb40cc4463c3fd01a4e14129a14b07445.tar.xz
(svn r21639) -Codechange: simplify setting the colour remap
-rw-r--r--src/gfx.cpp15
-rw-r--r--src/table/palettes.h77
2 files changed, 44 insertions, 48 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 594a2d2cb..0a61805ca 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -284,13 +284,14 @@ static void SetColourRemap(TextColour colour)
{
if (colour == TC_INVALID) return;
- if (colour & TC_IS_PALETTE_COLOUR) {
- _string_colourremap[1] = colour & ~TC_IS_PALETTE_COLOUR;
- _string_colourremap[2] = (_use_palette == PAL_DOS) ? 1 : 215;
- } else {
- _string_colourremap[1] = _string_colourmap[_use_palette][colour].text;
- _string_colourremap[2] = _string_colourmap[_use_palette][colour].shadow;
- }
+ /* Black strings have no shading ever; the shading is black, so it
+ * would be invisible at best, but it actually makes it illegible. */
+ bool no_shade = colour == TC_BLACK;
+ bool raw_colour = colour & TC_IS_PALETTE_COLOUR;
+ colour &= ~TC_IS_PALETTE_COLOUR;
+
+ _string_colourremap[1] = raw_colour ? (byte)colour : _string_colourmap[_use_palette][colour];
+ _string_colourremap[2] = no_shade ? 0 : (_use_palette == PAL_DOS ? 1 : 215);
_colour_remap_ptr = _string_colourremap;
}
diff --git a/src/table/palettes.h b/src/table/palettes.h
index 68f74377f..719725a1d 100644
--- a/src/table/palettes.h
+++ b/src/table/palettes.h
@@ -206,49 +206,44 @@ static const ExtraPaletteValues _extra_palette_values = {
};
#undef M
-/* Colour table for colours in lang files (e.g. {BLACK}) */
-struct StringColour {
- byte text;
- byte shadow;
-};
-
-static const StringColour _string_colourmap[][17] = {
+/** Colour mapping for the TextColours. */
+static const byte _string_colourmap[][17] = {
{ // DOS palette.
- { 150, 1 }, // TC_BLUE
- { 12, 1 }, // TC_SILVER
- { 189, 1 }, // TC_GOLD
- { 184, 1 }, // TC_RED
- { 174, 1 }, // TC_PURPLE
- { 30, 1 }, // TC_LIGHT_BROWN
- { 195, 1 }, // TC_ORANGE
- { 209, 1 }, // TC_GREEN
- { 68, 1 }, // TC_YELLOW
- { 95, 1 }, // TC_DARK_GREEN
- { 79, 1 }, // TC_CREAM
- { 116, 1 }, // TC_BROWN
- { 15, 1 }, // TC_WHITE
- { 152, 1 }, // TC_LIGHT_BLUE
- { 6, 1 }, // TC_GREY
- { 133, 1 }, // TC_DARK_BLUE
- { 1, 0 }, // TC_BLACK
+ 150, // TC_BLUE
+ 12, // TC_SILVER
+ 189, // TC_GOLD
+ 184, // TC_RED
+ 174, // TC_PURPLE
+ 30, // TC_LIGHT_BROWN
+ 195, // TC_ORANGE
+ 209, // TC_GREEN
+ 68, // TC_YELLOW
+ 95, // TC_DARK_GREEN
+ 79, // TC_CREAM
+ 116, // TC_BROWN
+ 15, // TC_WHITE
+ 152, // TC_LIGHT_BLUE
+ 6, // TC_GREY
+ 133, // TC_DARK_BLUE
+ 1, // TC_BLACK
},
{ // Windows palette.
- { 150, 215 }, // TC_BLUE
- { 12, 215 }, // TC_SILVER
- { 189, 215 }, // TC_GOLD
- { 184, 215 }, // TC_RED
- { 174, 215 }, // TC_PURPLE
- { 30, 215 }, // TC_LIGHT_BROWN
- { 195, 215 }, // TC_ORANGE
- { 209, 215 }, // TC_GREEN
- { 68, 215 }, // TC_YELLOW
- { 95, 215 }, // TC_DARK_GREEN
- { 79, 215 }, // TC_CREAM
- { 116, 215 }, // TC_BROWN
- { 15, 215 }, // TC_WHITE
- { 152, 215 }, // TC_LIGHT_BLUE
- { 32, 215 }, // TC_GREY
- { 133, 215 }, // TC_DARK_BLUE
- { 215, 0 }, // TC_BLACK
+ 150, // TC_BLUE
+ 12, // TC_SILVER
+ 189, // TC_GOLD
+ 184, // TC_RED
+ 174, // TC_PURPLE
+ 30, // TC_LIGHT_BROWN
+ 195, // TC_ORANGE
+ 209, // TC_GREEN
+ 68, // TC_YELLOW
+ 95, // TC_DARK_GREEN
+ 79, // TC_CREAM
+ 116, // TC_BROWN
+ 15, // TC_WHITE
+ 152, // TC_LIGHT_BLUE
+ 32, // TC_GREY
+ 133, // TC_DARK_BLUE
+ 215, // TC_BLACK
}
};