develop
John Cosker 2023-05-03 19:37:44 -04:00
parent 611e6d3a12
commit 58e11b01cb
2 changed files with 157 additions and 157 deletions

@ -41,6 +41,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements
- Terminal console no longer appears in front of the game window on startup
- `gui/design`: Improved performance for drawing shapes
## Documentation

@ -17,7 +17,6 @@
#include "modules/World.h"
DFHACK_PLUGIN("design");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
using DFHack::color_value;
REQUIRE_GLOBAL(window_x);
@ -27,24 +26,25 @@ REQUIRE_GLOBAL(plotinfo);
using namespace DFHack;
using namespace df::enums;
enum ConfigValues {
CONFIG_IS_ENABLED = 0,
};
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;
}
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;
}
std::map<uint32_t, Screen::Pen> PENS;
struct DrawingPoint {
uint32_t penKey = 0;
std::pair<int, int> cursor_coords;
@ -158,10 +158,10 @@ Screen::Pen get_pen(int x, int y, ShapeMap &arr, const std::string &type = "") {
auto mouse_pos = Gui::getMousePos();
bool mouse_over = mouse_pos.x == x && mouse_pos.y == y;
uint32_t pen_key =
gen_pen_key(n, s, e, w, is_drag_point, mouse_over, is_in_shape, is_extra);
uint32_t pen_key = gen_pen_key(n, s, e, w, is_drag_point, mouse_over,
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});
}
@ -169,21 +169,20 @@ Screen::Pen get_pen(int x, int y, ShapeMap &arr, const std::string &type = "") {
std::pair<int, int> cursor{-1, -1};
if (type != "") {
return make_pen(CURSORS_MAP.at({n, w, e, s}), is_drag_point, mouse_over,
is_in_shape, is_extra);
return make_pen(CURSORS_MAP.at({n, w, e, s}), is_drag_point,
mouse_over, is_in_shape, is_extra);
}
if (CURSORS_MAP.count({n, w, e, s}) > 0) {
PENS.emplace(pen_key,
make_pen(CURSORS_MAP.at({n, w, e, s}), is_drag_point,
mouse_over, is_in_shape, is_extra));
if (type == "" && has_point(x,y)) {
if (type == "" && has_point(x, y)) {
arr[x][y].penKey = pen_key;
}
}
}
// DEBUG(status).print("not cached lmao\n");
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 pen = get_pen(x.first, y.first, arr);
cur_tile.tile = pen.tile;
Screen::paintTile(cur_tile, x.first - *window_x, y.first - *window_y,
true);
Screen::paintTile(cur_tile, x.first - *window_x,
y.first - *window_y, true);
}
}