Changeset - r7759:89644b136fe9
[Not reviewed]
master
0 2 0
belugas - 17 years ago 2007-10-20 00:09:39
belugas@openttd.org
(svn r11304) -Feature: Control-Clicking the Center Main View button on the vehicle window allows the main viewport to follow the chosen vehicle.(stevenh)
2 files changed with 17 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/vehicle_gui.cpp
Show inline comments
 
@@ -2083,15 +2083,22 @@ static void VehicleViewWndProc(Window *w
 

	
 
			switch (e->we.click.widget) {
 
				case VVW_WIDGET_START_STOP_VEH: /* start stop */
 
					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]);
 
					break;
 
				case VVW_WIDGET_REFIT_VEH: /* refit */
 
					ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
src/window.cpp
Show inline comments
 
@@ -1463,12 +1463,19 @@ static bool HandleViewportScroll()
 
	bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
 

	
 
	if (!_scrolling_viewport) return true;
 

	
 
	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;
 
		return true;
 
	}
 

	
0 comments (0 inline, 0 general)