diff --git a/library/include/modules/Renderer.h b/library/include/modules/Renderer.h index 11abd7c1d..65a9694ab 100644 --- a/library/include/modules/Renderer.h +++ b/library/include/modules/Renderer.h @@ -5,6 +5,13 @@ #pragma once namespace DFHack { namespace Renderer { + // If the the 'x' parameter points to this value, then the 'y' parameter will + // be interpreted as a boolean flag for whether to return map coordinates (false) + // or text tile coordinates (true). Only TWBT implements this logic, and this + // sentinel value can be removed once DF provides an API for retrieving the + // two sets of coordinates. + DFHACK_EXPORT extern const int32_t GET_MOUSE_COORDS_SENTINEL; + struct DFHACK_EXPORT renderer_wrap : public df::renderer { void set_to_null(); void copy_from_parent(); diff --git a/library/modules/Renderer.cpp b/library/modules/Renderer.cpp index 474dc3656..b746a149c 100644 --- a/library/modules/Renderer.cpp +++ b/library/modules/Renderer.cpp @@ -9,6 +9,8 @@ using DFHack::Renderer::renderer_wrap; static renderer_wrap *original_renderer = NULL; +const int32_t Renderer::GET_MOUSE_COORDS_SENTINEL = 0xcd1aa471; + bool init() { if (!original_renderer) diff --git a/plugins/overlay.cpp b/plugins/overlay.cpp index 386b4b532..b8c4e1fb4 100644 --- a/plugins/overlay.cpp +++ b/plugins/overlay.cpp @@ -1,5 +1,3 @@ -#include "df/renderer.h" - #include "df/viewscreen_adopt_regionst.h" #include "df/viewscreen_adventure_logst.h" #include "df/viewscreen_announcelistst.h" @@ -90,6 +88,8 @@ #include "VTableInterpose.h" #include "uicommon.h" +#include "modules/Renderer.h" + using namespace DFHack; DFHACK_PLUGIN("overlay"); @@ -105,7 +105,7 @@ static const std::string button_text = "[ DFHack Launcher ]"; static bool clicked = false; static bool handle_click() { - int32_t x = 0, y = 0; + int32_t x = Renderer::GET_MOUSE_COORDS_SENTINEL, y = (int32_t)true; if (!enabler->mouse_lbut_down || clicked || !enabler->renderer->get_mouse_coords(&x, &y)) { DEBUG(log).print(