diff options
-rw-r--r-- | src/main_gui.cpp | 25 | ||||
-rw-r--r-- | src/viewport_func.h | 1 | ||||
-rw-r--r-- | src/viewport_gui.cpp | 7 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 60cadfb31..6a84d778b 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -34,6 +34,9 @@ #include "error.h" #include "news_gui.h" #include "misc_cmd.h" +#include "gfx_func.h" +#include "layer_gui.h" +#include "landscape.h" #include "saveload/saveload.h" @@ -153,6 +156,22 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w) } } +void LayerUpOrDownToCursorWindow(bool in, Window *w) +{ + assert(w != NULL); + + if (_game_mode != GM_MENU) { + int layer = calculateLayer(w->viewport) + (in ? -1 : 1); + if ((layer < 0) || (layer >= LayerCount())) return; + + Point pt = RemapCoords(0, (in ? -1 : 1) * LayerSizeY() * TILE_SIZE, 0); + w->viewport->dest_scrollpos_x += pt.x; + w->viewport->dest_scrollpos_y += pt.y; + w->InvalidateData(); + + } +} + void FixTitleGameZoom(int zoom_adjust) { if (_game_mode != GM_MENU) return; @@ -422,7 +441,11 @@ struct MainWindow : Window void OnMouseWheel(int wheel) override { if (_settings_client.gui.scrollwheel_scrolling != 2) { - ZoomInOrOutToCursorWindow(wheel < 0, this); + if (_ctrl_pressed) { + LayerUpOrDownToCursorWindow(wheel < 0, this); + } else { + ZoomInOrOutToCursorWindow(wheel < 0, this); + } } } diff --git a/src/viewport_func.h b/src/viewport_func.h index 58e1706eb..d8f2036aa 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -31,6 +31,7 @@ bool MarkAllViewportsDirty(int left, int top, int right, int bottom); bool DoZoomInOutWindow(ZoomStateChange how, Window *w); void ZoomInOrOutToCursorWindow(bool in, Window * w); +void LayerUpOrDownToCursorWindow(bool in, Window * w); Point GetTileZoomCenterWindow(bool in, Window * w); void FixTitleGameZoom(int zoom_adjust = 0); void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte widget_zoom_out); diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 5047f04f3..3c02f9ab8 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -14,6 +14,7 @@ #include "strings_func.h" #include "zoom_func.h" #include "window_func.h" +#include "gfx_func.h" #include "widgets/viewport_widget.h" @@ -137,7 +138,11 @@ public: void OnMouseWheel(int wheel) override { if (_settings_client.gui.scrollwheel_scrolling != 2) { - ZoomInOrOutToCursorWindow(wheel < 0, this); + if (_ctrl_pressed) { + LayerUpOrDownToCursorWindow(wheel < 0, this); + } else { + ZoomInOrOutToCursorWindow(wheel < 0, this); + } } } |