summaryrefslogtreecommitdiff
path: root/src/smallmap_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-01-16 15:24:00 +0000
committeralberth <alberth@openttd.org>2010-01-16 15:24:00 +0000
commitff11095916537744e3683080c32e46f3c70f8416 (patch)
tree32d8ac5f18c363a2469ffb45901f518b2d110610 /src/smallmap_gui.cpp
parent6465f02fba984e169c904cccf89fd1417ee2f45b (diff)
downloadopenttd-ff11095916537744e3683080c32e46f3c70f8416.tar.xz
(svn r18827) -Fix: Center main window using smallmap widget edge coordinates.
Diffstat (limited to 'src/smallmap_gui.cpp')
-rw-r--r--src/smallmap_gui.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 5f9d8b647..c1744dc3d 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -953,11 +953,12 @@ public:
*/
_left_button_clicked = false;
+ const NWidgetBase *wid = this->GetWidget<NWidgetBase>(SM_WIDGET_MAP);
Point pt = RemapCoords(this->scroll_x, this->scroll_y, 0);
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
w->viewport->follow_vehicle = INVALID_VEHICLE;
- w->viewport->dest_scrollpos_x = pt.x + ((_cursor.pos.x - this->left + 2) << 4) - (w->viewport->virtual_width >> 1);
- w->viewport->dest_scrollpos_y = pt.y + ((_cursor.pos.y - this->top - 16) << 4) - (w->viewport->virtual_height >> 1);
+ w->viewport->dest_scrollpos_x = pt.x + ((_cursor.pos.x - this->left + wid->pos_x) << 4) - (w->viewport->virtual_width >> 1);
+ w->viewport->dest_scrollpos_y = pt.y + ((_cursor.pos.y - this->top - wid->pos_y) << 4) - (w->viewport->virtual_height >> 1);
this->SetDirty();
} break;