Compensate mouse position for window scaling.

This commit is contained in:
Aaron van Geffen 2016-07-22 12:09:38 +02:00
parent 7c12c48bfd
commit 34bef11f75
1 changed files with 9 additions and 0 deletions

View File

@ -1449,6 +1449,11 @@ void window_viewport_get_map_coords_by_cursor(rct_window *w, sint16 *map_x, sint
{
int mouse_x, mouse_y;
platform_get_cursor_position(&mouse_x, &mouse_y);
// Compensate for window scaling.
mouse_x = (int) ceilf(mouse_x / gConfigGeneral.window_scale);
mouse_y = (int) ceilf(mouse_y / gConfigGeneral.window_scale);
get_map_coordinates_from_pos(mouse_x, mouse_y, VIEWPORT_INTERACTION_MASK_NONE, map_x, map_y, NULL, NULL, NULL);
}
@ -1463,6 +1468,10 @@ void window_viewport_centre_tile_around_cursor(rct_window *w, sint16 map_x, sint
int mouse_x, mouse_y;
platform_get_cursor_position(&mouse_x, &mouse_y);
// Compensate for window scaling.
mouse_x = (int) ceilf(mouse_x / gConfigGeneral.window_scale);
mouse_y = (int) ceilf(mouse_y / gConfigGeneral.window_scale);
// Rebase mouse position onto centre of window.
int rebased_x = (w->width >> 1) - mouse_x,
rebased_y = (w->height >> 1) - mouse_y;