Merge branch 'develop' into myk_no_stuck_df_viewscreens

develop
Myk 2023-01-29 16:55:52 -08:00 committed by GitHub
commit 376526d512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 120 additions and 53 deletions

@ -1,5 +1,5 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
echo Pre-generating a build folder
cmake ..\.. -G"Visual Studio 17 2022" -A x64 -B VC2022 -G"Visual Studio 17 2022" -A x64 -DCMAKE_INSTALL_PREFIX="%_DF_PATH%"
cmake ..\.. -G"Visual Studio 17 2022" -A x64 -B VC2022 -DCMAKE_INSTALL_PREFIX="%_DF_PATH%"
cmake-gui VC2022

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

@ -36,28 +36,34 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## New Plugins
## Fixes
-@ Ensure DF windows don't get "stuck" on transitions when DFHack tool windows are visible. Instead, those DF screens are force-paused while DFHack windows are visible so the player can close them first and not corrupt the screen sequence. The "force pause" indicator will appear on these DFHack windows to indicate what is happening.
-@ DF screens can no longer get "stuck" on transitions when DFHack tool windows are visible. Instead, those DF screens are force-paused while DFHack windows are visible so the player can close them first and not corrupt the screen sequence. The "force pause" indicator will appear on these DFHack windows to indicate what is happening.
-@ ``Screen``: allow `gui/launcher` and `gui/quickcmd` to launch themselves without hanging the game
-@ Fix issues with clicks "passing through" some DFHack window elements, like scrollbars
- `getplants`: tree are now designated correctly
## Misc Improvements
- A new cross-compile build script was added for building the Windows files from a Linux Docker builder (see the Compile instructions in the docs)
- You can now configure whether DFHack tool windows should pause the game by default
- `hotkeys`: clicking on the DFHack logo no longer closes the popup menu
- `gui/launcher`: sped up initialization time for faster load of the UI
- `orders`: orders plugin functionality is now offered via an overlay widget when the manager orders screen is open
- `gui/quickcmd`: now has it's own global keybinding for your convenience: Ctrl-Shift-A
- Many DFHack windows can now be unfocused by clicking somewhere not over the tool window. This has the same effect as pinning previously did, but without the extra clicking.
- `overlay`: overlay widgets can now specify a default enabled state if they are not already set in the player's overlay config file
- `getplants`: ID values will now be accepted regardless of case
-@ New borders for DFHack tool windows -- tell us what you think!
## Documentation
## API
- ``Buildings::containsTile()``: no longer takes a ``room`` parameter since that's not how rooms work anymore. If the building has extents, the extents will be checked. otherwise, the result just depends on whether the tile is within the building's bounding box.
- ``Units::getCitizens()``: gets a list of citizens, which otherwise you'd have to iterate over all units the world to discover
## Lua
- `helpdb`: new function: ``helpdb.refresh()`` to force a refresh of the database. Call if you are a developer adding new scripts, loading new plugins, or changing help text during play
- `helpdb`: changed from auto-refreshing every 60 seconds to only refreshing on explicit call to ``helpdb.refresh()``. docs very rarely change during a play session, and the automatic database refreshes were slowing down the startup of `gui/launcher`
- ``widgets.Label``: ``label.scroll()`` now understands ``home`` and ``end`` keywords for scrolling to the top or bottom
- ``dfhack.units.getCitizens()``: gets a list of citizens
## Removed

@ -1412,6 +1412,11 @@ Units module
Note that ``pos2xyz()`` cannot currently be used to convert coordinate objects to
the arguments required by this function.
* ``dfhack.units.getCitizens([ignore_sanity])``
Returns a table (list) of all citizens, which you would otherwise have to loop over all
units in world and test against ``isCitizen()`` to discover.
* ``dfhack.units.teleport(unit, pos)``
Moves the specified unit and any riders to the target coordinates, setting
@ -4182,9 +4187,12 @@ ZScreen provides the following functions:
ZScreen subclasses can set the following attributes:
* ``initial_pause`` (default: ``true``)
* ``initial_pause`` (default: ``DEFAULT_INITIAL_PAUSE``)
Whether to pause the game when the ZScreen is shown. ``DEFAULT_INITIAL_PAUSE``
defaults to ``true`` but can be set via running a command like::
Whether to pause the game when the ZScreen is shown.
:lua require('gui.widgets').DEFAULT_INITIAL_PAUSE = false
* ``force_pause`` (default: ``false``)

@ -1693,6 +1693,7 @@ static const LuaWrapper::FunctionReg dfhack_textures_module[] = {
WRAPM(Textures, getGreenPinTexposStart),
WRAPM(Textures, getRedPinTexposStart),
WRAPM(Textures, getIconsTexposStart),
WRAPM(Textures, getOnOffTexposStart),
WRAPM(Textures, getThinBordersTexposStart),
WRAPM(Textures, getMediumBordersTexposStart),
WRAPM(Textures, getPanelBordersTexposStart),
@ -1883,6 +1884,17 @@ static int units_getUnitsInBox(lua_State *state)
return 2;
}
static int units_getCitizens(lua_State *L) {
bool ignore_sanity = lua_toboolean(L, -1); // defaults to false
std::vector<df::unit *> citizens;
if (Units::getCitizens(citizens, ignore_sanity)) {
Lua::PushVector(L, citizens);
return 1;
}
return 0;
}
static int units_getStressCutoffs(lua_State *L)
{
lua_newtable(L);
@ -1896,6 +1908,7 @@ static const luaL_Reg dfhack_units_funcs[] = {
{ "getOuterContainerRef", units_getOuterContainerRef },
{ "getNoblePositions", units_getNoblePositions },
{ "getUnitsInBox", units_getUnitsInBox },
{ "getCitizens", units_getCitizens },
{ "getStressCutoffs", units_getStressCutoffs },
{ NULL, NULL }
};

@ -318,9 +318,10 @@ namespace DFHack
static const int RESTORE_AT_TOP = 0x1;
private:
void extract(df::viewscreen*);
void merge(df::viewscreen*);
void extract();
void merge();
df::viewscreen* screen;
df::viewscreen* prev_parent;
int flags;
};
}

@ -41,6 +41,11 @@ DFHACK_EXPORT long getRedPinTexposStart();
*/
DFHACK_EXPORT long getIconsTexposStart();
/**
* Get the first texpos for the on and off icons. It's a 2x1 grid.
*/
DFHACK_EXPORT long getOnOffTexposStart();
/**
* Get the first texpos for the DFHack borders. Each is a 7x3 grid.
*/

@ -145,6 +145,7 @@ DFHACK_EXPORT df::unit *getUnit(const int32_t index);
DFHACK_EXPORT bool getUnitsInBox(std::vector<df::unit*> &units,
int16_t x1, int16_t y1, int16_t z1,
int16_t x2, int16_t y2, int16_t z2);
DFHACK_EXPORT bool getCitizens(std::vector<df::unit *> &citizens, bool ignore_sanity = false);
DFHACK_EXPORT int32_t findIndexById(int32_t id);

@ -693,17 +693,25 @@ end
-- Z-order swapping screen --
-----------------------------
DEFAULT_INITIAL_PAUSE = true
local zscreen_inhibit_mouse_l = false
ZScreen = defclass(ZScreen, Screen)
ZScreen.ATTRS{
initial_pause=true,
initial_pause=DEFAULT_NIL,
force_pause=false,
pass_pause=true,
pass_movement_keys=false,
pass_mouse_clicks=true,
}
function ZScreen:preinit(args)
if args.initial_pause == nil then
args.initial_pause = DEFAULT_INITIAL_PAUSE
end
end
function ZScreen:init()
self.saved_pause_state = df.global.pause_state
if self.initial_pause and dfhack.isMapLoaded() then

@ -24,7 +24,7 @@ function foreach_module_script(cb)
end
end
local enabled_map = {}
local enabled_map = nil
local function process_script(env_name, env)
local global_name = 'isEnabled'
@ -44,10 +44,14 @@ function reload()
foreach_module_script(process_script)
end
local function ensure_loaded()
if not enabled_map then
reload()
end
end
function list()
-- call reload every time we list to make sure we get scripts that have
-- just been added
reload()
ensure_loaded()
for name,fn in pairs(enabled_map) do
print(('%21s %-3s'):format(name..':', fn() and 'on' or 'off'))
end

@ -527,43 +527,49 @@ void Screen::raise(df::viewscreen *screen) {
namespace DFHack { namespace Screen {
Hide::Hide(df::viewscreen* screen, int flags) :
screen{screen}, flags{flags}
{
extract(screen);
screen{screen}, prev_parent{nullptr}, flags{flags} {
if (!screen)
return;
// don't extract a screen that's not even in the stack
if (screen->parent)
extract();
}
Hide::~Hide()
{
Hide::~Hide() {
if (screen)
merge(screen);
merge();
}
void Hide::extract(df::viewscreen* a)
{
df::viewscreen* ap = a->parent;
df::viewscreen* ac = a->child;
void Hide::extract() {
prev_parent = screen->parent;
df::viewscreen *prev_child = screen->child;
ap->child = ac;
if (ac) ac->parent = ap;
else Core::getInstance().top_viewscreen = ap;
screen->parent = nullptr;
screen->child = nullptr;
prev_parent->child = prev_child;
if (prev_child) prev_child->parent = prev_parent;
else Core::getInstance().top_viewscreen = prev_parent;
}
void Hide::merge(df::viewscreen* a)
{
void Hide::merge() {
if (screen->parent) {
// we're somehow back on the stack; do nothing
return;
}
if (flags & RESTORE_AT_TOP) {
a->parent = NULL;
a->child = NULL;
Screen::show(std::unique_ptr<df::viewscreen>(a));
Screen::show(std::unique_ptr<df::viewscreen>(screen));
return;
}
df::viewscreen* ap = a->parent;
df::viewscreen* ac = a->parent->child;
df::viewscreen* new_child = prev_parent->child;
ap->child = a;
a->child = ac;
if (ac) ac->parent = a;
else Core::getInstance().top_viewscreen = a;
prev_parent->child = screen;
screen->child = new_child;
if (new_child) new_child->parent = screen;
else Core::getInstance().top_viewscreen = screen;
}
} }

@ -22,6 +22,7 @@ static long g_dfhack_logo_texpos_start = -1;
static long g_green_pin_texpos_start = -1;
static long g_red_pin_texpos_start = -1;
static long g_icons_texpos_start = -1;
static long g_on_off_texpos_start = -1;
static long g_thin_borders_texpos_start = -1;
static long g_medium_borders_texpos_start = -1;
static long g_panel_borders_texpos_start = -1;
@ -124,6 +125,8 @@ void Textures::init(color_ostream &out) {
&g_red_pin_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/icons.png",
&g_icons_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/on-off.png",
&g_on_off_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-thin.png",
&g_thin_borders_texpos_start);
g_num_dfhack_textures += load_textures(out, "hack/data/art/border-medium.png",
@ -180,6 +183,10 @@ long Textures::getIconsTexposStart() {
return g_icons_texpos_start;
}
long Textures::getOnOffTexposStart() {
return g_on_off_texpos_start;
}
long Textures::getThinBordersTexposStart() {
return g_thin_borders_texpos_start;
}

@ -756,6 +756,14 @@ bool Units::getUnitsInBox (std::vector<df::unit*> &units,
return true;
}
bool Units::getCitizens(std::vector<df::unit *> &citizens, bool ignore_sanity) {
for (auto &unit : world->units.active) {
if (isCitizen(unit, ignore_sanity))
citizens.emplace_back(unit);
}
return true;
}
int32_t Units::findIndexById(int32_t creature_id)
{
return df::unit::binsearch_index(world->units.all, creature_id);

@ -1 +1 @@
Subproject commit cf659eb0a0bc064208fcfeb4695ecee22e253d9f
Subproject commit a3b6cd5507753207ce28fe0872c98d6434d58a90

@ -369,13 +369,6 @@ static void bucket_tree(df::plant *plant, bool designate_clearcut, bool *designa
*can_chop = true;
}
static void get_citizens(vector<df::unit *> &vec) {
for (auto &unit : world->units.active) {
if (Units::isCitizen(unit))
vec.emplace_back(unit);
}
}
static void bucket_watched_burrows(color_ostream & out,
map<int, PersistentDataItem *> &clearcut_burrows,
map<int, PersistentDataItem *> &chop_burrows) {
@ -546,7 +539,7 @@ static int32_t do_cycle(color_ostream &out, bool force_designate) {
int32_t expected_yield;
TreesBySize designatable_trees_by_size;
vector<df::unit *> citizens;
get_citizens(citizens);
Units::getCitizens(citizens);
int32_t newly_marked = scan_trees(out, &expected_yield,
&designatable_trees_by_size, true, citizens);
@ -634,7 +627,7 @@ static void autochop_printStatus(color_ostream &out) {
int32_t designated_trees, expected_yield, accessible_yield;
map<int32_t, int32_t> tree_counts, designated_tree_counts;
vector<df::unit *> citizens;
get_citizens(citizens);
Units::getCitizens(citizens);
scan_logs(&usable_logs, citizens, &inaccessible_logs);
scan_trees(out, &expected_yield, NULL, false, citizens, &accessible_trees, &inaccessible_trees,
&designated_trees, &accessible_yield, &tree_counts, &designated_tree_counts);
@ -739,7 +732,7 @@ static int autochop_getLogCounts(lua_State *L) {
DEBUG(status,*out).print("entering autochop_getNumLogs\n");
int32_t usable_logs, inaccessible_logs;
vector<df::unit *> citizens;
get_citizens(citizens);
Units::getCitizens(citizens);
scan_logs(&usable_logs, citizens, &inaccessible_logs);
Lua::Push(L, usable_logs);
Lua::Push(L, inaccessible_logs);
@ -778,7 +771,7 @@ static int autochop_getTreeCountsAndBurrowConfigs(lua_State *L) {
int32_t designated_trees, expected_yield, accessible_yield;
map<int32_t, int32_t> tree_counts, designated_tree_counts;
vector<df::unit *> citizens;
get_citizens(citizens);
Units::getCitizens(citizens);
scan_trees(*out, &expected_yield, NULL, false, citizens, &accessible_trees, &inaccessible_trees,
&designated_trees, &accessible_yield, &tree_counts, &designated_tree_counts);

@ -7,6 +7,7 @@
#include "PluginManager.h"
#include "DataDefs.h"
#include "TileTypes.h"
#include "MiscUtils.h"
#include "df/map_block.h"
#include "df/map_block_column.h"
@ -321,9 +322,9 @@ bool designate(const df::plant *plant, bool farming) {
}
}
if ((!farming || seedSource) &&
ripe(plant->pos.x, plant->pos.y, plant_raw->growths[i]->timing_1, plant_raw->growths[i]->timing_2) &&
!picked(plant, i))
bool istree = (tileMaterial(Maps::getTileBlock(plant->pos)->tiletype[plant->pos.x % 16][plant->pos.y % 16]) == tiletype_material::TREE);
bool isripe = ripe(plant->pos.x, plant->pos.y, plant_raw->growths[i]->timing_1, plant_raw->growths[i]->timing_2);
if ((!farming || seedSource) && (istree || isripe) && !picked(plant, i))
{
return Designations::markPlant(plant);
}
@ -395,7 +396,7 @@ command_result df_getplants (color_ostream &out, vector <string> & parameters)
}
}
else
plantNames.insert(parameters[i]);
plantNames.insert(toUpper(parameters[i]));
}
if (treesonly && shrubsonly)
{
@ -428,7 +429,7 @@ command_result df_getplants (color_ostream &out, vector <string> & parameters)
// plantSelections[i] = selectablePlant(out, plant, farming);
plantSelections[i] = selectablePlant(plant, farming);
}
else if (plantNames.find(plant->id) != plantNames.end())
else if (plantNames.find(plant->id) != plantNames.end())
{
plantNames.erase(plant->id);
// plantSelections[i] = selectablePlant(out, plant, farming);

@ -1,6 +1,7 @@
#include "modules/Gui.h"
#include "modules/Maps.h"
#include "modules/Screen.h"
#include "modules/Textures.h"
#include "Debug.h"
#include "LuaTools.h"
@ -38,6 +39,11 @@ static void paintScreen(df::coord target, bool skip_unrevealed = false) {
long pathable_tile_texpos = 779;
long unpathable_tile_texpos = 782;
long on_off_texpos = Textures::getOnOffTexposStart();
if (on_off_texpos > 0) {
pathable_tile_texpos = on_off_texpos + 0;
unpathable_tile_texpos = on_off_texpos + 1;
}
auto dims = Gui::getDwarfmodeViewDims().map();
for (int y = dims.first.y; y <= dims.second.y; ++y) {

@ -1 +1 @@
Subproject commit 3193ad5c354a18cb55d41792379894b7b054c7bc
Subproject commit bf914ddd8c58011368f72172f9d158d0043c61fc