mousequery: use map dimensions to determine edge scrolling locations

TWBT modifies the map dimensions, so using the window dimensions to handle edge
scrolling produces the wrong behavior when using a larger map tileset than text
tileset.
develop
lethosor 2019-05-16 23:22:11 -04:00
parent edb5e37246
commit c3b06b81c7
1 changed files with 3 additions and 4 deletions

@ -572,12 +572,11 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
static decltype(enabler->clock) last_t = 0;
auto dims = Gui::getDwarfmodeViewDims();
auto right_margin = (dims.menu_x1 > 0) ? dims.menu_x1 : gps->dimx;
int32_t mx, my;
auto mpos = get_mouse_pos(mx, my);
bool mpos_valid = mpos.x != -30000 && mpos.y != -30000 && mpos.z != -30000;
if (mx < 1 || mx > right_margin - 2 || my < 1 || my > gps->dimy - 2)
if (mx < 1 || mx > dims.map_x2 || my < 1 || my > dims.map_y2)
mpos_valid = false;
// Check if in lever binding mode
@ -683,7 +682,7 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
return;
}
if (mx > right_margin - scroll_buffer)
if (mx > dims.map_x2 - scroll_buffer)
{
sendKey(interface_key::CURSOR_RIGHT);
return;
@ -695,7 +694,7 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
return;
}
if (my > gps->dimy - scroll_buffer)
if (my > dims.map_y2 - scroll_buffer)
{
sendKey(interface_key::CURSOR_DOWN);
return;