Changeset - r15685:a314b8920e50
[Not reviewed]
master
0 1 0
terkhen - 14 years ago 2010-08-04 08:58:45
terkhen@openttd.org
(svn r20361) -Fix [FS#3989]: Stop vehicle following after zooming out.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -131,60 +131,62 @@ void ShowNetworkGiveMoneyWindow(CompanyI
 
/* Zooms a viewport in a window in or out
 
 * No button handling or what so ever */
 
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
 
{
 
	ViewPort *vp;
 

	
 
	assert(w != NULL);
 
	vp = w->viewport;
 

	
 
	switch (how) {
 
		case ZOOM_NONE:
 
			/* On initialisation of the viewport we don't do anything. */
 
			break;
 

	
 
		case ZOOM_IN:
 
			if (vp->zoom == ZOOM_LVL_MIN) return false;
 
			vp->zoom = (ZoomLevel)((int)vp->zoom - 1);
 
			vp->virtual_width >>= 1;
 
			vp->virtual_height >>= 1;
 

	
 
			w->viewport->scrollpos_x += vp->virtual_width >> 1;
 
			w->viewport->scrollpos_y += vp->virtual_height >> 1;
 
			w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
 
			w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
 
			w->viewport->follow_vehicle = INVALID_VEHICLE;
 
			break;
 
		case ZOOM_OUT:
 
			if (vp->zoom == ZOOM_LVL_MAX) return false;
 
			vp->zoom = (ZoomLevel)((int)vp->zoom + 1);
 

	
 
			w->viewport->scrollpos_x -= vp->virtual_width >> 1;
 
			w->viewport->scrollpos_y -= vp->virtual_height >> 1;
 
			w->viewport->dest_scrollpos_x = w->viewport->scrollpos_x;
 
			w->viewport->dest_scrollpos_y = w->viewport->scrollpos_y;
 

	
 
			vp->virtual_width <<= 1;
 
			vp->virtual_height <<= 1;
 
			w->viewport->follow_vehicle = INVALID_VEHICLE;
 
			break;
 
	}
 
	if (vp != NULL) { // the vp can be null when how == ZOOM_NONE
 
		vp->virtual_left = w->viewport->scrollpos_x;
 
		vp->virtual_top = w->viewport->scrollpos_y;
 
	}
 
	/* Update the windows that have zoom-buttons to perhaps disable their buttons */
 
	w->InvalidateData();
 
	return true;
 
}
 

	
 
void ZoomInOrOutToCursorWindow(bool in, Window *w)
 
{
 
	assert(w != NULL);
 

	
 
	if (_game_mode != GM_MENU) {
 
		ViewPort *vp = w->viewport;
 
		if ((in && vp->zoom == ZOOM_LVL_MIN) || (!in && vp->zoom == ZOOM_LVL_MAX)) return;
 

	
 
		Point pt = GetTileZoomCenterWindow(in, w);
 
		if (pt.x != -1) {
 
			ScrollWindowTo(pt.x, pt.y, -1, w, true);
 

	
 
			DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w);
0 comments (0 inline, 0 general)