absorb Putnam's work on Screen

develop
Myk Taylor 2022-12-16 11:53:44 -08:00 committed by Kelly Kinkade
parent ccc9e976e2
commit 768c95ecb6
2 changed files with 16 additions and 4 deletions

@ -178,6 +178,7 @@ namespace DFHack
}; };
DFHACK_EXPORT df::coord2d getMousePos(); DFHACK_EXPORT df::coord2d getMousePos();
DFHACK_EXPORT df::coord2d getMousePixels();
DFHACK_EXPORT df::coord2d getWindowSize(); DFHACK_EXPORT df::coord2d getWindowSize();
inline rect2d getScreenRect() { inline rect2d getScreenRect() {

@ -79,12 +79,23 @@ using std::string;
// returns text grid coordinates, even if the game map is scaled differently // returns text grid coordinates, even if the game map is scaled differently
df::coord2d Screen::getMousePos() df::coord2d Screen::getMousePos()
{ {
int32_t a, b, r, f; int32_t pixelx = 0, pixely = 0, tilex = 0, tiley = 0;
if (!enabler || !enabler->renderer->get_mouse_coords(&a, &b, &r, &f)) { if (!enabler || !enabler->renderer->get_mouse_coords(
&pixelx, &pixely, &tilex, &tiley)) {
return df::coord2d(-1, -1); return df::coord2d(-1, -1);
} }
std::cerr << "a,b,r,f = " << a << ", " << b << ", " << r << ", " << f << std::endl; return df::coord2d(tilex, tiley);
return df::coord2d(-1, -1); }
// returns the screen pixel coordinates
df::coord2d Screen::getMousePixels()
{
int32_t pixelx = 0, pixely = 0, tilex = 0, tiley = 0;
if (!enabler || !enabler->renderer->get_mouse_coords(
&pixelx, &pixely, &tilex, &tiley)) {
return df::coord2d(-1, -1);
}
return df::coord2d(pixelx, pixely);
} }
df::coord2d Screen::getWindowSize() df::coord2d Screen::getWindowSize()