Skip to content

Commit 65a534b

Browse files
authored
Merge branch 'develop' into add_library_time_class
2 parents 4ea37e5 + 82491a6 commit 65a534b

File tree

16 files changed

+82
-62
lines changed

16 files changed

+82
-62
lines changed

docs/changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,23 @@ Template for new versions:
5454
## New Tools
5555

5656
## New Features
57+
- `prospect`: can now give you an estimate of resources from the embark screen. hover the mouse over a potential embark area and run `prospect`.
5758

5859
## Fixes
60+
- `stockpiles`: hide configure and help buttons when the overlay panel is minimized
61+
- `caravan`: price of vermin swarms correctly adjusted down. a stack of 10000 bees is worth 10, not 10000
5962

6063
## Misc Improvements
64+
- `buildingplan`: display how many items are available on the planner panel
65+
- `sort`: allow searching by profession on the squad assignment page
6166

6267
## Documentation
6368

6469
## API
70+
- ``Gui::revealInDwarfmodeMap``: gained ``highlight`` parameter to control setting the tile highlight on the zoom target
6571

6672
## Lua
73+
- ``dfhack.gui.revealInDwarfmodeMap``: gained ``highlight`` parameter to control setting the tile highlight on the zoom target
6774

6875
## Removed
6976

docs/dev/Lua API.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,11 +1053,13 @@ Fortress mode
10531053
Same as ``resetDwarfmodeView``, but also recenter if position is valid. If ``pause`` is false, skip pausing. Respects
10541054
``RECENTER_INTERFACE_SHUTDOWN_MS`` in DF's ``init.txt`` (the delay before input is recognized when a recenter occurs.)
10551055

1056-
* ``dfhack.gui.revealInDwarfmodeMap(pos[,center])``
1057-
``dfhack.gui.revealInDwarfmodeMap(x,y,z[,center])``
1056+
* ``dfhack.gui.revealInDwarfmodeMap(pos[,center[,highlight]])``
1057+
``dfhack.gui.revealInDwarfmodeMap(x,y,z[,center[,highlight]])``
10581058

1059-
Centers the view on the given coordinates. If ``center`` is true, make sure the
1060-
position is in the exact center of the view, else just bring it on screen.
1059+
Centers the view on the given coordinates. If ``center`` is true, make sure
1060+
the position is in the exact center of the view, else just bring it on screen.
1061+
If ``highlight`` is true, then mark the target tile with a pulsing highlight
1062+
until the player clicks somewhere else.
10611063

10621064
``pos`` can be a ``df.coord`` instance or a table assignable to a ``df.coord`` (see `lua-api-table-assignment`),
10631065
e.g.::

docs/plugins/prospector.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ prospector
1111
.. dfhack-command:: prospect
1212
:summary: Shows a summary of resources that exist on the map.
1313

14-
It can also calculate an estimate of resources available in the selected embark
15-
area.
14+
It can also calculate an estimate of resources available in the currently
15+
highlighted embark area.
1616

1717
Usage
1818
-----

library/LuaApi.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,11 +1660,19 @@ static int gui_revealInDwarfmodeMap(lua_State *state)
16601660
switch (lua_gettop(state))
16611661
{
16621662
default:
1663+
case 5:
1664+
rv = Gui::revealInDwarfmodeMap(CheckCoordXYZ(state, 1, false), lua_toboolean(state, 4), lua_toboolean(state, 5));
1665+
break;
16631666
case 4:
16641667
rv = Gui::revealInDwarfmodeMap(CheckCoordXYZ(state, 1, false), lua_toboolean(state, 4));
16651668
break;
16661669
case 3:
1667-
rv = Gui::revealInDwarfmodeMap(CheckCoordXYZ(state, 1, false));
1670+
if (lua_isboolean(state, 3)) {
1671+
Lua::CheckDFAssign(state, &p, 1);
1672+
rv = Gui::revealInDwarfmodeMap(p, lua_toboolean(state, 2), lua_toboolean(state, 3));
1673+
}
1674+
else
1675+
rv = Gui::revealInDwarfmodeMap(CheckCoordXYZ(state, 1, false));
16681676
break;
16691677
case 2:
16701678
Lua::CheckDFAssign(state, &p, 1);

library/include/modules/Gui.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ namespace DFHack
165165
DFHACK_EXPORT DwarfmodeDims getDwarfmodeViewDims();
166166

167167
DFHACK_EXPORT void resetDwarfmodeView(bool pause = false);
168-
DFHACK_EXPORT bool revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center = false);
169-
DFHACK_EXPORT inline bool revealInDwarfmodeMap(df::coord pos, bool center = false) { return revealInDwarfmodeMap(pos.x, pos.y, pos.z, center); };
168+
DFHACK_EXPORT bool revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center = false, bool highlight = false);
169+
DFHACK_EXPORT inline bool revealInDwarfmodeMap(df::coord pos, bool center = false, bool highlight = false) { return revealInDwarfmodeMap(pos.x, pos.y, pos.z, center, highlight); };
170170
DFHACK_EXPORT bool pauseRecenter(int32_t x, int32_t y, int32_t z, bool pause = true);
171171
DFHACK_EXPORT inline bool pauseRecenter(df::coord pos, bool pause = true) { return pauseRecenter(pos.x, pos.y, pos.z, pause); };
172172
DFHACK_EXPORT bool refreshSidebar();

library/modules/Gui.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,13 +2094,13 @@ void Gui::resetDwarfmodeView(bool pause)
20942094
*df::global::pause_state = true;
20952095
}
20962096

2097-
bool Gui::revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center)
2097+
bool Gui::revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center, bool highlight)
20982098
{ // Reverse-engineered from DF announcement and scrolling code
20992099
using df::global::window_x;
21002100
using df::global::window_y;
21012101
using df::global::window_z;
21022102

2103-
if (!window_x || !window_y || !window_z || !world)
2103+
if (!window_x || !window_y || !window_z || !world || !game)
21042104
return false;
21052105

21062106
auto dims = getDwarfmodeViewDims();
@@ -2137,6 +2137,12 @@ bool Gui::revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center)
21372137
game->minimap.update = true;
21382138
game->minimap.mustmake = true;
21392139

2140+
if (highlight) {
2141+
game->main_interface.recenter_indicator_m.x = x;
2142+
game->main_interface.recenter_indicator_m.y = y;
2143+
game->main_interface.recenter_indicator_m.z = z;
2144+
}
2145+
21402146
return true;
21412147
}
21422148

library/modules/Items.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,10 +2042,16 @@ int Items::getValue(df::item *item, df::caravan_state *caravan)
20422042
{
20432043
int divisor = 1;
20442044
auto creature = vector_get(world->raws.creatures.all, mat_type);
2045-
if (creature && size_t(mat_subtype) < creature->caste.size())
2046-
divisor = creature->caste[mat_subtype]->misc.petvalue_divisor;
2047-
if (divisor > 1)
2045+
if (creature) {
2046+
size_t caste = std::max(0, mat_subtype);
2047+
if (caste < creature->caste.size())
2048+
divisor = creature->caste[caste]->misc.petvalue_divisor;
2049+
}
2050+
if (divisor > 1) {
20482051
value /= divisor;
2052+
if (!value)
2053+
value = 1;
2054+
}
20492055
}
20502056

20512057
// Add in value from units contained in cages

plugins/lua/buildingplan/planneroverlay.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function ItemLine:get_item_line_text()
294294
uibs.building_type, uibs.building_subtype, uibs.custom_type, idx - 1)
295295
if self.available >= quantity then
296296
self.note_pen = COLOR_GREEN
297-
self.note = ' Available now'
297+
self.note = (' %d available now'):format(self.available)
298298
elseif self.available >= 0 then
299299
self.note_pen = COLOR_BROWN
300300
self.note = (' Will link next (need to make %d)'):format(quantity - self.available)

plugins/lua/sort.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local _ENV = mkmodule('plugins.sort')
33
local gui = require('gui')
44
local overlay = require('plugins.overlay')
55
local setbelief = reqscript('modtools/set-belief')
6-
local textures = require('gui.textures')
6+
local sortoverlay = require('plugins.sort.sortoverlay')
77
local utils = require('utils')
88
local widgets = require('gui.widgets')
99

@@ -1031,7 +1031,7 @@ local function filter_matches(unit_id, filter)
10311031
if filter.maimed == 'only' and not is_maimed(unit) then return false end
10321032
if filter.maimed == 'exclude' and is_maimed(unit) then return false end
10331033
if #filter.search == 0 then return true end
1034-
local search_key = dfhack.TranslateName(dfhack.units.getVisibleName(unit))
1034+
local search_key = sortoverlay.get_unit_search_key(unit)
10351035
return normalize_search_key(search_key):find(dfhack.toSearchNormalized(filter.search))
10361036
end
10371037

@@ -1233,14 +1233,15 @@ local function init_face_tiles()
12331233
FACE_TILES[idx-1] = face
12341234
end
12351235
end
1236+
init_face_tiles()
12361237

12371238
function get_stress_face_tile(idx, x, y)
12381239
local elem = rating_annotations[idx]
12391240
if not elem or not elem.val or elem.val < 0 then
12401241
return x == 0 and y == 1 and DASH_PEN or gui.CLEAR_PEN
12411242
end
12421243
local val = math.min(6, elem.val)
1243-
return FACE_TILES[val][y][x]
1244+
return safe_index(FACE_TILES, val, y, x)
12441245
end
12451246

12461247
function SquadAnnotationOverlay:init()

plugins/lua/sort/info.lua

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,9 @@ local function get_sort()
9797
end
9898
end
9999

100-
local function get_unit_search_key(unit)
101-
return ('%s %s %s'):format(
102-
dfhack.units.getReadableName(unit), -- last name is in english
103-
dfhack.units.getProfessionName(unit),
104-
dfhack.TranslateName(unit.name, false, true)) -- get untranslated last name
105-
end
106-
107100
local function get_cri_unit_search_key(cri_unit)
108101
return ('%s %s'):format(
109-
cri_unit.un and get_unit_search_key(cri_unit.un) or '',
102+
cri_unit.un and sortoverlay.get_unit_search_key(cri_unit.un) or '',
110103
cri_unit.job_sort_name)
111104
end
112105

@@ -132,7 +125,7 @@ local function work_details_search(vec, data, text, incremental)
132125
data.selected = work_details.selected_work_detail_index
133126
end
134127
sortoverlay.single_vector_search(
135-
{get_search_key_fn=get_unit_search_key},
128+
{get_search_key_fn=sortoverlay.get_unit_search_key},
136129
vec, data, text, incremental)
137130
end
138131

@@ -161,7 +154,7 @@ end
161154
local function get_candidate_search_key(cand)
162155
if not cand.un then return end
163156
return ('%s %s'):format(
164-
get_unit_search_key(cand.un),
157+
sortoverlay.get_unit_search_key(cand.un),
165158
serialize_skills(cand.un))
166159
end
167160

@@ -420,15 +413,15 @@ function InterrogationOverlay:init()
420413
self:register_handler('INTERROGATING', justice.interrogation_list,
421414
curry(sortoverlay.flags_vector_search,
422415
{
423-
get_search_key_fn=get_unit_search_key,
416+
get_search_key_fn=sortoverlay.get_unit_search_key,
424417
get_elem_id_fn=function(unit) return unit.id end,
425418
matches_filters_fn=self:callback('matches_filters'),
426419
},
427420
justice.interrogation_list_flag))
428421
self:register_handler('CONVICTING', justice.conviction_list,
429422
curry(sortoverlay.single_vector_search,
430423
{
431-
get_search_key_fn=get_unit_search_key,
424+
get_search_key_fn=sortoverlay.get_unit_search_key,
432425
matches_filters_fn=self:callback('matches_filters'),
433426
}))
434427
end

0 commit comments

Comments
 (0)