From 34bef11f7578b5f4158b9966784f272e033657e0 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 22 Jul 2016 12:09:38 +0200 Subject: [PATCH] Compensate mouse position for window scaling. --- src/interface/window.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/interface/window.c b/src/interface/window.c index c4ed8cdd92..716aefb020 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -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;