(svn r9844) -Codechange: replace zoomlevel with an enum
authortruelight
Tue, 15 May 2007 14:08:39 +0000
changeset 7120 e31767effc16
parent 7119 8ec832426743
child 7121 60360771cc0f
(svn r9844) -Codechange: replace zoomlevel with an enum
-Codechange: use predefined enums for viewport zoomlevels
projects/openttd.vcproj
projects/openttd_vs80.vcproj
source.list
src/aircraft_gui.cpp
src/gfx.cpp
src/gfx.h
src/industry_gui.cpp
src/main_gui.cpp
src/news_gui.cpp
src/road_cmd.cpp
src/roadveh_gui.cpp
src/screenshot.cpp
src/ship_gui.cpp
src/smallmap_gui.cpp
src/texteff.cpp
src/town_gui.cpp
src/train_gui.cpp
src/variables.h
src/viewport.cpp
src/viewport.h
src/window.cpp
src/zoom.hpp
--- a/projects/openttd.vcproj	Tue May 15 13:38:43 2007 +0000
+++ b/projects/openttd.vcproj	Tue May 15 14:08:39 2007 +0000
@@ -662,6 +662,9 @@
 			<File
 				RelativePath=".\..\src\window.h">
 			</File>
+			<File
+				RelativePath=".\..\src\zoom.hpp">
+			</File>
 		</Filter>
 		<Filter
 			Name="GUI Source Code"
--- a/projects/openttd_vs80.vcproj	Tue May 15 13:38:43 2007 +0000
+++ b/projects/openttd_vs80.vcproj	Tue May 15 14:08:39 2007 +0000
@@ -1111,6 +1111,10 @@
 				RelativePath=".\..\src\window.h"
 				>
 			</File>
+			<File
+				RelativePath=".\..\src\zoom.hpp"
+				>
+			</File>
 		</Filter>
 		<Filter
 			Name="GUI Source Code"
--- a/source.list	Tue May 15 13:38:43 2007 +0000
+++ b/source.list	Tue May 15 14:08:39 2007 +0000
@@ -188,6 +188,7 @@
 sound/win32_s.h
 video/win32_v.h
 window.h
+zoom.hpp
 
 # GUI Source Code
 aircraft_gui.cpp
--- a/src/aircraft_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/aircraft_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -393,6 +393,6 @@
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
-		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
+		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_AIRCRAFT);
 	}
 }
--- a/src/gfx.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/gfx.cpp	Tue May 15 14:08:39 2007 +0000
@@ -18,6 +18,7 @@
 #include "fontcache.h"
 #include "genworld.h"
 #include "debug.h"
+#include "zoom.hpp"
 
 #ifdef _DEBUG
 bool _dbg_screen_rect;
@@ -153,7 +154,7 @@
 	const int otop = top;
 	const int oleft = left;
 
-	if (dpi->zoom != 0) return;
+	if (dpi->zoom != ZOOM_LVL_NORMAL) return;
 	if (left > right || top > bottom) return;
 	if (right < dpi->left || left >= dpi->left + dpi->width) return;
 	if (bottom < dpi->top || top >= dpi->top + dpi->height) return;
@@ -1444,7 +1445,7 @@
 		/* tile blit */
 		start_y = 0;
 
-		if (dpi->zoom > 0) {
+		if (dpi->zoom > ZOOM_LVL_NORMAL) {
 			start_y += bp.height & ~zoom_mask;
 			bp.height &= zoom_mask;
 			if (bp.height == 0) return;
@@ -1946,7 +1947,7 @@
 {
 	const DrawPixelInfo *o = _cur_dpi;
 
-	n->zoom = 0;
+	n->zoom = ZOOM_LVL_NORMAL;
 
 	assert(width > 0);
 	assert(height > 0);
--- a/src/gfx.h	Tue May 15 13:38:43 2007 +0000
+++ b/src/gfx.h	Tue May 15 14:08:39 2007 +0000
@@ -6,6 +6,7 @@
 #define GFX_H
 
 #include "openttd.h"
+#include "zoom.hpp"
 
 enum WindowKeyCodes {
 	WKC_SHIFT = 0x8000,
@@ -136,7 +137,7 @@
 	Pixel *dst_ptr;
 	int left, top, width, height;
 	int pitch;
-	uint16 zoom;
+	ZoomLevel zoom;
 };
 
 struct Colour {
--- a/src/industry_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/industry_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -452,7 +452,7 @@
 		WP(w, vp2_d).data_1 = 0;
 		WP(w, vp2_d).data_2 = 0;
 		WP(w, vp2_d).data_3 = 0;
-		AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), 1);
+		AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
 	}
 }
 
--- a/src/main_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/main_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -880,8 +880,8 @@
 
 	switch (how) {
 		case ZOOM_IN:
-			if (vp->zoom == 0) return false;
-			vp->zoom--;
+			if (vp->zoom == ZOOM_LVL_NORMAL) return false;
+			vp->zoom = (ZoomLevel)((byte)vp->zoom - 1);
 			vp->virtual_width >>= 1;
 			vp->virtual_height >>= 1;
 
@@ -889,8 +889,8 @@
 			WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1;
 			break;
 		case ZOOM_OUT:
-			if (vp->zoom == 2) return false;
-			vp->zoom++;
+			if (vp->zoom == ZOOM_LVL_OUT_4X) 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;
@@ -1049,7 +1049,7 @@
 	vp = w->viewport;
 
 	if (_game_mode != GM_MENU) {
-		if ((in && vp->zoom == 0) || (!in && vp->zoom == 2))
+		if ((in && vp->zoom == ZOOM_LVL_NORMAL) || (!in && vp->zoom == ZOOM_LVL_OUT_4X))
 			return;
 
 		pt = GetTileZoomCenterWindow(in,w);
@@ -2460,7 +2460,7 @@
 	height = _screen.height;
 
 	w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
-	AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), 0);
+	AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
 
 	/* XXX: these are not done */
 	switch (_game_mode) {
--- a/src/news_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/news_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -427,7 +427,7 @@
 			w = AllocateWindowDesc(&_news_type13_desc);
 			if (ni->flags & NF_VIEWPORT)
 				AssignWindowViewport(w, 2, 58, 0x1AA, 0x6E,
-					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
+					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
 			break;
 		}
 
@@ -436,7 +436,7 @@
 			w = AllocateWindowDesc(&_news_type2_desc);
 			if (ni->flags & NF_VIEWPORT)
 				AssignWindowViewport(w, 2, 58, 0x1AA, 0x46,
-					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
+					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
 			break;
 		}
 
@@ -445,7 +445,7 @@
 			w = AllocateWindowDesc(&_news_type0_desc);
 			if (ni->flags & NF_VIEWPORT)
 				AssignWindowViewport(w, 3, 17, 0x112, 0x2F,
-					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
+					ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
 			break;
 		}
 	}
--- a/src/road_cmd.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/road_cmd.cpp	Tue May 15 14:08:39 2007 +0000
@@ -725,7 +725,7 @@
 	}
 
 	/* Return if full detail is disabled, or we are zoomed fully out. */
-	if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return;
+	if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom == ZOOM_LVL_OUT_4X) return;
 
 	/* Draw extra details. */
 	for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) {
--- a/src/roadveh_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/roadveh_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -346,7 +346,7 @@
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
-		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
+		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_ROADVEH);
 	}
 }
 
--- a/src/screenshot.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/screenshot.cpp	Tue May 15 14:08:39 2007 +0000
@@ -469,7 +469,7 @@
 	dpi.height = n;
 	dpi.width = vp->width;
 	dpi.pitch = pitch;
-	dpi.zoom = 0;
+	dpi.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
 	dpi.left = 0;
 	dpi.top = y;
 
@@ -540,7 +540,7 @@
 	ViewPort vp;
 	const ScreenshotFormat *sf;
 
-	vp.zoom = 0;
+	vp.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
 	vp.left = 0;
 	vp.top = 0;
 	vp.virtual_left = -(int)MapMaxX() * TILE_PIXELS;
--- a/src/ship_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/ship_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -347,6 +347,6 @@
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
-		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
+		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_SHIP);
 	}
 }
--- a/src/smallmap_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/smallmap_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -1055,7 +1055,7 @@
 		/* the main window with the main view */
 		v = FindWindowById(WC_MAIN_WINDOW, 0);
 		/* New viewport start ats (zero,zero) */
-		AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
+		AssignWindowViewport(w, 3, 17, 294, 214, 0 , ZOOM_LVL_VIEWPORT);
 
 		/* center on same place as main window (zoom is maximum, no adjustment needed) */
 		x = WP(v, vp_d).scrollpos_x;
--- a/src/texteff.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/texteff.cpp	Tue May 15 14:08:39 2007 +0000
@@ -327,7 +327,7 @@
 	const TextEffect* te;
 
 	switch (dpi->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
 				if (te->string_id != INVALID_STRING_ID &&
 						dpi->left <= te->right &&
@@ -339,7 +339,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
 				if (te->string_id != INVALID_STRING_ID &&
 						dpi->left <= te->right  * 2 - te->x &&
@@ -350,6 +350,9 @@
 				}
 			}
 			break;
+
+		default:
+			break;
 	}
 }
 
--- a/src/town_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/town_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -349,7 +349,7 @@
 
 	if (w != NULL) {
 		w->flags4 |= WF_DISABLE_VP_SCROLL;
-		AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, 1);
+		AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, ZOOM_LVL_TOWN);
 	}
 }
 
--- a/src/train_gui.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/train_gui.cpp	Tue May 15 14:08:39 2007 +0000
@@ -320,7 +320,7 @@
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
-		AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0);
+		AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), ZOOM_LVL_TRAIN);
 	}
 }
 
--- a/src/variables.h	Tue May 15 13:38:43 2007 +0000
+++ b/src/variables.h	Tue May 15 14:08:39 2007 +0000
@@ -78,7 +78,6 @@
 /* Keep track of current game position */
 VARDEF int _saved_scrollpos_x;
 VARDEF int _saved_scrollpos_y;
-VARDEF byte _saved_scrollpos_zoom;
 
 /* ********* END OF SAVE REGION */
 
--- a/src/viewport.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/viewport.cpp	Tue May 15 14:08:39 2007 +0000
@@ -26,6 +26,8 @@
 
 #define VIEWPORT_DRAW_MEM (65536 * 2)
 
+ZoomLevel _saved_scrollpos_zoom;
+
 /* XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) */
 static ViewPort _viewports[25 - 2];
 static uint32 _active_viewports;    ///< bitmasked variable where each bit signifies if a viewport is in use or not
@@ -143,7 +145,7 @@
 }
 
 void AssignWindowViewport(Window *w, int x, int y,
-	int width, int height, uint32 follow_flags, byte zoom)
+	int width, int height, uint32 follow_flags, ZoomLevel zoom)
 {
 	ViewPort *vp;
 	Point pt;
@@ -404,10 +406,10 @@
  * @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 == 0);
+	SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == ZOOM_LVL_NORMAL);
 	InvalidateWidget(w, widget_zoom_in);
 
-	SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == 2);
+	SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == ZOOM_LVL_OUT_4X);
 	InvalidateWidget(w, widget_zoom_out);
 }
 
@@ -669,7 +671,7 @@
 				z += TILE_HEIGHT;
 				if (ti->tileh == SLOPE_STEEP_N) z += TILE_HEIGHT;
 			}
-			DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
+			DrawGroundSpriteAt(_cur_dpi->zoom != ZOOM_LVL_OUT_4X ? 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;
@@ -808,7 +810,7 @@
 	bottom = top + dpi->height;
 
 	switch (dpi->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			FOR_ALL_TOWNS(t) {
 				if (bottom > t->sign.top &&
 						top    < t->sign.top + 12 &&
@@ -821,7 +823,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			right += 2;
 			bottom += 2;
 
@@ -838,7 +840,7 @@
 			break;
 
 		default: NOT_REACHED();
-		case 2:
+		case ZOOM_LVL_OUT_4X:
 			right += 4;
 			bottom += 5;
 
@@ -882,7 +884,7 @@
 	bottom = top + dpi->height;
 
 	switch (dpi->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			FOR_ALL_STATIONS(st) {
 				if (bottom > st->sign.top &&
 						top    < st->sign.top + 12 &&
@@ -893,7 +895,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			right += 2;
 			bottom += 2;
 			FOR_ALL_STATIONS(st) {
@@ -907,7 +909,7 @@
 			break;
 
 		default: NOT_REACHED();
-		case 2:
+		case ZOOM_LVL_OUT_4X:
 			right += 4;
 			bottom += 5;
 			FOR_ALL_STATIONS(st) {
@@ -949,7 +951,7 @@
 	bottom = top + dpi->height;
 
 	switch (dpi->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			FOR_ALL_SIGNS(si) {
 				if (bottom > si->sign.top &&
 						top    < si->sign.top + 12 &&
@@ -960,7 +962,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			right += 2;
 			bottom += 2;
 			FOR_ALL_SIGNS(si) {
@@ -974,7 +976,7 @@
 			break;
 
 		default: NOT_REACHED();
-		case 2:
+		case ZOOM_LVL_OUT_4X:
 			right += 4;
 			bottom += 5;
 			FOR_ALL_SIGNS(si) {
@@ -1016,7 +1018,7 @@
 	bottom = top + dpi->height;
 
 	switch (dpi->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			FOR_ALL_WAYPOINTS(wp) {
 				if (bottom > wp->sign.top &&
 						top    < wp->sign.top + 12 &&
@@ -1027,7 +1029,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			right += 2;
 			bottom += 2;
 			FOR_ALL_WAYPOINTS(wp) {
@@ -1041,7 +1043,7 @@
 			break;
 
 		default: NOT_REACHED();
-		case 2:
+		case ZOOM_LVL_OUT_4X:
 			right += 4;
 			bottom += 5;
 			FOR_ALL_WAYPOINTS(wp) {
@@ -1163,13 +1165,13 @@
 static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss)
 {
 	DrawPixelInfo dp;
-	byte zoom;
+	ZoomLevel zoom;
 
 	_cur_dpi = &dp;
 	dp = *dpi;
 
 	zoom = dp.zoom;
-	dp.zoom = 0;
+	dp.zoom = ZOOM_LVL_NORMAL;
 
 	dp.left >>= zoom;
 	dp.top >>= zoom;
@@ -1490,7 +1492,7 @@
 	if (!HASBIT(_display_opt, DO_SHOW_TOWN_NAMES)) return false;
 
 	switch (vp->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			x = x - vp->left + vp->virtual_left;
 			y = y - vp->top  + vp->virtual_top;
 			FOR_ALL_TOWNS(t) {
@@ -1504,7 +1506,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			x = (x - vp->left + 1) * 2 + vp->virtual_left;
 			y = (y - vp->top  + 1) * 2 + vp->virtual_top;
 			FOR_ALL_TOWNS(t) {
@@ -1518,7 +1520,8 @@
 			}
 			break;
 
-		default:
+		default: NOT_REACHED();
+		case ZOOM_LVL_OUT_4X:
 			x = (x - vp->left + 3) * 4 + vp->virtual_left;
 			y = (y - vp->top  + 3) * 4 + vp->virtual_top;
 			FOR_ALL_TOWNS(t) {
@@ -1544,7 +1547,7 @@
 	if (!HASBIT(_display_opt, DO_SHOW_STATION_NAMES)) return false;
 
 	switch (vp->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			x = x - vp->left + vp->virtual_left;
 			y = y - vp->top  + vp->virtual_top;
 			FOR_ALL_STATIONS(st) {
@@ -1558,7 +1561,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			x = (x - vp->left + 1) * 2 + vp->virtual_left;
 			y = (y - vp->top  + 1) * 2 + vp->virtual_top;
 			FOR_ALL_STATIONS(st) {
@@ -1572,7 +1575,8 @@
 			}
 			break;
 
-		default:
+		default: NOT_REACHED();
+		case ZOOM_LVL_OUT_4X:
 			x = (x - vp->left + 3) * 4 + vp->virtual_left;
 			y = (y - vp->top  + 3) * 4 + vp->virtual_top;
 			FOR_ALL_STATIONS(st) {
@@ -1598,7 +1602,7 @@
 	if (!HASBIT(_display_opt, DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
 
 	switch (vp->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			x = x - vp->left + vp->virtual_left;
 			y = y - vp->top  + vp->virtual_top;
 			FOR_ALL_SIGNS(si) {
@@ -1612,7 +1616,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			x = (x - vp->left + 1) * 2 + vp->virtual_left;
 			y = (y - vp->top  + 1) * 2 + vp->virtual_top;
 			FOR_ALL_SIGNS(si) {
@@ -1626,7 +1630,8 @@
 			}
 			break;
 
-		default:
+		default: NOT_REACHED();
+		case ZOOM_LVL_OUT_4X:
 			x = (x - vp->left + 3) * 4 + vp->virtual_left;
 			y = (y - vp->top  + 3) * 4 + vp->virtual_top;
 			FOR_ALL_SIGNS(si) {
@@ -1652,7 +1657,7 @@
 	if (!HASBIT(_display_opt, DO_WAYPOINTS)) return false;
 
 	switch (vp->zoom) {
-		case 0:
+		case ZOOM_LVL_NORMAL:
 			x = x - vp->left + vp->virtual_left;
 			y = y - vp->top  + vp->virtual_top;
 			FOR_ALL_WAYPOINTS(wp) {
@@ -1666,7 +1671,7 @@
 			}
 			break;
 
-		case 1:
+		case ZOOM_LVL_OUT_2X:
 			x = (x - vp->left + 1) * 2 + vp->virtual_left;
 			y = (y - vp->top  + 1) * 2 + vp->virtual_top;
 			FOR_ALL_WAYPOINTS(wp) {
@@ -1680,7 +1685,8 @@
 			}
 			break;
 
-		default:
+		default: NOT_REACHED();
+		case ZOOM_LVL_OUT_4X:
 			x = (x - vp->left + 3) * 4 + vp->virtual_left;
 			y = (y - vp->top  + 3) * 4 + vp->virtual_top;
 			FOR_ALL_WAYPOINTS(wp) {
--- a/src/viewport.h	Tue May 15 13:38:43 2007 +0000
+++ b/src/viewport.h	Tue May 15 14:08:39 2007 +0000
@@ -5,6 +5,8 @@
 #ifndef VIEWPORT_H
 #define VIEWPORT_H
 
+#include "zoom.hpp"
+
 struct ViewPort {
 	int left,top;                       // screen coordinates for the viewport
 	int width, height;                  // screen width/height for the viewport
@@ -12,7 +14,7 @@
 	int virtual_left, virtual_top;      // virtual coordinates
 	int virtual_width, virtual_height;  // these are just width << zoom, height << zoom
 
-	byte zoom;
+	ZoomLevel zoom;
 };
 
 void SetSelectionRed(bool);
@@ -21,7 +23,7 @@
 void InitViewports();
 void DeleteWindowViewport(Window *w);
 void AssignWindowViewport(Window *w, int x, int y,
-	int width, int height, uint32 follow_flags, byte zoom);
+	int width, int height, uint32 follow_flags, ZoomLevel zoom);
 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
 Point GetTileBelowCursor();
 void UpdateViewportPosition(Window *w);
--- a/src/window.cpp	Tue May 15 13:38:43 2007 +0000
+++ b/src/window.cpp	Tue May 15 14:08:39 2007 +0000
@@ -271,7 +271,7 @@
 		dp->top = top - (*wz)->top;
 		dp->pitch = _screen.pitch;
 		dp->dst_ptr = _screen.dst_ptr + top * _screen.pitch + left;
-		dp->zoom = 0;
+		dp->zoom = ZOOM_LVL_NORMAL;
 		CallWindowEventNP(*wz, WE_PAINT);
 	}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/zoom.hpp	Tue May 15 14:08:39 2007 +0000
@@ -0,0 +1,29 @@
+/* $Id$ */
+
+/** @file zoom.hpp */
+
+#ifndef ZOOM_HPP
+#define ZOOM_HPP
+
+enum ZoomLevel {
+	/* Our possible zoom-levels */
+	ZOOM_LVL_NORMAL = 0,
+	ZOOM_LVL_OUT_2X,
+	ZOOM_LVL_OUT_4X,
+	ZOOM_LVL_END,
+
+	/* Here we define in which zoom viewports are */
+	ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_NEWS     = ZOOM_LVL_NORMAL,
+	ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
+	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,
+};
+
+extern ZoomLevel _saved_scrollpos_zoom;
+
+#endif /* ZOOM_HPP */