MCPcopy Create free account
hub / github.com/DFHack/dfhack / getMousePos

Method getMousePos

library/modules/Gui.cpp:2979–2996  ·  view source on GitHub ↗

returns the map coordinates that the mouse cursor is over

Source from the content-addressed store, hash-verified

2977
2978// returns the map coordinates that the mouse cursor is over
2979df::coord Gui::getMousePos(bool allow_out_of_bounds)
2980{
2981 df::coord pos;
2982 if (gps && gps->precise_mouse_x > -1) {
2983 pos = getViewportPos();
2984 if (Screen::inGraphicsMode()) {
2985 int32_t map_tile_pixels = gps->viewport_zoom_factor / 4;
2986 pos.x += gps->precise_mouse_x / map_tile_pixels;
2987 pos.y += gps->precise_mouse_y / map_tile_pixels;
2988 } else {
2989 pos.x += gps->mouse_x;
2990 pos.y += gps->mouse_y;
2991 }
2992 }
2993 if (!allow_out_of_bounds && !Maps::isValidTilePos(pos.x, pos.y, pos.z))
2994 return df::coord();
2995 return pos;
2996}
2997
2998int getDepthAt_default (int32_t x, int32_t y)
2999{

Callers

nothing calls this directly

Calls 1

isValidTilePosFunction · 0.85

Tested by

no test coverage detected