From 3feca2ae58e6977326130f0bad82d9cc6f9252ee Mon Sep 17 00:00:00 2001 From: myk002 Date: Fri, 16 Sep 2022 16:19:21 -0700 Subject: [PATCH] make the overlay work with TWBT --- plugins/overlay.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/overlay.cpp b/plugins/overlay.cpp index c4bbfb95b..386b4b532 100644 --- a/plugins/overlay.cpp +++ b/plugins/overlay.cpp @@ -1,3 +1,5 @@ +#include "df/renderer.h" + #include "df/viewscreen_adopt_regionst.h" #include "df/viewscreen_adventure_logst.h" #include "df/viewscreen_announcelistst.h" @@ -83,8 +85,7 @@ #include "df/viewscreen_workquota_detailsst.h" #include "df/viewscreen_workshop_profilest.h" -#include "modules/Gui.h" - +#include "Debug.h" #include "PluginManager.h" #include "VTableInterpose.h" #include "uicommon.h" @@ -96,14 +97,23 @@ DFHACK_PLUGIN_IS_ENABLED(is_enabled); REQUIRE_GLOBAL(enabler); REQUIRE_GLOBAL(gps); +namespace DFHack { + DBG_DECLARE(overlay, log, DebugCategory::LINFO); +} + static const std::string button_text = "[ DFHack Launcher ]"; static bool clicked = false; static bool handle_click() { - int32_t x, y; - if (!enabler->tracking_on || !enabler->mouse_lbut_down || clicked || - !Gui::getMousePos(x, y)) + int32_t x = 0, y = 0; + if (!enabler->mouse_lbut_down || clicked || + !enabler->renderer->get_mouse_coords(&x, &y)) { + DEBUG(log).print( + "lbut_down=%s; clicked=%s; mouse_x=%d; mouse_y=%d\n", + enabler->mouse_lbut_down ? "true" : "false", + clicked ? "true" : "false", x, y); return false; + } if (y == gps->dimy - 1 && x >= 1 && (size_t)x <= button_text.size()) { clicked = true; Core::getInstance().setHotkeyCmd("gui/launcher");