|
|
@ -17,7 +17,6 @@
|
|
|
|
#include "modules/World.h"
|
|
|
|
#include "modules/World.h"
|
|
|
|
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("design");
|
|
|
|
DFHACK_PLUGIN("design");
|
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
|
|
|
|
using DFHack::color_value;
|
|
|
|
using DFHack::color_value;
|
|
|
|
|
|
|
|
|
|
|
|
REQUIRE_GLOBAL(window_x);
|
|
|
|
REQUIRE_GLOBAL(window_x);
|
|
|
@ -27,24 +26,25 @@ REQUIRE_GLOBAL(plotinfo);
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
using namespace df::enums;
|
|
|
|
|
|
|
|
|
|
|
|
enum ConfigValues {
|
|
|
|
|
|
|
|
CONFIG_IS_ENABLED = 0,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DFHack {
|
|
|
|
namespace DFHack {
|
|
|
|
DBG_DECLARE(pathable, log, DebugCategory::LINFO);
|
|
|
|
DBG_DECLARE(design, log, DebugCategory::LINFO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &out, std::vector<PluginCommand> &commands) {
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &out,
|
|
|
|
|
|
|
|
std::vector<PluginCommand> &commands) {
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown(color_ostream &out) {
|
|
|
|
std::map<uint32_t, Screen::Pen> PENS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) {
|
|
|
|
|
|
|
|
if (event == DFHack::SC_WORLD_UNLOADED) {
|
|
|
|
|
|
|
|
DEBUG(log,out).print("clearing PENS\n");
|
|
|
|
|
|
|
|
PENS.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::map<uint32_t, Screen::Pen> PENS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct DrawingPoint {
|
|
|
|
struct DrawingPoint {
|
|
|
|
uint32_t penKey = 0;
|
|
|
|
uint32_t penKey = 0;
|
|
|
|
std::pair<int, int> cursor_coords;
|
|
|
|
std::pair<int, int> cursor_coords;
|
|
|
@ -158,8 +158,8 @@ Screen::Pen get_pen(int x, int y, ShapeMap &arr, const std::string &type = "") {
|
|
|
|
auto mouse_pos = Gui::getMousePos();
|
|
|
|
auto mouse_pos = Gui::getMousePos();
|
|
|
|
bool mouse_over = mouse_pos.x == x && mouse_pos.y == y;
|
|
|
|
bool mouse_over = mouse_pos.x == x && mouse_pos.y == y;
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t pen_key =
|
|
|
|
uint32_t pen_key = gen_pen_key(n, s, e, w, is_drag_point, mouse_over,
|
|
|
|
gen_pen_key(n, s, e, w, is_drag_point, mouse_over, is_in_shape, is_extra);
|
|
|
|
is_in_shape, is_extra);
|
|
|
|
|
|
|
|
|
|
|
|
if (CURSORS_MAP.count({n, w, e, s}) > 0 && has_point(x, y)) {
|
|
|
|
if (CURSORS_MAP.count({n, w, e, s}) > 0 && has_point(x, y)) {
|
|
|
|
arr[x][y].cursor_coords = CURSORS_MAP.at({n, w, e, s});
|
|
|
|
arr[x][y].cursor_coords = CURSORS_MAP.at({n, w, e, s});
|
|
|
@ -169,8 +169,8 @@ Screen::Pen get_pen(int x, int y, ShapeMap &arr, const std::string &type = "") {
|
|
|
|
std::pair<int, int> cursor{-1, -1};
|
|
|
|
std::pair<int, int> cursor{-1, -1};
|
|
|
|
|
|
|
|
|
|
|
|
if (type != "") {
|
|
|
|
if (type != "") {
|
|
|
|
return make_pen(CURSORS_MAP.at({n, w, e, s}), is_drag_point, mouse_over,
|
|
|
|
return make_pen(CURSORS_MAP.at({n, w, e, s}), is_drag_point,
|
|
|
|
is_in_shape, is_extra);
|
|
|
|
mouse_over, is_in_shape, is_extra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (CURSORS_MAP.count({n, w, e, s}) > 0) {
|
|
|
|
if (CURSORS_MAP.count({n, w, e, s}) > 0) {
|
|
|
@ -183,7 +183,6 @@ Screen::Pen get_pen(int x, int y, ShapeMap &arr, const std::string &type = "") {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// DEBUG(status).print("not cached lmao\n");
|
|
|
|
|
|
|
|
return PENS.at(pen_key);
|
|
|
|
return PENS.at(pen_key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -228,8 +227,8 @@ static int design_draw_shape(lua_State *L) {
|
|
|
|
Screen::Pen cur_tile = Screen::readTile(x.first, y.first, true);
|
|
|
|
Screen::Pen cur_tile = Screen::readTile(x.first, y.first, true);
|
|
|
|
Screen::Pen pen = get_pen(x.first, y.first, arr);
|
|
|
|
Screen::Pen pen = get_pen(x.first, y.first, arr);
|
|
|
|
cur_tile.tile = pen.tile;
|
|
|
|
cur_tile.tile = pen.tile;
|
|
|
|
Screen::paintTile(cur_tile, x.first - *window_x, y.first - *window_y,
|
|
|
|
Screen::paintTile(cur_tile, x.first - *window_x,
|
|
|
|
true);
|
|
|
|
y.first - *window_y, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|