set sentinel value used by TWBT

develop
myk002 2022-09-16 20:59:02 -07:00
parent 3feca2ae58
commit d0a5db2a0d
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
3 changed files with 12 additions and 3 deletions

@ -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();

@ -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)

@ -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(