diff options
author | peter1138 <peter1138@openttd.org> | 2011-11-24 12:38:48 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2011-11-24 12:38:48 +0000 |
commit | 81598273e9b6bb2ee20ebdd82f3d4646a02999ba (patch) | |
tree | 2d13cc93dc84f2d99cff6fc2bb02214d4453f033 /src/smallmap_gui.cpp | |
parent | 15d0a22aac6b90a2055e68d019cab4350376a8fd (diff) | |
download | openttd-81598273e9b6bb2ee20ebdd82f3d4646a02999ba.tar.xz |
(svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
Diffstat (limited to 'src/smallmap_gui.cpp')
-rw-r--r-- | src/smallmap_gui.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 871fff252..c8b38f86e 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -618,6 +618,14 @@ class SmallMapWindow : public Window { static const uint8 FORCE_REFRESH_PERIOD = 0x1F; ///< map is redrawn after that many ticks uint8 refresh; ///< refresh counter, zeroed every FORCE_REFRESH_PERIOD ticks + FORCEINLINE Point SmallmapRemapCoords(int x, int y) const + { + Point pt; + pt.x = (y - x) * 2; + pt.y = y + x; + return pt; + } + /** * Remap tile to location on this smallmap. * @param tile_x X coordinate of the tile. @@ -629,13 +637,13 @@ class SmallMapWindow : public Window { int x_offset = tile_x - this->scroll_x / (int)TILE_SIZE; int y_offset = tile_y - this->scroll_y / (int)TILE_SIZE; - if (this->zoom == 1) return RemapCoords(x_offset, y_offset, 0); + if (this->zoom == 1) return SmallmapRemapCoords(x_offset, y_offset); /* For negative offsets, round towards -inf. */ if (x_offset < 0) x_offset -= this->zoom - 1; if (y_offset < 0) y_offset -= this->zoom - 1; - return RemapCoords(x_offset / this->zoom, y_offset / this->zoom, 0); + return SmallmapRemapCoords(x_offset / this->zoom, y_offset / this->zoom); } /** @@ -1505,7 +1513,7 @@ public: void SetNewScroll(int sx, int sy, int sub) { const NWidgetBase *wi = this->GetWidget<NWidgetBase>(SM_WIDGET_MAP); - Point hv = InverseRemapCoords(wi->current_x * TILE_SIZE / 2, wi->current_y * TILE_SIZE / 2); + Point hv = InverseRemapCoords(wi->current_x * ZOOM_LVL_BASE * TILE_SIZE / 2, wi->current_y * ZOOM_LVL_BASE * TILE_SIZE / 2); hv.x *= this->zoom; hv.y *= this->zoom; |