diff options
author | rubidium <rubidium@openttd.org> | 2009-09-11 22:21:54 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-09-11 22:21:54 +0000 |
commit | 1dc2284e0c5ec9240379ea105317cb0b04e1c143 (patch) | |
tree | 8aeb698b260c4c2c4a19d461c53ff428564d9ab6 /src | |
parent | a10d84197028de074d41d16e893bf041541cb566 (diff) | |
download | openttd-1dc2284e0c5ec9240379ea105317cb0b04e1c143.tar.xz |
(svn r17506) -Fix [FS#3191]: signs partly drawn out of the rectangle in 4/8x zoom out.
Diffstat (limited to 'src')
-rw-r--r-- | src/smallmap_gui.cpp | 4 | ||||
-rw-r--r-- | src/viewport.cpp | 59 |
2 files changed, 25 insertions, 38 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index ae360fea2..7e1757005 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -798,13 +798,13 @@ public: this->RemapX(TileX(t->xy)), this->RemapY(TileY(t->xy)), 0); - x = pt.x - this->subscroll + 3 - (t->sign.width_small >> 1); + x = pt.x - this->subscroll - (t->sign.width_small >> 1); y = pt.y; /* Check if the town sign is within bounds */ if (x + t->sign.width_small > dpi->left && x < dpi->left + dpi->width && - y + 6 > dpi->top && + y + FONT_HEIGHT_SMALL > dpi->top && y < dpi->top + dpi->height) { /* And draw it. */ SetDParam(0, t->index); diff --git a/src/viewport.cpp b/src/viewport.cpp index bb998127e..198eeee1b 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1279,12 +1279,12 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str) char buffer[DRAW_STRING_BUFFER]; GetString(buffer, str, lastof(buffer)); - this->width_normal = GetStringBoundingBox(buffer).width + 3; + this->width_normal = GetStringBoundingBox(buffer).width; this->left = center - this->width_normal / 2; /* zoomed out version */ _cur_fontsize = FS_SMALL; - this->width_small = GetStringBoundingBox(buffer).width + 3; + this->width_small = GetStringBoundingBox(buffer).width; _cur_fontsize = FS_NORMAL; this->MarkDirty(); @@ -1428,58 +1428,45 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDrawVect const StringSpriteToDraw *ssend = sstdv->End(); for (const StringSpriteToDraw *ss = sstdv->Begin(); ss != ssend; ++ss) { - TextColour colour; + TextColour colour = TC_BLACK; + bool small = HasBit(ss->width, 15); + int w = GB(ss->width, 0, 15); + int x = UnScaleByZoom(ss->x, zoom); + int y = UnScaleByZoom(ss->y, zoom); + int bottom = y + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL); + + SetDParam(0, ss->params[0]); + SetDParam(1, ss->params[1]); - if (ss->width != 0) { + if (w != 0) { /* Do not draw signs nor station names if they are set invisible */ if (IsInvisibilitySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) continue; - int x = UnScaleByZoom(ss->x, zoom) - 1; - int y = UnScaleByZoom(ss->y, zoom) - 1; - int bottom = y + 11; - int w = ss->width; - - if (w & 0x8000) { - w &= ~0x8000; - y--; - bottom -= 6; - w -= 3; + /* if we didn't draw a rectangle, or if transparant building is on, + * draw the text in the colour the rectangle would have */ + if (IsTransparencySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) { + /* Real colours need the IS_PALETTE_COLOUR flag + * otherwise colours from _string_colourmap are assumed. */ + colour = (TextColour)_colour_gradient[ss->colour][6] | IS_PALETTE_COLOUR; } - /* Draw the rectangle if 'tranparent station signs' is off, - * or if we are drawing a general text sign (STR_WHITE_SIGN) */ + /* Draw the rectangle if 'tranparent station signs' is off, + * or if we are drawing a general text sign (STR_WHITE_SIGN) */ if (!IsTransparencySet(TO_SIGNS) || ss->string == STR_WHITE_SIGN) { DrawFrameRect( - x, y, x + w, bottom, (Colours)ss->colour, + x - 1, y - 1, x + 1 + w, bottom, (Colours)ss->colour, IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE ); } - } - SetDParam(0, ss->params[0]); - SetDParam(1, ss->params[1]); - /* if we didn't draw a rectangle, or if transparant building is on, - * draw the text in the colour the rectangle would have */ - if (IsTransparencySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN && ss->width != 0) { - /* Real colours need the IS_PALETTE_COLOUR flag - * otherwise colours from _string_colourmap are assumed. */ - colour = (TextColour)_colour_gradient[ss->colour][6] | IS_PALETTE_COLOUR; + if (small) y -= 1; } else { - colour = TC_BLACK; - } - - /* The maximum width of the string */ - int w = GB(ss->width, 0, 15); - if (w == 0) { char buffer[DRAW_STRING_BUFFER]; GetString(buffer, ss->string, lastof(buffer)); w = GetStringBoundingBox(buffer).width; } - DrawString( - UnScaleByZoom(ss->x, zoom), UnScaleByZoom(ss->x, zoom) + w - 1, UnScaleByZoom(ss->y, zoom) - (ss->width & 0x8000 ? 2 : 0), - ss->string, colour, SA_CENTER - ); + DrawString(x, x + w - 1, y, ss->string, colour, SA_CENTER); } } |