Skip to content

Commit

Permalink
Merge branch 'DFHack:develop' into squid-docs-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
realSquidCoder authored Jan 13, 2025
2 parents 8a548e6 + df711f4 commit 0797342
Show file tree
Hide file tree
Showing 44 changed files with 272 additions and 287 deletions.
2 changes: 1 addition & 1 deletion build/build-win64-from-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if ! docker run --rm -i -v "$srcdir":/src -v "$srcdir/build/win64-cross/":/src/b
-e steam_password \
--name dfhack-win \
ghcr.io/dfhack/build-env:master \
bash -c "cd /src/build && dfhack-configure windows 64 Release -DCMAKE_INSTALL_PREFIX=/src/build/output -DBUILD_DOCS=1 $CMAKE_EXTRA_ARGS && dfhack-make -j$jobs install && find $(find -name depends -o -name library -o -name plugins) -iname '*.pdb' -exec cp '{}' pdb/ \;" \
bash -c "cd /src/build && dfhack-configure windows 64 Release -DCMAKE_INSTALL_PREFIX=/src/build/output -DBUILD_DOCS=1 $CMAKE_EXTRA_ARGS && dfhack-make -j$jobs install && find . \! -path './pdb/*' -name '*.pdb' -type f -exec cp '{}' pdb/ \;" \
; then
echo
echo "Build failed"
Expand Down
10 changes: 7 additions & 3 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Template for new versions:

## New Features
- `stockpiles`: add simple import/export dialogs to stockpile overlay panel
- `orders`: add overlays to the manager orders screen that allow right clicks to cancel edit of quantities or condition details instead of exiting to the main screen

## Fixes
- `preserve-rooms`: don't erroneously release reservations for units that have returned from their missions but have not yet entered the fort map
Expand All @@ -67,24 +68,27 @@ Template for new versions:
## Misc Improvements
- `strangemood`: add ability to choose Stone Cutting and Stone Carving as the mood skill
- `suspendmanager`: add more specific messages for submerged jobsites and those managed by `buildingplan`
- `dig-now`: handle digging in pool and river tiles

## Documentation
- Added example code for creating plugin RPC endpoints that can be used to extend the DFHack API

## API
- ``Units::isUnitInBox``, ``Units::getUnitsInBox``: add versions accepting pos arguments
- ``Units::getVisibleName``: when acting on a unit without an impersonated identity, returns the unit's name structure instead of the associated histfig's name structure
- ``Translation::GenerateName``: generates in-game names, reimplemented based on DF's own logic
- ``Translation::generateName``: generates in-game names, mirroring DF's internal logic

## Lua
- ``dfhack.units.isUnitInBox``, ``dfhack.units.getUnitsInBox``: add versions accepting pos arguments
- ``widgets.FilteredList``: search keys for list items can now be functions that return a string
- ``dfhack.GenerateName``: Lua API for ``Translation::GenerateName``
- ``dfhack.translation.generateName``: Lua API for ``Translation::generateName``

## Removed
- ``dfhack.TranslateName`` has been renamed to ``dfhack.translation.translateName``
- ``Translation::TranslateName`` has been renamed to ``Translation::translateName``

## Internals
- Plugin command callbacks are now called with the core suspended by default so DF memory is always safe to access
- Plugin command callbacks are now called with the core suspended by default so DF memory is always safe to access without extra steps
- Errors when unloading a plugin's DLL are now checked and reported

# 50.15-r1.2
Expand Down
23 changes: 13 additions & 10 deletions docs/dev/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -949,14 +949,6 @@ can be omitted.

Checks if a site (e.g., a player fort) is loaded.

* ``dfhack.TranslateName(name[,in_english[,only_last_name]])``

Convert a ``df.language_name`` (or only the last name part) to string.

* ``dfhack.GenerateName(name,language,type,major_selector,minor_selector)``

Dynamically generate a name using the same logic the game itself uses.

* ``dfhack.df2utf(string)``

Convert a string from DF's CP437 encoding to UTF-8.
Expand All @@ -969,8 +961,8 @@ can be omitted.
.. warning::

When printing CP437-encoded text to the console (for example, names returned
from ``dfhack.TranslateName()``), use ``print(dfhack.df2console(text))`` to
ensure proper display on all platforms.
from ``dfhack.units.getReadableName()``), use
``print(dfhack.df2console(text))`` to ensure proper display on all platforms.

* ``dfhack.utf2df(string)``

Expand Down Expand Up @@ -1038,6 +1030,17 @@ can be omitted.
returns an ``output, command_result`` pair. ``output`` is a single string -
see ``dfhack.internal.runCommand()`` to obtain colors as well.

Translation module
------------------

* ``dfhack.translation.translateName(name[,in_english[,only_last_name]])``

Convert a ``df.language_name`` (or only the last name part) to string.

* ``dfhack.translation.generateName(name,language,type,major_selector,minor_selector)``

Dynamically generate a name using the same logic the game itself uses.

Gui module
----------

Expand Down
36 changes: 23 additions & 13 deletions docs/plugins/orders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,32 @@ Examples
Import manager orders from the library that keep your fort stocked with
basic essentials.

Overlay
-------
Overlays
--------

The orders plugin provides several overlays managed by the `overlay` framework.
You can toggle them via the ``Overlays`` tab in `gui/control-panel` or
reposition the ones with onscreen widgets with `gui/overlay`.

Fort-wide work orders screen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
orders.importexport
~~~~~~~~~~~~~~~~~~~

Orders plugin functionality is directly available via an `overlay` widget when
the fort-wide work orders screen is open. There are hotkeys assigned to export,
import, sort, clear, and recheck conditions. You can also click on the hotkey
hints as if they were buttons. Clearing will ask for confirmation before acting.
Adds a panel to the fort-wide work orders screen that allows access to `orders`
plugin functionality. There are hotkeys assigned to export, import, sort,
clear, and recheck conditions. You can also click on the hotkey hints as if
they were buttons. Clearing will ask for confirmation before acting.

When you open the conditions screen for a manager order, there is also a small
orders.recheck
~~~~~~~~~~~~~~

When you open the conditions screen for a manager order, there is a small
overlay that allows you to recheck conditions for just that order. This is
useful for when the conditions were true when the order started, but they have
become false and now you're just getting repeated cancellation spam as the
order cannot be fulfilled.

Workshop Workers tab
~~~~~~~~~~~~~~~~~~~~
orders.skillrestrictions and orders.laborrestrictions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For workshops that do *not* have a workshop master assigned, there is a slider
you can use to restrict the units that perform jobs at that workshop by their
Expand Down Expand Up @@ -106,8 +113,11 @@ Veteran players may remember these overlays as vanilla features in pre-v50 Dwarf
Fortress. This is actually still the case. The DFHack overlay simply provides a
UI for the vanilla feature hiding beneath the surface.

If you want to change where the overlay panels appear, you can move them with
`gui/overlay`.
orders.\*rightclick
~~~~~~~~~~~~~~~~~~~

These overlays are invisible interface improvements. They allow you to cancel
out of data entry with Escape or right mouse click without exiting the screen.

The orders library
------------------
Expand Down
1 change: 0 additions & 1 deletion library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ if(BUILD_LIBRARY)

set(MAIN_HEADERS
include/Internal.h
include/DFHack.h
include/DFHackVersion.h
include/BitArray.h
include/ColorText.h
Expand Down
16 changes: 0 additions & 16 deletions library/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,13 @@ bool is_builtin(color_ostream &con, const std::string &command) {
}

void get_commands(color_ostream &con, std::vector<std::string> &commands) {
#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Cannot acquire core lock in helpdb.get_commands\n");
commands.clear();
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand Down Expand Up @@ -630,16 +626,12 @@ static std::string sc_event_name (state_change_event id) {
}

void help_helper(color_ostream &con, const std::string &entry_name) {
#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Failed Lua call to helpdb.help (could not acquire core lock).\n");
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand All @@ -658,16 +650,12 @@ void help_helper(color_ostream &con, const std::string &entry_name) {
}

void tags_helper(color_ostream &con, const std::string &tag) {
#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Failed Lua call to helpdb.help (could not acquire core lock).\n");
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand Down Expand Up @@ -705,16 +693,12 @@ void ls_helper(color_ostream &con, const std::vector<std::string> &params) {
filter.push_back(str);
}

#ifdef LINUX_BUILD
CoreSuspender suspend;
#else
ConditionalCoreSuspender suspend{};

if (!suspend) {
con.printerr("Failed Lua call to helpdb.help (could not acquire core lock).\n");
return;
}
#endif

auto L = DFHack::Core::getInstance().getLuaState();
Lua::StackUnwinder top(L);
Expand Down
12 changes: 10 additions & 2 deletions library/LuaApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,7 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAP(isWorldLoaded),
WRAP(isMapLoaded),
WRAP(isSiteLoaded),
WRAPM(Translation, TranslateName),
WRAPM(Translation, GenerateName),
WRAPN(Translation, Translation::translateName), // left for backward compatibility
WRAP(df2utf),
WRAP(utf2df),
WRAP(df2console),
Expand Down Expand Up @@ -1405,6 +1404,14 @@ static const luaL_Reg dfhack_funcs[] = {
{ NULL, NULL }
};

/***** Translation module *****/

static const LuaWrapper::FunctionReg dfhack_translation_module[] = {
WRAPM(Translation, translateName),
WRAPM(Translation, generateName),
{ NULL, NULL }
};

/***** Gui module *****/

static int gui_getDwarfmodeViewDims(lua_State *state)
Expand Down Expand Up @@ -4248,6 +4255,7 @@ void OpenDFHackApi(lua_State *state)

LuaWrapper::SetFunctionWrappers(state, dfhack_module);
luaL_setfuncs(state, dfhack_funcs, 0);
OpenModule(state, "translation", dfhack_translation_module);
OpenModule(state, "gui", dfhack_gui_module, dfhack_gui_funcs);
OpenModule(state, "job", dfhack_job_module, dfhack_job_funcs);
OpenModule(state, "textures", dfhack_textures_funcs);
Expand Down
1 change: 0 additions & 1 deletion library/LuaTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ distribution.
#include "modules/Gui.h"
#include "modules/Job.h"
#include "modules/Screen.h"
#include "modules/Translation.h"
#include "modules/Units.h"

#include "df/building.h"
Expand Down
1 change: 0 additions & 1 deletion library/PlugLoad.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Core.h"
#include "DFHack.h"
#include "Debug.h"
#include "Export.h"
#include "PluginManager.h"
Expand Down
4 changes: 2 additions & 2 deletions library/RemoteTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ void DFHack::describeName(NameInfo *info, df::language_name *name)
if (name->language >= 0)
info->set_language_id(name->language);

std::string lname = Translation::TranslateName(name, false, true);
std::string lname = Translation::translateName(name, false, true);
if (!lname.empty())
info->set_last_name(DF2UTF(lname));

lname = Translation::TranslateName(name, true, true);
lname = Translation::translateName(name, true, true);
if (!lname.empty())
info->set_english_name(DF2UTF(lname));
}
Expand Down
8 changes: 4 additions & 4 deletions library/include/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ namespace DFHack

void unlock()
{
if (!owns_lock())
return;
/* Restore core owner to previous value */
if (tid == std::thread::id{})
Lua::Core::Reset(core.getConsole(), "suspend");
Expand All @@ -386,7 +384,8 @@ namespace DFHack
}

~CoreSuspenderBase() {
unlock();
if (owns_lock())
unlock();
}

protected:
Expand Down Expand Up @@ -438,7 +437,8 @@ namespace DFHack

// note that this is needed so the destructor will call CoreSuspender::unlock instead of CoreSuspenderBase::unlock
~CoreSuspender() {
unlock();
if (owns_lock())
unlock();
}

protected:
Expand Down
78 changes: 0 additions & 78 deletions library/include/DFHack.h

This file was deleted.

Loading

0 comments on commit 0797342

Please sign in to comment.