Mercurial > hg > openttd
changeset 11087:1b6173594ff3 draft
(svn r15431) -Fix (r15425): wrongly added assertion due to unneeded & 0xFF. Now use the same method of handling the colour as it would do when drawing a string instead of a character.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 09 Feb 2009 10:31:37 +0000 |
parents | 23adfa4f7d5a |
children | 43660f731f0e |
files | src/gfx.cpp |
diffstat | 1 files changed, 21 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -234,6 +234,23 @@ GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx2, y + dy3 + dy2, colour); } +/** + * Set the colour remap to be for the given colour. + * @param colour the new colour of the remap. + */ +static void SetColourRemap(TextColour colour) +{ + if (colour == TC_INVALID) return; + + if (colour & IS_PALETTE_COLOUR) { + _string_colourremap[1] = colour & ~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; + } + _colour_remap_ptr = _string_colourremap; +} #if !defined(WITH_ICU) static void HandleBiDiAndArabicShapes(char *text, const char *lastof) {} @@ -833,20 +850,12 @@ * @param c Character (glyph) to draw * @param x X position to draw character * @param y Y position to draw character - * @param real_colour Colour to use, see DoDrawString() for details + * @param colour Colour to use, see DoDrawString() for details */ void DrawCharCentered(WChar c, int x, int y, TextColour colour) { - FontSize size = FS_NORMAL; - assert(colour & IS_PALETTE_COLOUR); - colour &= ~IS_PALETTE_COLOUR; - int w = GetCharacterWidth(size, c); - - _string_colourremap[1] = _string_colourmap[_use_palette][colour].text; - _string_colourremap[2] = _string_colourmap[_use_palette][colour].shadow; - _colour_remap_ptr = _string_colourremap; - - GfxMainBlitter(GetGlyph(size, c), x - w / 2, y, BM_COLOUR_REMAP); + SetColourRemap(colour); + GfxMainBlitter(GetGlyph(FS_NORMAL, c), x - GetCharacterWidth(FS_NORMAL, c) / 2, y, BM_COLOUR_REMAP); } /** Draw a string at the given coordinates with the given colour. @@ -908,14 +917,7 @@ if (colour != TC_INVALID) { // the invalid colour flag test should not really occur. But better be safe switch_colour:; - if (colour & IS_PALETTE_COLOUR) { - _string_colourremap[1] = colour & ~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; - } - _colour_remap_ptr = _string_colourremap; + SetColourRemap(colour); } }