From 2a52582c1f0305ae26d3931a50b276763681ef89 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 9 May 2018 10:23:05 -0400 Subject: [PATCH 1/5] Add Gui::inRenameBuilding --- library/LuaApi.cpp | 1 + library/include/modules/Gui.h | 2 ++ library/modules/Gui.cpp | 18 ++++++++++++++---- plugins/buildingplan.cpp | 4 +--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 852f4e29d..b78d621ce 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1493,6 +1493,7 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = { WRAPM(Gui, resetDwarfmodeView), WRAPM(Gui, revealInDwarfmodeMap), WRAPM(Gui, refreshSidebar), + WRAPM(Gui, inRenameBuilding), WRAPM(Gui, getDepthAt), { NULL, NULL } }; diff --git a/library/include/modules/Gui.h b/library/include/modules/Gui.h index ec5d1ea94..819ad1558 100644 --- a/library/include/modules/Gui.h +++ b/library/include/modules/Gui.h @@ -150,6 +150,8 @@ namespace DFHack DFHACK_EXPORT bool revealInDwarfmodeMap(df::coord pos, bool center = false); DFHACK_EXPORT bool refreshSidebar(); + DFHACK_EXPORT bool inRenameBuilding(); + DFHACK_EXPORT bool getViewCoords (int32_t &x, int32_t &y, int32_t &z); DFHACK_EXPORT bool setViewCoords (const int32_t x, const int32_t y, const int32_t z); diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 53bacb129..271aedcaf 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -111,14 +111,16 @@ using namespace DFHack; #include "df/world.h" using namespace df::enums; + +using df::global::gamemode; +using df::global::gps; using df::global::gview; using df::global::init; -using df::global::gps; -using df::global::ui; -using df::global::world; using df::global::selection_rect; +using df::global::ui; using df::global::ui_menu_width; -using df::global::gamemode; +using df::global::ui_sidebar_menus; +using df::global::world; static df::layer_object_listst *getLayerList(df::viewscreen_layer *layer, int idx) { @@ -1757,6 +1759,14 @@ bool Gui::refreshSidebar() return false; } +bool Gui::inRenameBuilding() +{ + if (!ui_sidebar_menus) + return false; + + return ui_sidebar_menus->barracks.in_rename; +} + bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z) { x = *df::global::window_x; diff --git a/plugins/buildingplan.cpp b/plugins/buildingplan.cpp index eb6d2a661..37bb069a4 100644 --- a/plugins/buildingplan.cpp +++ b/plugins/buildingplan.cpp @@ -1,11 +1,9 @@ #include "buildingplan-lib.h" -#include "df/ui_sidebar_menus.h" DFHACK_PLUGIN("buildingplan"); #define PLUGIN_VERSION 0.14 REQUIRE_GLOBAL(ui); REQUIRE_GLOBAL(ui_build_selector); -REQUIRE_GLOBAL(ui_sidebar_menus); REQUIRE_GLOBAL(world); DFhackCExport command_result plugin_shutdown ( color_ostream &out ) @@ -188,7 +186,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest } else if (isInNobleRoomQueryMode()) { - if (ui_sidebar_menus->barracks.in_rename) + if (Gui::inRenameBuilding()) return false; auto np = getNoblePositionOfSelectedBuildingOwner(); df::interface_key last_token = get_string_key(input); From ead0092765f5053ac6d4c1f78e5d8fdbe1549b29 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 9 May 2018 10:25:55 -0400 Subject: [PATCH 2/5] Ignore added stockpile keys when renaming stockpiles Fixes #1267 --- plugins/autodump.cpp | 3 +++ plugins/automelt.cpp | 3 +++ plugins/autotrade.cpp | 3 +++ plugins/stockpiles/stockpiles.cpp | 3 +++ plugins/stocks.cpp | 3 +++ 5 files changed, 15 insertions(+) diff --git a/plugins/autodump.cpp b/plugins/autodump.cpp index 3fbe1ae77..b70c7f83c 100644 --- a/plugins/autodump.cpp +++ b/plugins/autodump.cpp @@ -181,6 +181,9 @@ struct dump_hook : public df::viewscreen_dwarfmodest bool handleInput(set *input) { + if (Gui::inRenameBuilding()) + return false; + building_stockpilest *sp = get_selected_stockpile(); if (!sp) return false; diff --git a/plugins/automelt.cpp b/plugins/automelt.cpp index b4c93e15f..c01981603 100644 --- a/plugins/automelt.cpp +++ b/plugins/automelt.cpp @@ -194,6 +194,9 @@ struct melt_hook : public df::viewscreen_dwarfmodest bool handleInput(set *input) { + if (Gui::inRenameBuilding()) + return false; + building_stockpilest *sp = get_selected_stockpile(); if (!sp) return false; diff --git a/plugins/autotrade.cpp b/plugins/autotrade.cpp index a645d579e..c4257c195 100644 --- a/plugins/autotrade.cpp +++ b/plugins/autotrade.cpp @@ -389,6 +389,9 @@ struct trade_hook : public df::viewscreen_dwarfmodest bool handleInput(set *input) { + if (Gui::inRenameBuilding()) + return false; + building_stockpilest *sp = get_selected_stockpile(); if (!sp) return false; diff --git a/plugins/stockpiles/stockpiles.cpp b/plugins/stockpiles/stockpiles.cpp index d24a20a7a..ae3df03d1 100644 --- a/plugins/stockpiles/stockpiles.cpp +++ b/plugins/stockpiles/stockpiles.cpp @@ -376,6 +376,9 @@ struct stockpiles_import_hook : public df::viewscreen_dwarfmodest bool handleInput ( set *input ) { + if ( Gui::inRenameBuilding() ) + return false; + df::building_stockpilest *sp = get_selected_stockpile(); if ( !sp ) return false; diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index 154a58dc3..83eb01c4e 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -1451,6 +1451,9 @@ struct stocks_stockpile_hook : public df::viewscreen_dwarfmodest bool handleInput(set *input) { + if (Gui::inRenameBuilding()) + return false; + df::building_stockpilest *sp = get_selected_stockpile(); if (!sp) return false; From 2ada907420c10ba15b2a4de6270f86478ff694ab Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 9 May 2018 10:33:41 -0400 Subject: [PATCH 3/5] Move stockpiles option (load/save) below stocks/autodump/etc Fixes #1161 --- plugins/stockpiles/stockpiles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/stockpiles/stockpiles.cpp b/plugins/stockpiles/stockpiles.cpp index ae3df03d1..51d4ccb53 100644 --- a/plugins/stockpiles/stockpiles.cpp +++ b/plugins/stockpiles/stockpiles.cpp @@ -409,7 +409,7 @@ struct stockpiles_import_hook : public df::viewscreen_dwarfmodest auto dims = Gui::getDwarfmodeViewDims(); int left_margin = dims.menu_x1 + 1; int x = left_margin; - int y = dims.y2 - 7; + int y = dims.y2 - 3; int links = 0; links += sp->links.give_to_pile.size(); From b95e8f433ade53fefcc4ff3d3a76de15e7008033 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 9 May 2018 10:37:03 -0400 Subject: [PATCH 4/5] Update changelog, scripts --- docs/changelog.txt | 10 ++++++++++ scripts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index fe1b05f90..beaa1665a 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -37,6 +37,16 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ================================================================================ # Future +## New Scripts +- `devel/find-primitive`: Finds a primitive variable in memory + +## Fixes +- `stockpiles`: stopped sidebar option from overlapping with `autodump` +-@ `autodump`, `automelt`, `autotrade`, `stocks`, `stockpiles`: fixed conflict with building renaming + +## Internals +- Added ``Gui::inRenameBuilding()`` + # 0.44.10-alpha1 ## New Scripts diff --git a/scripts b/scripts index a1cd002d6..313655344 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit a1cd002d60fdbf7b4c4bf833db41ec691746552b +Subproject commit 313655344562956f2c3a2c3d547ac04816730306 From cd717a4fe8676bac94e753aa21b906a819d23581 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 9 May 2018 10:39:14 -0400 Subject: [PATCH 5/5] Fix stockpiles header in Plugins.rst --- docs/Plugins.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Plugins.rst b/docs/Plugins.rst index d8cfdd270..49c86ca8a 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -721,8 +721,8 @@ Replaces the DF stocks screen with an improved version. .. _stocksettings: .. _stockpiles: -stocksettings -============= +stockpiles +========== Offers the following commands to save and load stockpile settings. See `gui/stockpiles` for an in-game interface.