summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-10-20 00:09:39 +0000
committerbelugas <belugas@openttd.org>2007-10-20 00:09:39 +0000
commit202b4de2792b00e3194c9a760d48f491403d7c15 (patch)
tree442ff03cf4716d34011b3800016bae3642f66818 /src/window.cpp
parent8342c18fb5f96465c917f9f89ec31765b0c21c6c (diff)
downloadopenttd-202b4de2792b00e3194c9a760d48f491403d7c15.tar.xz
(svn r11304) -Feature: Control-Clicking the Center Main View button on the vehicle window allows the main viewport to follow the chosen vehicle.(stevenh)
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 82458879b..44dc9ae2a 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1466,6 +1466,13 @@ static bool HandleViewportScroll()
w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
+ if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE && w == FindWindowById(WC_MAIN_WINDOW, 0)) {
+ /* If the main window is following a vehicle, then first let go of it! */
+ const Vehicle *veh = GetVehicle(WP(w, vp_d).follow_vehicle);
+ ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); /* This also resets follow_vehicle */
+ return true;
+ }
+
if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) {
_cursor.fix_at = false;
_scrolling_viewport = false;