Changeset - r6626:a882a4aaa61c
[Not reviewed]
master
0 13 0
truelight - 17 years ago 2007-05-15 16:08:46
truelight@openttd.org
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
-Codechange: introduced ZOOM_LVL_DETAIL to show/remove details
-Codechange: changed << and >> operator with ZoomLevel to a simple wrapper (that in theory also allows zoom-in besides the current zoom-out)
-Fix r9845: missed some int -> ZoomLevel
13 files changed with 79 insertions and 60 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1423,13 +1423,13 @@ static void GfxBlitZoomOutUncomp(Blitter
 

	
 
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode)
 
{
 
	const DrawPixelInfo *dpi = _cur_dpi;
 
	int start_x, start_y;
 
	BlitterParams bp;
 
	int zoom_mask = ~((1 << dpi->zoom) - 1);
 
	int zoom_mask = ~(ScaleByZoom(1, dpi->zoom) - 1);
 

	
 
	/* decode sprite header */
 
	x += sprite->x_offs;
 
	y += sprite->y_offs;
 
	bp.width_org = bp.width = sprite->width;
 
	bp.height = sprite->height;
 
@@ -1455,13 +1455,13 @@ static void GfxMainBlitter(const Sprite 
 
		if ( (y -= dpi->top) < 0) {
 
			bp.height += y;
 
			if (bp.height <= 0) return;
 
			start_y -= y;
 
			y = 0;
 
		} else {
 
			bp.dst += bp.pitch * (y >> dpi->zoom);
 
			bp.dst += bp.pitch * UnScaleByZoom(y, dpi->zoom);
 
		}
 
		bp.start_y = start_y;
 

	
 
		if ( (y = y + bp.height - dpi->height) > 0) {
 
			bp.height -= y;
 
			if (bp.height <= 0) return;
 
@@ -1473,24 +1473,24 @@ static void GfxMainBlitter(const Sprite 
 
			bp.width += x;
 
			if (bp.width <= 0) return;
 
			start_x -= x;
 
			x = 0;
 
		}
 
		bp.start_x = start_x;
 
		bp.dst += x >> dpi->zoom;
 
		bp.dst += UnScaleByZoom(x, dpi->zoom);
 

	
 
		if ( (x = x + bp.width - dpi->width) > 0) {
 
			bp.width -= x;
 
			if (bp.width <= 0) return;
 
		}
 

	
 
		switch (dpi->zoom) {
 
			default: NOT_REACHED();
 
			case 0: GfxBlitTileZoomIn(&bp);     break;
 
			case 1: GfxBlitTileZoomMedium(&bp); break;
 
			case 2: GfxBlitTileZoomOut(&bp);    break;
 
			case ZOOM_LVL_NORMAL: GfxBlitTileZoomIn(&bp);     break;
 
			case ZOOM_LVL_OUT_2X: GfxBlitTileZoomMedium(&bp); break;
 
			case ZOOM_LVL_OUT_4X: GfxBlitTileZoomOut(&bp);    break;
 
		}
 
	} else {
 
		bp.sprite += bp.width * (bp.height & ~zoom_mask);
 
		bp.height &= zoom_mask;
 
		if (bp.height == 0) return;
 

	
 
@@ -1499,13 +1499,13 @@ static void GfxMainBlitter(const Sprite 
 
		if ( (y -= dpi->top) < 0) {
 
			bp.height += y;
 
			if (bp.height <= 0) return;
 
			bp.sprite -= bp.width * y;
 
			y = 0;
 
		} else {
 
			bp.dst += bp.pitch * (y >> dpi->zoom);
 
			bp.dst += bp.pitch * UnScaleByZoom(y, dpi->zoom);
 
		}
 

	
 
		if (bp.height > dpi->height - y) {
 
			bp.height = dpi->height - y;
 
			if (bp.height <= 0) return;
 
		}
 
@@ -1515,24 +1515,24 @@ static void GfxMainBlitter(const Sprite 
 
		if ( (x -= dpi->left) < 0) {
 
			bp.width += x;
 
			if (bp.width <= 0) return;
 
			bp.sprite -= x;
 
			x = 0;
 
		}
 
		bp.dst += x >> dpi->zoom;
 
		bp.dst += UnScaleByZoom(x, dpi->zoom);
 

	
 
		if (bp.width > dpi->width - x) {
 
			bp.width = dpi->width - x;
 
			if (bp.width <= 0) return;
 
		}
 

	
 
		switch (dpi->zoom) {
 
			default: NOT_REACHED();
 
			case 0: GfxBlitZoomInUncomp(&bp);     break;
 
			case 1: GfxBlitZoomMediumUncomp(&bp); break;
 
			case 2: GfxBlitZoomOutUncomp(&bp);    break;
 
			case ZOOM_LVL_NORMAL: GfxBlitZoomInUncomp(&bp);     break;
 
			case ZOOM_LVL_OUT_2X: GfxBlitZoomMediumUncomp(&bp); break;
 
			case ZOOM_LVL_OUT_4X: GfxBlitZoomOutUncomp(&bp);    break;
 
		}
 
	}
 
}
 

	
 
void DoPaletteAnimations();
 

	
src/main_gui.cpp
Show inline comments
 
@@ -877,22 +877,22 @@ bool DoZoomInOutWindow(int how, Window *
 

	
 
	assert(w != NULL);
 
	vp = w->viewport;
 

	
 
	switch (how) {
 
		case ZOOM_IN:
 
			if (vp->zoom == ZOOM_LVL_NORMAL) return false;
 
			if (vp->zoom == ZOOM_LVL_MIN) return false;
 
			vp->zoom = (ZoomLevel)((byte)vp->zoom - 1);
 
			vp->virtual_width >>= 1;
 
			vp->virtual_height >>= 1;
 

	
 
			WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1;
 
			WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1;
 
			break;
 
		case ZOOM_OUT:
 
			if (vp->zoom == ZOOM_LVL_OUT_4X) return false;
 
			if (vp->zoom == ZOOM_LVL_MAX) return false;
 
			vp->zoom = (ZoomLevel)((byte)vp->zoom + 1);
 

	
 
			WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1;
 
			WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1;
 

	
 
			vp->virtual_width <<= 1;
 
@@ -1046,13 +1046,13 @@ void ZoomInOrOutToCursorWindow(bool in, 
 

	
 
	assert(w != 0);
 

	
 
	vp = w->viewport;
 

	
 
	if (_game_mode != GM_MENU) {
 
		if ((in && vp->zoom == ZOOM_LVL_NORMAL) || (!in && vp->zoom == ZOOM_LVL_OUT_4X))
 
		if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX))
 
			return;
 

	
 
		pt = GetTileZoomCenterWindow(in,w);
 
		if (pt.x != -1) {
 
			ScrollWindowTo(pt.x, pt.y, w);
 

	
src/misc_gui.cpp
Show inline comments
 
@@ -576,30 +576,30 @@ void ShowErrorMessage(StringID msg_1, St
 

	
 
		if ( (x|y) != 0) {
 
			pt = RemapCoords2(x, y);
 
			vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
 

	
 
			/* move x pos to opposite corner */
 
			pt.x = ((pt.x - vp->virtual_left) >> vp->zoom) + vp->left;
 
			pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
 
			pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - 260 : 20;
 

	
 
			/* move y pos to opposite corner */
 
			pt.y = ((pt.y - vp->virtual_top) >> vp->zoom) + vp->top;
 
			pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
 
			pt.y = (pt.y < (_screen.height >> 1)) ? _screen.height - 80 : 100;
 

	
 
		} else {
 
			pt.x = (_screen.width - 240) >> 1;
 
			pt.y = (_screen.height - 46) >> 1;
 
		}
 
		w = AllocateWindow(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets);
 
	} else {
 
		if ( (x|y) != 0) {
 
			pt = RemapCoords2(x, y);
 
			vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
 
			pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
 
			pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137);
 
			pt.x = clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (334/2), 0, _screen.width - 334);
 
			pt.y = clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (137/2), 22, _screen.height - 137);
 
		} else {
 
			pt.x = (_screen.width - 334) >> 1;
 
			pt.y = (_screen.height - 137) >> 1;
 
		}
 
		w = AllocateWindow(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets);
 
	}
src/openttd.cpp
Show inline comments
 
@@ -983,14 +983,14 @@ static void DoAutosave()
 
static void ScrollMainViewport(int x, int y)
 
{
 
	if (_game_mode != GM_MENU) {
 
		Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 
		assert(w);
 

	
 
		WP(w,vp_d).scrollpos_x += x << w->viewport->zoom;
 
		WP(w,vp_d).scrollpos_y += y << w->viewport->zoom;
 
		WP(w,vp_d).scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
 
		WP(w,vp_d).scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
 
	}
 
}
 

	
 
static const int8 scrollamt[16][2] = {
 
	{ 0,  0},
 
	{-2,  0}, ///<  1 : left
 
@@ -1279,14 +1279,14 @@ bool AfterLoadGame()
 

	
 
	WP(w,vp_d).scrollpos_x = _saved_scrollpos_x;
 
	WP(w,vp_d).scrollpos_y = _saved_scrollpos_y;
 

	
 
	vp = w->viewport;
 
	vp->zoom = _saved_scrollpos_zoom;
 
	vp->virtual_width = vp->width << vp->zoom;
 
	vp->virtual_height = vp->height << vp->zoom;
 
	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
 
	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
 

	
 
	/* in version 4.1 of the savegame, is_active was introduced to determine
 
	 * if a player does exist, rather then checking name_1 */
 
	if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive();
 

	
 
	/* the void tiles on the southern border used to belong to a wrong class (pre 4.3). */
src/road_cmd.cpp
Show inline comments
 
@@ -722,13 +722,13 @@ static void DrawRoadBits(TileInfo* ti)
 
		/* Road works */
 
		DrawGroundSprite(road & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE);
 
		return;
 
	}
 

	
 
	/* Return if full detail is disabled, or we are zoomed fully out. */
 
	if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom == ZOOM_LVL_OUT_4X) return;
 
	if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return;
 

	
 
	/* Draw extra details. */
 
	for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) {
 
		int x = ti->x | drts->subcoord_x;
 
		int y = ti->y | drts->subcoord_y;
 
		byte z = ti->z;
src/screenshot.cpp
Show inline comments
 
@@ -476,16 +476,16 @@ static void LargeWorldCallback(void *use
 
	left = 0;
 
	while (vp->width - left != 0) {
 
		wx = min(vp->width - left, 1600);
 
		left += wx;
 

	
 
		ViewportDoDraw(vp,
 
			((left - wx - vp->left) << vp->zoom) + vp->virtual_left,
 
			((y - vp->top) << vp->zoom) + vp->virtual_top,
 
			((left - vp->left) << vp->zoom) + vp->virtual_left,
 
			(((y + n) - vp->top) << vp->zoom) + vp->virtual_top
 
			ScaleByZoom(left - wx - vp->left, vp->zoom) + vp->virtual_left,
 
			ScaleByZoom(y - vp->top, vp->zoom) + vp->virtual_top,
 
			ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left,
 
			ScaleByZoom((y + n) - vp->top, vp->zoom) + vp->virtual_top
 
		);
 
	}
 

	
 
	_cur_dpi = old_dpi;
 
}
 

	
src/smallmap_gui.cpp
Show inline comments
 
@@ -1013,14 +1013,14 @@ static void ExtraViewPortWndProc(Window 
 

	
 
			if (vp == NULL) {
 
				_cursor.fix_at = false;
 
				_scrolling_viewport = false;
 
			}
 

	
 
			WP(w, vp_d).scrollpos_x += e->we.scroll.delta.x << vp->zoom;
 
			WP(w, vp_d).scrollpos_y += e->we.scroll.delta.y << vp->zoom;
 
			WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
 
			WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
 
		} break;
 

	
 
		case WE_MOUSEWHEEL:
 
			ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w);
 
			break;
 

	
src/sound.cpp
Show inline comments
 
@@ -149,13 +149,13 @@ static void StartSound(uint sound, int p
 
	right_vol = (volume * PANNING_LEVELS) + (volume * panning);
 
	MxSetChannelVolume(mc, left_vol * 128 / PANNING_LEVELS, right_vol * 128 / PANNING_LEVELS);
 
	MxActivateChannel(mc);
 
}
 

	
 

	
 
static const byte _vol_factor_by_zoom[] = {255, 190, 134};
 
static const byte _vol_factor_by_zoom[ZOOM_LVL_END] = {255, 190, 134};
 

	
 
static const byte _sound_base_vol[] = {
 
	128,  90, 128, 128, 128, 128, 128, 128,
 
	128,  90,  90, 128, 128, 128, 128, 128,
 
	128, 128, 128,  80, 128, 128, 128, 128,
 
	128, 128, 128, 128, 128, 128, 128, 128,
src/texteff.cpp
Show inline comments
 
@@ -348,14 +348,16 @@ void DrawTextEffects(DrawPixelInfo *dpi)
 
						dpi->top  + dpi->height > te->y) {
 
					AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2);
 
				}
 
			}
 
			break;
 

	
 
		default:
 
		case ZOOM_LVL_OUT_4X:
 
			break;
 

	
 
		default: NOT_REACHED();
 
	}
 
}
 

	
 
void DeleteAnimatedTile(TileIndex tile)
 
{
 
	TileIndex *ti;
src/vehicle.cpp
Show inline comments
 
@@ -1422,14 +1422,14 @@ Vehicle *CheckClickOnVehicle(const ViewP
 
	uint dist, best_dist = (uint)-1;
 

	
 
	if ( (uint)(x -= vp->left) >= (uint)vp->width ||
 
			 (uint)(y -= vp->top) >= (uint)vp->height)
 
				return NULL;
 

	
 
	x = (x << vp->zoom) + vp->virtual_left;
 
	y = (y << vp->zoom) + vp->virtual_top;
 
	x = ScaleByZoom(x, vp->zoom) + vp->virtual_left;
 
	y = ScaleByZoom(y, vp->zoom) + vp->virtual_top;
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		if ((v->vehstatus & (VS_HIDDEN|VS_UNCLICKABLE)) == 0 &&
 
				x >= v->left_coord && x <= v->right_coord &&
 
				y >= v->top_coord && y <= v->bottom_coord) {
 

	
src/viewport.cpp
Show inline comments
 
@@ -266,16 +266,16 @@ static void SetViewportPosition(Window *
 
	int i;
 
	int left, top, width, height;
 

	
 
	vp->virtual_left = x;
 
	vp->virtual_top = y;
 

	
 
	old_left >>= vp->zoom;
 
	old_top >>= vp->zoom;
 
	x >>= vp->zoom;
 
	y >>= vp->zoom;
 
	old_left = UnScaleByZoom(old_left, vp->zoom);
 
	old_top = UnScaleByZoom(old_top, vp->zoom);
 
	x = UnScaleByZoom(x, vp->zoom);
 
	y = UnScaleByZoom(y, vp->zoom);
 

	
 
	old_left -= x;
 
	old_top -= y;
 

	
 
	if (old_top == 0 && old_left == 0) return;
 

	
 
@@ -330,14 +330,14 @@ static Point TranslateXYToTileCoord(cons
 
	if ( (uint)(x -= vp->left) >= (uint)vp->width ||
 
				(uint)(y -= vp->top) >= (uint)vp->height) {
 
				Point pt = {-1, -1};
 
				return pt;
 
	}
 

	
 
	x = ((x << vp->zoom) + vp->virtual_left) >> 2;
 
	y = ((y << vp->zoom) + vp->virtual_top) >> 1;
 
	x = (ScaleByZoom(x, vp->zoom) + vp->virtual_left) >> 2;
 
	y = (ScaleByZoom(y, vp->zoom) + vp->virtual_top) >> 1;
 

	
 
	a = y-x;
 
	b = y+x;
 

	
 
	/* we need to move variables in to the valid range, as the
 
	 * GetTileZoomCenterWindow() function can call here with invalid x and/or y,
 
@@ -403,16 +403,16 @@ Point GetTileZoomCenterWindow(bool in, W
 
 * @param w Window pointer to the window that has the zoom buttons
 
 * @param vp pointer to the viewport whose zoom-level the buttons represent
 
 * @param widget_zoom_in widget index for window with zoom-in button
 
 * @param widget_zoom_out widget index for window with zoom-out button */
 
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
 
{
 
	SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == ZOOM_LVL_NORMAL);
 
	SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == ZOOM_LVL_MIN);
 
	InvalidateWidget(w, widget_zoom_in);
 

	
 
	SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == ZOOM_LVL_OUT_4X);
 
	SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == ZOOM_LVL_MAX);
 
	InvalidateWidget(w, widget_zoom_out);
 
}
 

	
 
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z)
 
{
 
	ViewportDrawer *vd = _cur_vd;
 
@@ -668,13 +668,13 @@ static void DrawTileSelection(const Tile
 
			/* Figure out the Z coordinate for the single dot. */
 
			byte z = ti->z;
 
			if (ti->tileh & SLOPE_N) {
 
				z += TILE_HEIGHT;
 
				if (ti->tileh == SLOPE_STEEP_N) z += TILE_HEIGHT;
 
			}
 
			DrawGroundSpriteAt(_cur_dpi->zoom != ZOOM_LVL_OUT_4X ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
 
			DrawGroundSpriteAt(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
 
		} else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) {
 
			/* autorail highlight piece under cursor */
 
			uint type = _thd.drawstyle & 0xF;
 
			int offset;
 

	
 
			assert(type <= 5);
 
@@ -1238,24 +1238,24 @@ void ViewportDoDraw(const ViewPort *vp, 
 
	_cur_vd = &vd;
 

	
 
	old_dpi = _cur_dpi;
 
	_cur_dpi = &vd.dpi;
 

	
 
	vd.dpi.zoom = vp->zoom;
 
	mask = (-1) << vp->zoom;
 
	mask = ScaleByZoom(-1, vp->zoom);
 

	
 
	vd.combine_sprites = 0;
 

	
 
	vd.dpi.width = (right - left) & mask;
 
	vd.dpi.height = (bottom - top) & mask;
 
	vd.dpi.left = left & mask;
 
	vd.dpi.top = top & mask;
 
	vd.dpi.pitch = old_dpi->pitch;
 

	
 
	x = ((vd.dpi.left - (vp->virtual_left&mask)) >> vp->zoom) + vp->left;
 
	y = ((vd.dpi.top - (vp->virtual_top&mask)) >> vp->zoom) + vp->top;
 
	x = UnScaleByZoom(vd.dpi.left - (vp->virtual_left & mask), vp->zoom) + vp->left;
 
	y = UnScaleByZoom(vd.dpi.top - (vp->virtual_top & mask), vp->zoom) + vp->top;
 

	
 
	vd.dpi.dst_ptr = old_dpi->dst_ptr + x - old_dpi->left + (y - old_dpi->top) * old_dpi->pitch;
 

	
 
	vd.parent_list = parent_list;
 
	vd.eof_parent_list = endof(parent_list);
 
	vd.spritelist_mem = mem;
 
@@ -1292,28 +1292,28 @@ void ViewportDoDraw(const ViewPort *vp, 
 
}
 

	
 
/** Make sure we don't draw a too big area at a time.
 
 * If we do, the sprite memory will overflow. */
 
static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom)
 
{
 
	if (((bottom - top) * (right - left) << (2 * vp->zoom)) > 180000) {
 
	if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > 180000) {
 
		if ((bottom - top) > (right - left)) {
 
			int t = (top + bottom) >> 1;
 
			ViewportDrawChk(vp, left, top, right, t);
 
			ViewportDrawChk(vp, left, t, right, bottom);
 
		} else {
 
			int t = (left + right) >> 1;
 
			ViewportDrawChk(vp, left, top, t, bottom);
 
			ViewportDrawChk(vp, t, top, right, bottom);
 
		}
 
	} else {
 
		ViewportDoDraw(vp,
 
			((left - vp->left) << vp->zoom) + vp->virtual_left,
 
			((top - vp->top) << vp->zoom) + vp->virtual_top,
 
			((right - vp->left) << vp->zoom) + vp->virtual_left,
 
			((bottom - vp->top) << vp->zoom) + vp->virtual_top
 
			ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left,
 
			ScaleByZoom(top - vp->top, vp->zoom) + vp->virtual_top,
 
			ScaleByZoom(right - vp->left, vp->zoom) + vp->virtual_left,
 
			ScaleByZoom(bottom - vp->top, vp->zoom) + vp->virtual_top
 
		);
 
	}
 
}
 

	
 
static inline void ViewportDraw(const ViewPort *vp, int left, int top, int right, int bottom)
 
{
 
@@ -1395,16 +1395,16 @@ static void MarkViewportDirty(const View
 

	
 
	top = max(0, top - vp->virtual_top);
 

	
 
	if (top >= vp->virtual_height) return;
 

	
 
	SetDirtyBlocks(
 
		(left >> vp->zoom) + vp->left,
 
		(top >> vp->zoom) + vp->top,
 
		(right >> vp->zoom) + vp->left,
 
		(bottom >> vp->zoom) + vp->top
 
		UnScaleByZoom(left, vp->zoom) + vp->left,
 
		UnScaleByZoom(top, vp->zoom) + vp->top,
 
		UnScaleByZoom(right, vp->zoom) + vp->left,
 
		UnScaleByZoom(bottom, vp->zoom) + vp->top
 
	);
 
}
 

	
 
void MarkAllViewportsDirty(int left, int top, int right, int bottom)
 
{
 
	const ViewPort *vp = _viewports;
src/window.cpp
Show inline comments
 
@@ -1615,20 +1615,20 @@ static void HandleAutoscroll()
 
		if (vp != NULL) {
 
			x -= vp->left;
 
			y -= vp->top;
 
			/* here allows scrolling in both x and y axis */
 
#define scrollspeed 3
 
			if (x - 15 < 0) {
 
				WP(w, vp_d).scrollpos_x += (x - 15) * scrollspeed << vp->zoom;
 
				WP(w, vp_d).scrollpos_x += ScaleByZoom((x - 15) * scrollspeed, vp->zoom);
 
			} else if (15 - (vp->width - x) > 0) {
 
				WP(w, vp_d).scrollpos_x += (15 - (vp->width - x)) * scrollspeed << vp->zoom;
 
				WP(w, vp_d).scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * scrollspeed, vp->zoom);
 
			}
 
			if (y - 15 < 0) {
 
				WP(w, vp_d).scrollpos_y += (y - 15) * scrollspeed << vp->zoom;
 
				WP(w, vp_d).scrollpos_y += ScaleByZoom((y - 15) * scrollspeed, vp->zoom);
 
			} else if (15 - (vp->height - y) > 0) {
 
				WP(w,vp_d).scrollpos_y += (15 - (vp->height - y)) * scrollspeed << vp->zoom;
 
				WP(w,vp_d).scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * scrollspeed, vp->zoom);
 
			}
 
#undef scrollspeed
 
		}
 
	}
 
}
 

	
 
@@ -1967,14 +1967,14 @@ void RelocateAllWindows(int neww, int ne
 
		int left, top;
 

	
 
		if (w->window_class == WC_MAIN_WINDOW) {
 
			ViewPort *vp = w->viewport;
 
			vp->width = w->width = neww;
 
			vp->height = w->height = newh;
 
			vp->virtual_width = neww << vp->zoom;
 
			vp->virtual_height = newh << vp->zoom;
 
			vp->virtual_width = ScaleByZoom(neww, vp->zoom);
 
			vp->virtual_height = ScaleByZoom(newh, vp->zoom);
 
			continue; // don't modify top,left
 
		}
 

	
 
		/* XXX - this probably needs something more sane. For example specying
 
		 * in a 'backup'-desc that the window should always be centred. */
 
		switch (w->window_class) {
src/zoom.hpp
Show inline comments
 
@@ -19,11 +19,28 @@ enum ZoomLevel {
 
	ZOOM_LVL_TOWN     = ZOOM_LVL_OUT_2X,
 
	ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
 
	ZOOM_LVL_SHIP     = ZOOM_LVL_NORMAL,
 
	ZOOM_LVL_TRAIN    = ZOOM_LVL_NORMAL,
 
	ZOOM_LVL_ROADVEH  = ZOOM_LVL_NORMAL,
 
	ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
 

	
 
	ZOOM_LVL_DETAIL   = ZOOM_LVL_OUT_2X, //! All zoomlevels below or equal to this, will result in details on the screen, like road-work, ...
 

	
 
	ZOOM_LVL_MIN      = ZOOM_LVL_NORMAL,
 
	ZOOM_LVL_MAX      = ZOOM_LVL_OUT_4X,
 
};
 

	
 
extern ZoomLevel _saved_scrollpos_zoom;
 

	
 
static inline int ScaleByZoom(int value, ZoomLevel zoom)
 
{
 
	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
 
	return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << izoom;
 
}
 

	
 
static inline int UnScaleByZoom(int value, ZoomLevel zoom)
 
{
 
	int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
 
	return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> izoom;
 
}
 

	
 
#endif /* ZOOM_HPP */
0 comments (0 inline, 0 general)