mirror of https://github.com/OpenRCT2/OpenRCT2.git
Compensate mouse position for window scaling.
This commit is contained in:
parent
7c12c48bfd
commit
34bef11f75
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue