mirror of https://github.com/OpenTTD/OpenTTD
(svn r21639) -Codechange: simplify setting the colour remap
parent
d2564a3e56
commit
1d21903eb4
15
src/gfx.cpp
15
src/gfx.cpp
|
@ -284,13 +284,14 @@ static void SetColourRemap(TextColour colour)
|
||||||
{
|
{
|
||||||
if (colour == TC_INVALID) return;
|
if (colour == TC_INVALID) return;
|
||||||
|
|
||||||
if (colour & TC_IS_PALETTE_COLOUR) {
|
/* Black strings have no shading ever; the shading is black, so it
|
||||||
_string_colourremap[1] = colour & ~TC_IS_PALETTE_COLOUR;
|
* would be invisible at best, but it actually makes it illegible. */
|
||||||
_string_colourremap[2] = (_use_palette == PAL_DOS) ? 1 : 215;
|
bool no_shade = colour == TC_BLACK;
|
||||||
} else {
|
bool raw_colour = colour & TC_IS_PALETTE_COLOUR;
|
||||||
_string_colourremap[1] = _string_colourmap[_use_palette][colour].text;
|
colour &= ~TC_IS_PALETTE_COLOUR;
|
||||||
_string_colourremap[2] = _string_colourmap[_use_palette][colour].shadow;
|
|
||||||
}
|
_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;
|
_colour_remap_ptr = _string_colourremap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,49 +206,44 @@ static const ExtraPaletteValues _extra_palette_values = {
|
||||||
};
|
};
|
||||||
#undef M
|
#undef M
|
||||||
|
|
||||||
/* Colour table for colours in lang files (e.g. {BLACK}) */
|
/** Colour mapping for the TextColours. */
|
||||||
struct StringColour {
|
static const byte _string_colourmap[][17] = {
|
||||||
byte text;
|
|
||||||
byte shadow;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const StringColour _string_colourmap[][17] = {
|
|
||||||
{ // DOS palette.
|
{ // DOS palette.
|
||||||
{ 150, 1 }, // TC_BLUE
|
150, // TC_BLUE
|
||||||
{ 12, 1 }, // TC_SILVER
|
12, // TC_SILVER
|
||||||
{ 189, 1 }, // TC_GOLD
|
189, // TC_GOLD
|
||||||
{ 184, 1 }, // TC_RED
|
184, // TC_RED
|
||||||
{ 174, 1 }, // TC_PURPLE
|
174, // TC_PURPLE
|
||||||
{ 30, 1 }, // TC_LIGHT_BROWN
|
30, // TC_LIGHT_BROWN
|
||||||
{ 195, 1 }, // TC_ORANGE
|
195, // TC_ORANGE
|
||||||
{ 209, 1 }, // TC_GREEN
|
209, // TC_GREEN
|
||||||
{ 68, 1 }, // TC_YELLOW
|
68, // TC_YELLOW
|
||||||
{ 95, 1 }, // TC_DARK_GREEN
|
95, // TC_DARK_GREEN
|
||||||
{ 79, 1 }, // TC_CREAM
|
79, // TC_CREAM
|
||||||
{ 116, 1 }, // TC_BROWN
|
116, // TC_BROWN
|
||||||
{ 15, 1 }, // TC_WHITE
|
15, // TC_WHITE
|
||||||
{ 152, 1 }, // TC_LIGHT_BLUE
|
152, // TC_LIGHT_BLUE
|
||||||
{ 6, 1 }, // TC_GREY
|
6, // TC_GREY
|
||||||
{ 133, 1 }, // TC_DARK_BLUE
|
133, // TC_DARK_BLUE
|
||||||
{ 1, 0 }, // TC_BLACK
|
1, // TC_BLACK
|
||||||
},
|
},
|
||||||
{ // Windows palette.
|
{ // Windows palette.
|
||||||
{ 150, 215 }, // TC_BLUE
|
150, // TC_BLUE
|
||||||
{ 12, 215 }, // TC_SILVER
|
12, // TC_SILVER
|
||||||
{ 189, 215 }, // TC_GOLD
|
189, // TC_GOLD
|
||||||
{ 184, 215 }, // TC_RED
|
184, // TC_RED
|
||||||
{ 174, 215 }, // TC_PURPLE
|
174, // TC_PURPLE
|
||||||
{ 30, 215 }, // TC_LIGHT_BROWN
|
30, // TC_LIGHT_BROWN
|
||||||
{ 195, 215 }, // TC_ORANGE
|
195, // TC_ORANGE
|
||||||
{ 209, 215 }, // TC_GREEN
|
209, // TC_GREEN
|
||||||
{ 68, 215 }, // TC_YELLOW
|
68, // TC_YELLOW
|
||||||
{ 95, 215 }, // TC_DARK_GREEN
|
95, // TC_DARK_GREEN
|
||||||
{ 79, 215 }, // TC_CREAM
|
79, // TC_CREAM
|
||||||
{ 116, 215 }, // TC_BROWN
|
116, // TC_BROWN
|
||||||
{ 15, 215 }, // TC_WHITE
|
15, // TC_WHITE
|
||||||
{ 152, 215 }, // TC_LIGHT_BLUE
|
152, // TC_LIGHT_BLUE
|
||||||
{ 32, 215 }, // TC_GREY
|
32, // TC_GREY
|
||||||
{ 133, 215 }, // TC_DARK_BLUE
|
133, // TC_DARK_BLUE
|
||||||
{ 215, 0 }, // TC_BLACK
|
215, // TC_BLACK
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue