summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.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
commit705f0ae90c0b17f2d051e1705569f54f687d76c7 (patch)
tree442ff03cf4716d34011b3800016bae3642f66818 /src/vehicle_gui.cpp
parent95f2181a1dbd2ac1276bf3e044d6d9161b96ed50 (diff)
downloadopenttd-705f0ae90c0b17f2d051e1705569f54f687d76c7.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/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index aac92f30c..e19086556 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -2086,9 +2086,16 @@ static void VehicleViewWndProc(Window *w, WindowEvent *e)
DoCommandP(v->tile, v->index, 0, NULL,
_vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]);
break;
- case VVW_WIDGET_CENTER_MAIN_VIEH: /* center main view */
- ScrollMainWindowTo(v->x_pos, v->y_pos);
- break;
+ case VVW_WIDGET_CENTER_MAIN_VIEH: {/* center main view */
+ const Window *mainwindow = FindWindowById(WC_MAIN_WINDOW, 0);
+ /* code to allow the main window to 'follow' the vehicle if the ctrl key is pressed */
+ if (_ctrl_pressed && mainwindow->viewport->zoom == ZOOM_LVL_NORMAL) {
+ WP(mainwindow, vp_d).follow_vehicle = v->index;
+ } else {
+ ScrollMainWindowTo(v->x_pos, v->y_pos);
+ }
+ } break;
+
case VVW_WIDGET_GOTO_DEPOT: /* goto hangar */
DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0, NULL,
_vehicle_command_translation_table[VCT_CMD_GOTO_DEPOT][v->type]);