Changeset - r9607:03e00693be33
[Not reviewed]
master
0 12 0
frosch - 16 years ago 2008-06-28 15:44:24
frosch@openttd.org
(svn r13649) -Codechange: Split the GfxFillRect() special flags from 'color' into their own parameter.
12 files changed with 54 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/engine_gui.cpp
Show inline comments
 
@@ -202,7 +202,7 @@ void DrawNewsNewVehicleAvail(Window *w, 
 
	DrawStringMultiCenter(w->width >> 1, 57, STR_NEW_VEHICLE_TYPE, w->width - 2);
 

	
 
	dei->engine_proc(w->width >> 1, 88, engine, 0);
 
	GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE));
 
	GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOR);
 
	dei->info_proc(engine, w->width >> 1, 129, w->width - 52);
 
}
 

	
src/gfx.cpp
Show inline comments
 
@@ -89,7 +89,21 @@ void GfxScroll(int left, int top, int wi
 
}
 

	
 

	
 
void GfxFillRect(int left, int top, int right, int bottom, int color)
 
/**
 
 * Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
 
 *
 
 * @pre dpi->zoom == ZOOM_LVL_NORMAL, right >= left, bottom >= top
 
 * @param left Minimum X (inclusive)
 
 * @param top Minimum Y (inclusive)
 
 * @param right Maximum X (inclusive)
 
 * @param bottom Maximum Y (inclusive)
 
 * @param color A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolor spritenumber (FILLRECT_RECOLOR)
 
 * @param mode
 
 *         FILLRECT_OPAQUE:   Fill the rectangle with the specified color
 
 *         FILLRECT_CHECKER:  Like FILLRECT_OPAQUE, but only draw every second pixel (used to grey out things)
 
 *         FILLRECT_RECOLOR:  Apply a recolor sprite to every pixel in the rectangle currently on screen
 
 */
 
void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMode mode)
 
{
 
	Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
 
	const DrawPixelInfo *dpi = _cur_dpi;
 
@@ -116,18 +130,23 @@ void GfxFillRect(int left, int top, int 
 

	
 
	dst = blitter->MoveTo(dpi->dst_ptr, left, top);
 

	
 
	if (!HasBit(color, PALETTE_MODIFIER_GREYOUT)) {
 
		if (!HasBit(color, USE_COLORTABLE)) {
 
	switch (mode) {
 
		default: // FILLRECT_OPAQUE
 
			blitter->DrawRect(dst, right, bottom, (uint8)color);
 
		} else {
 
			break;
 

	
 
		case FILLRECT_RECOLOR:
 
			blitter->DrawColorMappingRect(dst, right, bottom, GB(color, 0, PALETTE_WIDTH));
 
			break;
 

	
 
		case FILLRECT_CHECKER: {
 
			byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
 
			do {
 
				for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)color);
 
				dst = blitter->MoveTo(dst, 0, 1);
 
			} while (--bottom > 0);
 
			break;
 
		}
 
	} else {
 
		byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
 
		do {
 
			for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)color);
 
			dst = blitter->MoveTo(dst, 0, 1);
 
		} while (--bottom > 0);
 
	}
 
}
 

	
src/gfx_func.h
Show inline comments
 
@@ -99,7 +99,7 @@ void DrawStringRightAlignedUnderline(int
 

	
 
void DrawCharCentered(uint32 c, int x, int y, uint16 color);
 

	
 
void GfxFillRect(int left, int top, int right, int bottom, int color);
 
void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMode mode = FILLRECT_OPAQUE);
 
void GfxDrawLine(int left, int top, int right, int bottom, int color);
 
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
 

	
src/gfx_type.h
Show inline comments
 
@@ -216,4 +216,11 @@ enum StringColorFlags {
 
	IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor
 
};
 

	
 
/** Define the operation GfxFillRect performs */
 
enum FillRectMode {
 
	FILLRECT_OPAQUE,  ///< Fill rectangle with a single color
 
	FILLRECT_CHECKER, ///< Draw only every second pixel, used for greying-out
 
	FILLRECT_RECOLOR, ///< Apply a recolor sprite to the screen content
 
};
 

	
 
#endif /* GFX_TYPE_H */
src/news_gui.cpp
Show inline comments
 
@@ -51,7 +51,7 @@ static void DrawNewsBankrupcy(Window *w,
 
{
 
	Player *p = GetPlayer((PlayerID)(ni->data_b));
 
	DrawPlayerFace(p->face, p->player_color, 2, 23);
 
	GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE));
 
	GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOR);
 

	
 
	SetDParam(0, p->index);
 

	
 
@@ -233,7 +233,7 @@ struct NewsWindow : Window {
 
					ViewPort *vp = this->viewport;
 
					GfxFillRect(vp->left - this->left, vp->top - this->top,
 
						vp->left - this->left + vp->width - 1, vp->top - this->top + vp->height - 1,
 
						(this->ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE)
 
						(this->ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY), FILLRECT_RECOLOR
 
					);
 

	
 
					CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
src/rail_gui.cpp
Show inline comments
 
@@ -1070,7 +1070,7 @@ public:
 

	
 
				if (statspec != NULL && statspec->name != 0) {
 
					if (HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
 
						GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT));
 
						GfxFillRect(8, y - 2, 127, y + 10, 0, FILLRECT_CHECKER);
 
					}
 

	
 
					DrawStringTruncated(9, y, statspec->name, i == _railstation.station_type ? TC_WHITE : TC_BLACK, 118);
 
@@ -1606,7 +1606,7 @@ public:
 
				if (statspec != NULL &&
 
						HasBit(statspec->callbackmask, CBM_STATION_AVAIL) &&
 
						GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
 
					GfxFillRect(4 + i * 68, 18, 67 + i * 68, 75, (1 << PALETTE_MODIFIER_GREYOUT));
 
					GfxFillRect(4 + i * 68, 18, 67 + i * 68, 75, 0, FILLRECT_CHECKER);
 
				}
 
			}
 
		}
src/settings_gui.cpp
Show inline comments
 
@@ -1005,7 +1005,7 @@ void ShowPatchesSelection()
 
 */
 
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
 
{
 
	int color = (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[COLOUR_YELLOW][2];
 
	int color = _colour_gradient[COLOUR_YELLOW][2];
 

	
 
	DrawFrameRect(x,      y + 1, x +  9, y + 9, ctab, (state == 1) ? FR_LOWERED : FR_NONE);
 
	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : FR_NONE);
 
@@ -1014,9 +1014,9 @@ void DrawArrowButtons(int x, int y, int 
 

	
 
	/* Grey out the buttons that aren't clickable */
 
	if (!clickable_left)
 
		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, color);
 
		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, color, FILLRECT_CHECKER);
 
	if (!clickable_right)
 
		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
 
		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color, FILLRECT_CHECKER);
 
}
 

	
 
/** These are not, strickly speaking, widget enums,
src/table/sprites.h
Show inline comments
 
@@ -1471,12 +1471,6 @@ enum Modifiers {
 
	PALETTE_MODIFIER_TRANSPARENT  = TRANSPARENT_BIT,
 
	///this bit is set when a recoloring process is in action
 
	PALETTE_MODIFIER_COLOR        = RECOLOR_BIT,
 

	
 
	//This is used for the GfxFillRect function
 
	///Used to draw a "grey out" rectangle. @see GfxFillRect
 
	PALETTE_MODIFIER_GREYOUT        = TRANSPARENT_BIT,
 
	///Set when a colortable mode is used. @see GfxFillRect
 
	USE_COLORTABLE                  = RECOLOR_BIT,
 
};
 

	
 
/** Masks needed for sprite operations.
src/texteff.cpp
Show inline comments
 
@@ -241,7 +241,7 @@ void DrawChatMessage()
 
			_screen.height - _chatmsg_box.y - count * 13 - 2,
 
			_chatmsg_box.x + _chatmsg_box.width - 1,
 
			_screen.height - _chatmsg_box.y - 2,
 
			PALETTE_TO_TRANSPARENT | (1 << USE_COLORTABLE) // black, but with some alpha for background
 
			PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOR // black, but with some alpha for background
 
		);
 

	
 
	/* Paint the chat messages starting with the lowest at the bottom */
src/toolbar_gui.cpp
Show inline comments
 
@@ -914,7 +914,7 @@ struct MainToolbarWindow : Window {
 
	{
 
		/* Draw brown-red toolbar bg. */
 
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
 
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
 
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4, FILLRECT_CHECKER);
 

	
 
		/* If spectator, disable all construction buttons
 
		* ie : Build road, rail, ships, airports and landscaping
 
@@ -1118,7 +1118,7 @@ public:
 

	
 
		/* Draw brown-red toolbar bg. */
 
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
 
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
 
		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4, FILLRECT_CHECKER);
 

	
 
		this->DrawWidgets();
 

	
src/widget.cpp
Show inline comments
 
@@ -162,7 +162,7 @@ void DrawFrameRect(int left, int top, in
 
	uint light        = _colour_gradient[ctab][7];
 

	
 
	if (flags & FR_TRANSPARENT) {
 
		GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT | (1 << USE_COLORTABLE));
 
		GfxFillRect(left, top, right, bottom, PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOR);
 
	} else {
 
		uint interior;
 

	
 
@@ -317,7 +317,7 @@ void Window::DrawWidgets() const
 

	
 
			/* draw "shaded" background */
 
			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c2);
 
			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
 
			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c1, FILLRECT_CHECKER);
 

	
 
			/* draw shaded lines */
 
			GfxFillRect(r.left + 2, r.top + 10, r.left + 2, r.bottom - 10, c1);
 
@@ -348,7 +348,7 @@ void Window::DrawWidgets() const
 

	
 
			/* draw "shaded" background */
 
			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c2);
 
			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
 
			GfxFillRect(r.left, r.top + 10, r.right, r.bottom - 10, c1, FILLRECT_CHECKER);
 

	
 
			/* draw shaded lines */
 
			GfxFillRect(r.left + 2, r.top + 10, r.left + 2, r.bottom - 10, c1);
 
@@ -379,7 +379,7 @@ void Window::DrawWidgets() const
 

	
 
			/* draw "shaded" background */
 
			GfxFillRect(r.left + 10, r.top, r.right - 10, r.bottom, c2);
 
			GfxFillRect(r.left + 10, r.top, r.right - 10, r.bottom, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
 
			GfxFillRect(r.left + 10, r.top, r.right - 10, r.bottom, c1, FILLRECT_CHECKER);
 

	
 
			/* draw shaded lines */
 
			GfxFillRect(r.left + 10, r.top + 2, r.right - 10, r.top + 2, c1);
 
@@ -490,7 +490,7 @@ void Window::DrawWidgets() const
 
		}
 

	
 
		if (this->IsWidgetDisabled(i)) {
 
			GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->color & 0xF][2] | (1 << PALETTE_MODIFIER_GREYOUT));
 
			GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[wi->color & 0xF][2], FILLRECT_CHECKER);
 
		}
 
	}
 

	
src/widgets/dropdown.cpp
Show inline comments
 
@@ -146,7 +146,7 @@ struct DropdownWindow : Window {
 

	
 
					if (item->masked) {
 
						GfxFillRect(x, y, x + width, y + item_height - 1,
 
							(1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[this->widget[0].color][5]
 
							_colour_gradient[this->widget[0].color][5], FILLRECT_CHECKER
 
						);
 
					}
 
				} else {
0 comments (0 inline, 0 general)