Changeset - r13002:d6a902b42116
[Not reviewed]
master
0 2 0
rubidium - 15 years ago 2009-09-11 22:21:54
rubidium@openttd.org
(svn r17506) -Fix [FS#3191]: signs partly drawn out of the rectangle in 4/8x zoom out.
2 files changed with 27 insertions and 40 deletions:
0 comments (0 inline, 0 general)
src/smallmap_gui.cpp
Show inline comments
 
@@ -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);
src/viewport.cpp
Show inline comments
 
@@ -1279,12 +1279,12 @@ void ViewportSign::UpdatePosition(int ce
 
	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(DrawPixe
 

	
 
	const StringSpriteToDraw *ssend = sstdv->End();
 
	for (const StringSpriteToDraw *ss = sstdv->Begin(); ss != ssend; ++ss) {
 
		TextColour colour;
 

	
 
		if (ss->width != 0) {
 
		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 (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);
 
	}
 
}
 

	
0 comments (0 inline, 0 general)