mirror of https://github.com/OpenTTD/OpenTTD
Change: Autoscrolling while following a vehicle stops following
parent
829883ba13
commit
be6317b4ff
|
@ -2683,15 +2683,20 @@ static void HandleAutoscroll()
|
||||||
y -= vp->top;
|
y -= vp->top;
|
||||||
|
|
||||||
/* here allows scrolling in both x and y axis */
|
/* here allows scrolling in both x and y axis */
|
||||||
|
/* If we succeed at scrolling in any direction, stop following a vehicle. */
|
||||||
static const int SCROLLSPEED = 3;
|
static const int SCROLLSPEED = 3;
|
||||||
if (x - 15 < 0) {
|
if (x - 15 < 0) {
|
||||||
|
w->viewport->follow_vehicle = INVALID_VEHICLE;
|
||||||
w->viewport->dest_scrollpos_x += ScaleByZoom((x - 15) * SCROLLSPEED, vp->zoom);
|
w->viewport->dest_scrollpos_x += ScaleByZoom((x - 15) * SCROLLSPEED, vp->zoom);
|
||||||
} else if (15 - (vp->width - x) > 0) {
|
} else if (15 - (vp->width - x) > 0) {
|
||||||
|
w->viewport->follow_vehicle = INVALID_VEHICLE;
|
||||||
w->viewport->dest_scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * SCROLLSPEED, vp->zoom);
|
w->viewport->dest_scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * SCROLLSPEED, vp->zoom);
|
||||||
}
|
}
|
||||||
if (y - 15 < 0) {
|
if (y - 15 < 0) {
|
||||||
|
w->viewport->follow_vehicle = INVALID_VEHICLE;
|
||||||
w->viewport->dest_scrollpos_y += ScaleByZoom((y - 15) * SCROLLSPEED, vp->zoom);
|
w->viewport->dest_scrollpos_y += ScaleByZoom((y - 15) * SCROLLSPEED, vp->zoom);
|
||||||
} else if (15 - (vp->height - y) > 0) {
|
} else if (15 - (vp->height - y) > 0) {
|
||||||
|
w->viewport->follow_vehicle = INVALID_VEHICLE;
|
||||||
w->viewport->dest_scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * SCROLLSPEED, vp->zoom);
|
w->viewport->dest_scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * SCROLLSPEED, vp->zoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue