From f3af815cc1ffdce1b91fbd8ec978be58d0f41c81 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Fri, 12 Jul 2019 23:47:45 +0300 Subject: [PATCH] Fixed minimap scrolling --- src/smallmap_gui.cpp | 10 ++++++++++ src/smallmap_gui.h | 1 + todo.txt | 2 -- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index d5197ec93c..c4f0fa7d6d 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1413,6 +1413,16 @@ int SmallMapWindow::GetPositionOnLegend(Point pt) Window *w = FindWindowById(WC_MAIN_WINDOW, 0); int sub; pt = this->PixelToTile(pt.x - wid->pos_x, pt.y - wid->pos_y, &sub); + if (_settings_client.gui.scroll_mode == VSM_MAP_LMB) { + if (click_count > 0) { + this->lmb_scroll_pt.x = this->scroll_x + pt.x * TILE_SIZE; + this->lmb_scroll_pt.y = this->scroll_y + pt.y * TILE_SIZE; + } else { + this->SetNewScroll(this->lmb_scroll_pt.x - pt.x * TILE_SIZE, this->lmb_scroll_pt.y - pt.y * TILE_SIZE, 0); + this->SetDirty(); + break; + } + } ScrollWindowTo(this->scroll_x + pt.x * TILE_SIZE, this->scroll_y + pt.y * TILE_SIZE, -1, w); this->SetDirty(); diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index d81c5c77ed..5ff916dccd 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -75,6 +75,7 @@ protected: uint min_number_of_fixed_rows; ///< Minimal number of rows in the legends for the fixed layouts only (all except #SMT_INDUSTRY). uint column_width; ///< Width of a column in the #WID_SM_LEGEND widget. const uint row_height; ///< Heigth of each row in the #WID_SM_LEGEND widget. + Point lmb_scroll_pt; ///< Starting point for scrolling minimap with left mouse button. int32 scroll_x; ///< Horizontal world coordinate of the base tile left of the top-left corner of the smallmap display. int32 scroll_y; ///< Vertical world coordinate of the base tile left of the top-left corner of the smallmap display. diff --git a/todo.txt b/todo.txt index c877343a03..a1d6e8127f 100644 --- a/todo.txt +++ b/todo.txt @@ -11,8 +11,6 @@ - Select native screen width x 480 resolution on first run. -- Minimap scrolling is broken. - - Scrollable lists open scrolled to bottom. - Two-finger scroll when building road is broken.