|
|
|
@ -20,6 +20,7 @@
|
|
|
|
|
#include "uicommon.h"
|
|
|
|
|
#include "TileTypes.h"
|
|
|
|
|
#include "DataFuncs.h"
|
|
|
|
|
#include "Debug.h"
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("mousequery");
|
|
|
|
|
REQUIRE_GLOBAL(enabler);
|
|
|
|
@ -32,6 +33,10 @@ using namespace df::enums::ui_sidebar_mode;
|
|
|
|
|
|
|
|
|
|
#define PLUGIN_VERSION 0.18
|
|
|
|
|
|
|
|
|
|
namespace DFHack {
|
|
|
|
|
DBG_DECLARE(mousequery,log,DebugCategory::LINFO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t last_clicked_x, last_clicked_y, last_clicked_z;
|
|
|
|
|
static int32_t last_pos_x, last_pos_y, last_pos_z;
|
|
|
|
|
static df::coord last_move_pos;
|
|
|
|
@ -53,22 +58,12 @@ static enum { None, Left, Right } drag_mode;
|
|
|
|
|
|
|
|
|
|
static df::coord get_mouse_pos(int32_t &mx, int32_t &my)
|
|
|
|
|
{
|
|
|
|
|
df::coord pos;
|
|
|
|
|
pos.x = -30000;
|
|
|
|
|
|
|
|
|
|
if (!enabler->tracking_on)
|
|
|
|
|
return pos;
|
|
|
|
|
df::coord pos = Gui::getMousePos();
|
|
|
|
|
pos.z -= Gui::getDepthAt(pos.x, pos.y);
|
|
|
|
|
|
|
|
|
|
if (!Gui::getMousePos(mx, my))
|
|
|
|
|
return pos;
|
|
|
|
|
|
|
|
|
|
int32_t vx, vy, vz;
|
|
|
|
|
if (!Gui::getViewCoords(vx, vy, vz))
|
|
|
|
|
return pos;
|
|
|
|
|
|
|
|
|
|
pos.x = vx + mx - 1;
|
|
|
|
|
pos.y = vy + my - 1;
|
|
|
|
|
pos.z = vz - Gui::getDepthAt(mx, my);
|
|
|
|
|
df::coord vpos = Gui::getViewportPos();
|
|
|
|
|
mx = pos.x - vpos.x + 1;
|
|
|
|
|
my = pos.y - vpos.y + 1;
|
|
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
|
}
|
|
|
|
@ -536,6 +531,7 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
|
|
|
|
|
if (mpos.x == x && mpos.y == y && mpos.z == z)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DEBUG(log).print("moving cursor to %d, %d, %d\n", x, y, z);
|
|
|
|
|
Gui::setCursorCoords(mpos.x, mpos.y, mpos.z);
|
|
|
|
|
Gui::refreshSidebar();
|
|
|
|
|
}
|
|
|
|
@ -575,8 +571,6 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
|
|
|
|
|
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 > dims.map_x2 || my < 1 || my > dims.map_y2)
|
|
|
|
|
mpos_valid = false;
|
|
|
|
|
|
|
|
|
|
// Check if in lever binding mode
|
|
|
|
|
if (Gui::getFocusString(Core::getTopViewscreen()) ==
|
|
|
|
@ -723,7 +717,7 @@ struct mousequery_hook : public df::viewscreen_dwarfmodest
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OutputString(color, mx, my, "X", false, 0, 0, true);
|
|
|
|
|
Screen::paintTile(Screen::Pen('X', color), mx, my, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|