diff --git a/docs/changelog.txt b/docs/changelog.txt index 6f2e0d8f7..c1c309b37 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -83,12 +83,14 @@ Template for new versions: - ``Units::getReadableName``: now returns the *untranslated* name - ``Burrows::setAssignedUnit``: now properly handles inactive burrows - ``Gui::getMousePos``: now takes an optional ``allow_out_of_bounds`` parameter so coordinates can be returned for mouse positions outside of the game map (i.e. in the blank space around the map) +- ``Buildings::completebuild``: used to link a newly created building into the world ## Lua - ``dfhack.gui.revealInDwarfmodeMap``: gained ``highlight`` parameter to control setting the tile highlight on the zoom target - ``dfhack.maps.getWalkableGroup``: get the walkability group of a tile - ``dfhack.gui.getMousePos``: support new optional ``allow_out_of_bounds`` parameter - ``gui.FRAME_THIN``: a panel frame suitable for floating tooltips +- ``dfhack.buildings.completebuild``: expose new module API ## Removed diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index a8e901a6d..93291592d 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -2440,6 +2440,7 @@ static const LuaWrapper::FunctionReg dfhack_buildings_module[] = { WRAPM(Buildings, isPenPasture), WRAPM(Buildings, isPitPond), WRAPM(Buildings, isActive), + WRAPM(Buildings, completebuild), { NULL, NULL } }; diff --git a/library/include/modules/Buildings.h b/library/include/modules/Buildings.h index 22dbb0370..6fbe0d6e1 100644 --- a/library/include/modules/Buildings.h +++ b/library/include/modules/Buildings.h @@ -289,5 +289,10 @@ DFHACK_EXPORT df::building* findPenPitAt(df::coord coord); * Returns the units currently in the given cage */ DFHACK_EXPORT bool getCageOccupants(df::building_cagest *cage, std::vector &units); + +/** + * Finalizes a new building into the world + */ +DFHACK_EXPORT void completebuild(df::building* bld, char in_play); } } diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 78c7b00ed..5bb1a55c1 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -1707,3 +1707,15 @@ bool Buildings::getCageOccupants(df::building_cagest *cage, vector &u return true; } + +void Buildings::completebuild(df::building* bld, char in_play) +{ + CHECK_NULL_POINTER(bld); + + auto fp = df::global::buildingst_completebuild; + CHECK_NULL_POINTER(fp); + + using FT = std::function; + auto f = reinterpret_cast(fp); + (*f)(bld, in_play); +} diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 475ac5728..c718bf46e 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -380,8 +380,13 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode) case df::view_sheet_type::BUILDING: if (game->main_interface.view_sheets.linking_lever) newFocusString = baseFocus + "/LinkingLever"; - else if (auto bld = df::building::find(game->main_interface.view_sheets.viewing_bldid)) + else if (auto bld = df::building::find(game->main_interface.view_sheets.viewing_bldid)) { newFocusString += '/' + enum_item_key(bld->getType()); + if (bld->getType() == df::enums::building_type::Trap) { + df::building_trapst* trap = strict_virtual_cast(bld); + newFocusString += '/' + enum_item_key(trap->trap_type); + } + } break; default: break; diff --git a/scripts b/scripts index 0ab280651..87e6f1ae3 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 0ab280651ead18b8678ea081f4ab1b0edc044847 +Subproject commit 87e6f1ae310ab81545198542cb07fea7016529c9