summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-05-15 14:08:39 +0000
committertruelight <truelight@openttd.org>2007-05-15 14:08:39 +0000
commitdc191785db0f17c34e52b6a44a366afdc290f254 (patch)
tree8be72fe02f196559ceab115af10a4a7e142fc46a
parent3615d2aeee788dfd504f9af20b8ccfb643900694 (diff)
downloadopenttd-dc191785db0f17c34e52b6a44a366afdc290f254.tar.xz
(svn r9844) -Codechange: replace zoomlevel with an enum
-Codechange: use predefined enums for viewport zoomlevels
-rw-r--r--projects/openttd.vcproj3
-rw-r--r--projects/openttd_vs80.vcproj4
-rw-r--r--source.list1
-rw-r--r--src/aircraft_gui.cpp2
-rw-r--r--src/gfx.cpp7
-rw-r--r--src/gfx.h3
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/main_gui.cpp12
-rw-r--r--src/news_gui.cpp6
-rw-r--r--src/road_cmd.cpp2
-rw-r--r--src/roadveh_gui.cpp2
-rw-r--r--src/screenshot.cpp4
-rw-r--r--src/ship_gui.cpp2
-rw-r--r--src/smallmap_gui.cpp2
-rw-r--r--src/texteff.cpp7
-rw-r--r--src/town_gui.cpp2
-rw-r--r--src/train_gui.cpp2
-rw-r--r--src/variables.h1
-rw-r--r--src/viewport.cpp66
-rw-r--r--src/viewport.h6
-rw-r--r--src/window.cpp2
-rw-r--r--src/zoom.hpp29
22 files changed, 108 insertions, 59 deletions
diff --git a/projects/openttd.vcproj b/projects/openttd.vcproj
index ca587c9ea..95512fdc8 100644
--- a/projects/openttd.vcproj
+++ b/projects/openttd.vcproj
@@ -662,6 +662,9 @@
<File
RelativePath=".\..\src\window.h">
</File>
+ <File
+ RelativePath=".\..\src\zoom.hpp">
+ </File>
</Filter>
<Filter
Name="GUI Source Code"
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 9ac7e6cb5..f501d5bcb 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1111,6 +1111,10 @@
RelativePath=".\..\src\window.h"
>
</File>
+ <File
+ RelativePath=".\..\src\zoom.hpp"
+ >
+ </File>
</Filter>
<Filter
Name="GUI Source Code"
diff --git a/source.list b/source.list
index ce9113853..8249fd37b 100644
--- a/source.list
+++ b/source.list
@@ -188,6 +188,7 @@ music/win32_m.h
sound/win32_s.h
video/win32_v.h
window.h
+zoom.hpp
# GUI Source Code
aircraft_gui.cpp
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index d0b90e86b..b63365361 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -393,6 +393,6 @@ void ShowAircraftViewWindow(const Vehicle *v)
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);
}
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index a37343720..02974d155 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -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 @@ void GfxFillRect(int left, int top, int right, int bottom, int color)
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 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode)
/* 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 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int heigh
{
const DrawPixelInfo *o = _cur_dpi;
- n->zoom = 0;
+ n->zoom = ZOOM_LVL_NORMAL;
assert(width > 0);
assert(height > 0);
diff --git a/src/gfx.h b/src/gfx.h
index 8eefb2a3e..418fc277c 100644
--- a/src/gfx.h
+++ b/src/gfx.h
@@ -6,6 +6,7 @@
#define GFX_H
#include "openttd.h"
+#include "zoom.hpp"
enum WindowKeyCodes {
WKC_SHIFT = 0x8000,
@@ -136,7 +137,7 @@ struct DrawPixelInfo {
Pixel *dst_ptr;
int left, top, width, height;
int pitch;
- uint16 zoom;
+ ZoomLevel zoom;
};
struct Colour {
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 1787835ec..18eaff5df 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -452,7 +452,7 @@ void ShowIndustryViewWindow(int industry)
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);
}
}
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index d6be058fd..b090e69df 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -880,8 +880,8 @@ bool DoZoomInOutWindow(int how, Window *w)
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 @@ bool DoZoomInOutWindow(int how, Window *w)
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 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w)
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 @@ void SetupColorsAndInitialWindow()
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) {
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index bf9d13daf..58ba6d7cc 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -427,7 +427,7 @@ static void ShowNewspaper(NewsItem *ni)
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 @@ static void ShowNewspaper(NewsItem *ni)
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 @@ static void ShowNewspaper(NewsItem *ni)
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;
}
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 3217f045f..2b6881887 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -725,7 +725,7 @@ static void DrawRoadBits(TileInfo* ti)
}
/* 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++) {
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 81f7f84fa..b5f80b4f7 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -346,7 +346,7 @@ void ShowRoadVehViewWindow(const Vehicle *v)
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);
}
}
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 9cbaad628..a6d3153c0 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -469,7 +469,7 @@ static void LargeWorldCallback(void *userdata, Pixel *buf, uint y, uint pitch, u
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 @@ static bool MakeWorldScreenshot()
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;
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index 0e943b40a..4cca7e17d 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -347,6 +347,6 @@ void ShowShipViewWindow(const Vehicle *v)
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);
}
}
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 7687c9ea4..2b1868288 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1055,7 +1055,7 @@ void ShowExtraViewPortWindow()
/* 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;
diff --git a/src/texteff.cpp b/src/texteff.cpp
index 2c7b5d32f..692641be5 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -327,7 +327,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
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 @@ void DrawTextEffects(DrawPixelInfo *dpi)
}
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 @@ void DrawTextEffects(DrawPixelInfo *dpi)
}
}
break;
+
+ default:
+ break;
}
}
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index f4af235ec..565a7ecec 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -349,7 +349,7 @@ void ShowTownViewWindow(TownID town)
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);
}
}
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index b0ea9175f..1a1a475c8 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -320,7 +320,7 @@ void ShowTrainViewWindow(const Vehicle *v)
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);
}
}
diff --git a/src/variables.h b/src/variables.h
index 302ba4bb8..bb371d95d 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -78,7 +78,6 @@ VARDEF byte _trees_tick_ctr;
/* 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 */
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 23f5a5a31..e5f6279cf 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -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 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 *vp;
Point pt;
@@ -404,10 +406,10 @@ Point GetTileZoomCenterWindow(bool in, Window * w)
* @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 @@ static void DrawTileSelection(const TileInfo *ti)
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 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
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 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
@@ -838,7 +840,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
break;
default: NOT_REACHED();
- case 2:
+ case ZOOM_LVL_OUT_4X:
right += 4;
bottom += 5;
@@ -882,7 +884,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
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 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
FOR_ALL_STATIONS(st) {
@@ -907,7 +909,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
break;
default: NOT_REACHED();
- case 2:
+ case ZOOM_LVL_OUT_4X:
right += 4;
bottom += 5;
FOR_ALL_STATIONS(st) {
@@ -949,7 +951,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
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 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
FOR_ALL_SIGNS(si) {
@@ -974,7 +976,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
break;
default: NOT_REACHED();
- case 2:
+ case ZOOM_LVL_OUT_4X:
right += 4;
bottom += 5;
FOR_ALL_SIGNS(si) {
@@ -1016,7 +1018,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
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 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
FOR_ALL_WAYPOINTS(wp) {
@@ -1041,7 +1043,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
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 ViewportDrawParentSprites(ParentSpriteToDraw *psd[])
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 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
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 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
}
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 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
}
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 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
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 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
}
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 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
}
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 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
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 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
}
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 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
}
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 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
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 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
}
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 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
}
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) {
diff --git a/src/viewport.h b/src/viewport.h
index f40a671ee..e69690e20 100644
--- a/src/viewport.h
+++ b/src/viewport.h
@@ -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 @@ struct ViewPort {
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 SetSelectionRed(bool);
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);
diff --git a/src/window.cpp b/src/window.cpp
index 08e65e052..34ccb70aa 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -271,7 +271,7 @@ static void DrawOverlappedWindow(Window* const *wz, int left, int top, int right
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);
}
}
diff --git a/src/zoom.hpp b/src/zoom.hpp
new file mode 100644
index 000000000..64a2a1397
--- /dev/null
+++ b/src/zoom.hpp
@@ -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 */