Add Gui::inRenameBuilding

develop
lethosor 2018-05-09 10:23:05 -04:00
parent c4c450a494
commit 2a52582c1f
4 changed files with 18 additions and 7 deletions

@ -1493,6 +1493,7 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
WRAPM(Gui, resetDwarfmodeView), WRAPM(Gui, resetDwarfmodeView),
WRAPM(Gui, revealInDwarfmodeMap), WRAPM(Gui, revealInDwarfmodeMap),
WRAPM(Gui, refreshSidebar), WRAPM(Gui, refreshSidebar),
WRAPM(Gui, inRenameBuilding),
WRAPM(Gui, getDepthAt), WRAPM(Gui, getDepthAt),
{ NULL, NULL } { NULL, NULL }
}; };

@ -150,6 +150,8 @@ namespace DFHack
DFHACK_EXPORT bool revealInDwarfmodeMap(df::coord pos, bool center = false); DFHACK_EXPORT bool revealInDwarfmodeMap(df::coord pos, bool center = false);
DFHACK_EXPORT bool refreshSidebar(); DFHACK_EXPORT bool refreshSidebar();
DFHACK_EXPORT bool inRenameBuilding();
DFHACK_EXPORT bool getViewCoords (int32_t &x, int32_t &y, int32_t &z); 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); DFHACK_EXPORT bool setViewCoords (const int32_t x, const int32_t y, const int32_t z);

@ -111,14 +111,16 @@ using namespace DFHack;
#include "df/world.h" #include "df/world.h"
using namespace df::enums; using namespace df::enums;
using df::global::gamemode;
using df::global::gps;
using df::global::gview; using df::global::gview;
using df::global::init; using df::global::init;
using df::global::gps;
using df::global::ui;
using df::global::world;
using df::global::selection_rect; using df::global::selection_rect;
using df::global::ui;
using df::global::ui_menu_width; 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) static df::layer_object_listst *getLayerList(df::viewscreen_layer *layer, int idx)
{ {
@ -1757,6 +1759,14 @@ bool Gui::refreshSidebar()
return false; 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) bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z)
{ {
x = *df::global::window_x; x = *df::global::window_x;

@ -1,11 +1,9 @@
#include "buildingplan-lib.h" #include "buildingplan-lib.h"
#include "df/ui_sidebar_menus.h"
DFHACK_PLUGIN("buildingplan"); DFHACK_PLUGIN("buildingplan");
#define PLUGIN_VERSION 0.14 #define PLUGIN_VERSION 0.14
REQUIRE_GLOBAL(ui); REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector); REQUIRE_GLOBAL(ui_build_selector);
REQUIRE_GLOBAL(ui_sidebar_menus);
REQUIRE_GLOBAL(world); REQUIRE_GLOBAL(world);
DFhackCExport command_result plugin_shutdown ( color_ostream &out ) DFhackCExport command_result plugin_shutdown ( color_ostream &out )
@ -188,7 +186,7 @@ struct buildingplan_hook : public df::viewscreen_dwarfmodest
} }
else if (isInNobleRoomQueryMode()) else if (isInNobleRoomQueryMode())
{ {
if (ui_sidebar_menus->barracks.in_rename) if (Gui::inRenameBuilding())
return false; return false;
auto np = getNoblePositionOfSelectedBuildingOwner(); auto np = getNoblePositionOfSelectedBuildingOwner();
df::interface_key last_token = get_string_key(input); df::interface_key last_token = get_string_key(input);