make the overlay work with TWBT

develop
myk002 2022-09-16 16:19:21 -07:00
parent b084171048
commit 3feca2ae58
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 15 additions and 5 deletions

@ -1,3 +1,5 @@
#include "df/renderer.h"
#include "df/viewscreen_adopt_regionst.h" #include "df/viewscreen_adopt_regionst.h"
#include "df/viewscreen_adventure_logst.h" #include "df/viewscreen_adventure_logst.h"
#include "df/viewscreen_announcelistst.h" #include "df/viewscreen_announcelistst.h"
@ -83,8 +85,7 @@
#include "df/viewscreen_workquota_detailsst.h" #include "df/viewscreen_workquota_detailsst.h"
#include "df/viewscreen_workshop_profilest.h" #include "df/viewscreen_workshop_profilest.h"
#include "modules/Gui.h" #include "Debug.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "VTableInterpose.h" #include "VTableInterpose.h"
#include "uicommon.h" #include "uicommon.h"
@ -96,14 +97,23 @@ DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(enabler); REQUIRE_GLOBAL(enabler);
REQUIRE_GLOBAL(gps); REQUIRE_GLOBAL(gps);
namespace DFHack {
DBG_DECLARE(overlay, log, DebugCategory::LINFO);
}
static const std::string button_text = "[ DFHack Launcher ]"; static const std::string button_text = "[ DFHack Launcher ]";
static bool clicked = false; static bool clicked = false;
static bool handle_click() { static bool handle_click() {
int32_t x, y; int32_t x = 0, y = 0;
if (!enabler->tracking_on || !enabler->mouse_lbut_down || clicked || if (!enabler->mouse_lbut_down || clicked ||
!Gui::getMousePos(x, y)) !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; return false;
}
if (y == gps->dimy - 1 && x >= 1 && (size_t)x <= button_text.size()) { if (y == gps->dimy - 1 && x >= 1 && (size_t)x <= button_text.size()) {
clicked = true; clicked = true;
Core::getInstance().setHotkeyCmd("gui/launcher"); Core::getInstance().setHotkeyCmd("gui/launcher");