diff --git a/library/include/modules/Renderer.h b/library/include/modules/Renderer.h index 65a9694ab..864efd8c1 100644 --- a/library/include/modules/Renderer.h +++ b/library/include/modules/Renderer.h @@ -5,13 +5,6 @@ #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(); @@ -19,19 +12,12 @@ namespace DFHack { namespace Renderer { renderer_wrap *parent; renderer_wrap *child; - virtual void update_tile(int32_t x, int32_t y); - virtual void update_all(); - virtual void render(); - virtual void set_fullscreen(); - virtual void zoom(df::zoom_commands z); - virtual void resize(int32_t w, int32_t h); - virtual void grid_resize(int32_t w, int32_t h); virtual ~renderer_wrap() { // All necessary cleanup should be handled by RemoveRenderer() }; - virtual bool get_mouse_coords(int32_t *x, int32_t *y); - virtual bool uses_opengl(); }; + + /* TODO: we can't cat enabler->renderer to renderer_wrap and expect it to work // Returns the renderer instance given on success, or deletes it and returns NULL on failure // Usage: renderer_foo *r = AddRenderer(new renderer_foo) DFHACK_EXPORT renderer_wrap *AddRenderer(renderer_wrap*, bool refresh_screen = false); @@ -42,4 +28,5 @@ namespace DFHack { namespace Renderer { { return (renderer_wrap*)(df::global::enabler ? df::global::enabler->renderer : NULL); } + */ }} diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index e75ab41af..d3055c5af 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -2150,7 +2150,7 @@ bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t df::coord Gui::getMousePos() { df::coord pos; - if (gps && gps->mouse_x_pixel > -1) { + if (gps && gps->precise_mouse_x > -1) { pos = getViewportPos(); /* TODO: understand how this changes for v50 pos.x += gps->mouse_x_pixel / tile_width; diff --git a/library/modules/Renderer.cpp b/library/modules/Renderer.cpp index b746a149c..e134fa4f3 100644 --- a/library/modules/Renderer.cpp +++ b/library/modules/Renderer.cpp @@ -7,10 +7,9 @@ using df::global::enabler; using df::global::gps; 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) @@ -156,3 +155,4 @@ bool Renderer::renderer_wrap::get_mouse_coords(int32_t* x, int32_t* y) { bool Renderer::renderer_wrap::uses_opengl() { return parent->uses_opengl(); }; +*/ diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index 351515740..2d51b8e20 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -54,6 +54,7 @@ using namespace DFHack; #include "df/tile_page.h" #include "df/interfacest.h" #include "df/enabler.h" +#include "df/graphic_map_portst.h" #include "df/unit.h" #include "df/item.h" #include "df/job.h" @@ -87,7 +88,7 @@ df::coord2d Screen::getMousePos() { if (!gps) return df::coord2d(-1, -1); - return df::coord2d(gps->mouse_x_tile, gps->mouse_y_tile); + return df::coord2d(gps->mouse_x, gps->mouse_y); } // returns the screen pixel coordinates @@ -95,7 +96,7 @@ df::coord2d Screen::getMousePixels() { if (!gps) return df::coord2d(-1, -1); - return df::coord2d(gps->mouse_x_pixel, gps->mouse_y_pixel); + return df::coord2d(gps->precise_mouse_x, gps->precise_mouse_y); } df::coord2d Screen::getWindowSize() @@ -114,45 +115,20 @@ bool Screen::inGraphicsMode() return init && init->display.flag.is_set(init_display_flags::USE_GRAPHICS); } -static int32_t flood_clear(int32_t target, size_t index, size_t max_idx) { - if (index >= max_idx || !gps->screen1_offset_tile[index] - || gps->screen1_offset_tile[index] != target) - return 0; - gps->screen1_offset_tile[index] = 0; - gps->screen1_offset_x[index] = 0; - gps->screen1_offset_y[index] = 0; - int32_t cleared = 1; - cleared += flood_clear(target, index - 1, max_idx); - cleared += flood_clear(target, index + 1, max_idx); - cleared += flood_clear(target, index - gps->dimy, max_idx); - cleared += flood_clear(target, index + gps->dimy, max_idx); - return cleared; -} - static bool doSetTile_default(const Pen &pen, int x, int y, bool map) { - auto dim = Screen::getWindowSize(); - if (x < 0 || x >= dim.x || y < 0 || y >= dim.y) - return false; - // TODO: understand how this changes for v50 size_t index = ((x * gps->dimy) + y); if (!map) { // don't let DF overlay interface elements draw over us - gps->screen1_forced_tile[index] = 0; - gps->screen1_flags[index] = 0; - // the DF renderer can't handle partial offset tiles. make sure we clear - // the whole thing if we hit any part of it - int32_t cleared = flood_clear(gps->screen1_offset_tile[index], index, - (gps->dimx*gps->dimy)-1); - if (cleared) { - DEBUG(screen).print("offset tiles cleared: %d\n", cleared); - } + gps->screentexpos_anchored[index] = 0; + gps->screentexpos_top[index] = 0; + gps->screentexpos_flag[index] = 0; } //gps->screen1_opt_tile[index] = uint8_t(pen.tile); - auto fg = &gps->palette[pen.fg][0]; - auto bg = &gps->palette[pen.bg][0]; - auto argb = &gps->screen1_asciirgb[index * 8]; + auto fg = &gps->uccolor[pen.fg][0]; + auto bg = &gps->uccolor[pen.bg][0]; + auto argb = &gps->screen[index * 8]; argb[0] = uint8_t(pen.ch); argb[1] = fg[0]; argb[2] = fg[1];