Skip to content

Commit

Permalink
Merge branch 'develop' into adv-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Aug 25, 2024
2 parents 55b5328 + 994b146 commit dd3f933
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 41 deletions.
2 changes: 1 addition & 1 deletion data/init/dfhack.tools.init
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ alias add autounsuspend suspendmanager
alias add drain-aquifer aquifer drain --all
alias add gui/dig gui/design
alias add version help
alias add gui/family-affairs gui/pregnancy
alias add gui/pregnancy gui/family-affairs --pregnancy
6 changes: 0 additions & 6 deletions docs/about/Removed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ gui/dig
=======
Renamed to `gui/design`.

.. _gui/family-affairs:

gui/family-affairs
==================
Merged into `gui/pregnancy`.

.. _gui/hack-wish:

gui/hack-wish
Expand Down
4 changes: 3 additions & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ Template for new versions:
- System clipboard: when pasting single lines from the system clipboard, replace newlines with spaces so they don't show up as strange CP437 glyphs in-game
- `exterminate`: don't kill friendly undead (unless ``--include-friendly`` is passed) when specifying ``undead`` as the target
- `gui/settings-manager`: work details overlay no longer disappears when you click on a unit in the unit list
- `buildingplan`: fixed type confusion when using quick filter slot '0'

## Misc Improvements
- `orders`: more space efficient workshop overlay
- `gui/family-affairs`: is now an alias that points to `gui/pregnancy`
- `sort`: Search results on the Places>Stockpile tab now filter based on: the stockpile's default name & number, customized name, and the storable-category flags that are enabled for the stockpile
- `gui/family-affairs`: you can start this tool by the name ``gui/pregnancy`` to start on the "Pregnancies" tab

## Documentation
- Lua API document ``dfhack.items.findType(string)`` and ``dfhack.items.findSubtype(string)``
Expand Down
Binary file removed docs/images/family-affairs.png
Binary file not shown.
8 changes: 4 additions & 4 deletions plugins/examples/persistent_per_save_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static command_result do_command(color_ostream &out, vector<string> &parameters)
static void do_cycle(color_ostream &out);

DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands) {
DEBUG(config,out).print("initializing %s\n", plugin_name);
DEBUG(control,out).print("initializing %s\n", plugin_name);

// provide a configuration interface for the plugin
commands.push_back(PluginCommand(
Expand Down Expand Up @@ -116,7 +116,7 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
}

DFhackCExport command_result plugin_shutdown (color_ostream &out) {
DEBUG(config,out).print("shutting down %s\n", plugin_name);
DEBUG(control,out).print("shutting down %s\n", plugin_name);

return CR_OK;
}
Expand All @@ -136,7 +136,7 @@ DFhackCExport command_result plugin_load_site_data (color_ostream &out) {
// all the other state we can directly read/modify from the persistent
// data structure.
is_enabled = config.get_bool(CONFIG_IS_ENABLED);
DEBUG(config,out).print("loading persisted enabled state: %s\n",
DEBUG(control,out).print("loading persisted enabled state: %s\n",
is_enabled ? "true" : "false");

// load other config elements, if applicable
Expand All @@ -155,7 +155,7 @@ DFhackCExport command_result plugin_load_site_data (color_ostream &out) {
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) {
if (event == DFHack::SC_WORLD_UNLOADED) {
if (is_enabled) {
DEBUG(config,out).print("world unloaded; disabling %s\n",
DEBUG(control,out).print("world unloaded; disabling %s\n",
plugin_name);
is_enabled = false;
}
Expand Down
69 changes: 43 additions & 26 deletions plugins/lua/buildingplan/planneroverlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,29 @@ end
--

-- Used to store a table of the following format:
-- table<integer, { label: string, mats: string[] }>
-- integer: quick filter slot
-- table<string, { label: string, mats: string[] }>
-- string: quick filter slot (must be strings because of the way persistence works)
-- label: string representation of the filter
-- mats: list of material names allowed by the filter
BUILDINGPLAN_FILTERS_KEY = "buildingplan/quick-filters"

-- old saves may use numbers as keys, which we convert to string keys on load
dfhack.onStateChange[BUILDINGPLAN_FILTERS_KEY] = function(sc)
if sc ~= SC_MAP_LOADED or df.global.gamemode ~= df.game_mode.DWARF then
return
end
local saved_filters = dfhack.persistent.getSiteData(BUILDINGPLAN_FILTERS_KEY, {})
local new_filters = {}
for k, v in pairs(saved_filters) do
if type(k) == 'number' then
new_filters[tostring(k)] = v
elseif type(k) == 'string' then
new_filters[k] = v
end
end
dfhack.persistent.saveSiteData(BUILDINGPLAN_FILTERS_KEY, new_filters)
end

QuickFilter = defclass(QuickFilter, widgets.Panel)
QuickFilter.ATTRS{
idx=DEFAULT_NIL,
Expand Down Expand Up @@ -584,7 +601,7 @@ function PlannerOverlay:init()
self.selected = 1
self.state = ensure_key(config.data, 'planner')

self.selected_favorite = 1
self.selected_favorite = '1'

local main_panel = widgets.Panel{
view_id='main',
Expand Down Expand Up @@ -886,46 +903,46 @@ function PlannerOverlay:init()
frame_background=gui.CLEAR_PEN,
visible=self:callback('show_favorites'),
subviews={
QuickFilter{idx=1, frame={t=0,l=0},
QuickFilter{idx='1', frame={t=0,l=0},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(1) },
QuickFilter{idx=2, frame={t=1,l=0},
is_selected_fn=make_is_selected_filter('1') },
QuickFilter{idx='2', frame={t=1,l=0},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(2) },
QuickFilter{idx=3, frame={t=2,l=0},
is_selected_fn=make_is_selected_filter('2') },
QuickFilter{idx='3', frame={t=2,l=0},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(3) },
QuickFilter{idx=4, frame={t=3,l=0},
is_selected_fn=make_is_selected_filter('3') },
QuickFilter{idx='4', frame={t=3,l=0},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(4) },
QuickFilter{idx=5, frame={t=4,l=0},
is_selected_fn=make_is_selected_filter('4') },
QuickFilter{idx='5', frame={t=4,l=0},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(5) },
QuickFilter{idx=6, frame={t=0,l=27},
is_selected_fn=make_is_selected_filter('5') },
QuickFilter{idx='6', frame={t=0,l=27},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(6) },
QuickFilter{idx=7, frame={t=1,l=27},
is_selected_fn=make_is_selected_filter('6') },
QuickFilter{idx='7', frame={t=1,l=27},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(7) },
QuickFilter{idx=8, frame={t=2,l=27},
is_selected_fn=make_is_selected_filter('7') },
QuickFilter{idx='8', frame={t=2,l=27},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(8) },
QuickFilter{idx=9, frame={t=3,l=27},
is_selected_fn=make_is_selected_filter('8') },
QuickFilter{idx='9', frame={t=3,l=27},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(9) },
QuickFilter{idx=0, frame={t=4,l=27},
is_selected_fn=make_is_selected_filter('9') },
QuickFilter{idx='0', frame={t=4,l=27},
on_click_fn=self:callback("save_restore_filter"),
is_selected_fn=make_is_selected_filter(0) },
is_selected_fn=make_is_selected_filter('0') },
widgets.CycleHotkeyLabel {
view_id='slot_select',
frame={b=0, l=2},
key='CUSTOM_X',
key_back='CUSTOM_SHIFT_X',
label='next/previous slot',
auto_width=true,
options=utils.tabulate(function(i) return {label="", value=i} end, 0, 9),
initial_option=1,
on_change=function(val) print(val) self.selected_favorite = val end,
options=utils.tabulate(function(i) return {label="", value=tostring(i)} end, 0, 9),
initial_option='1',
on_change=function(val) self.selected_favorite = val end,
},
widgets.HotkeyLabel{
frame={b=0, l=28},
Expand Down
32 changes: 30 additions & 2 deletions plugins/lua/sort/places.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ local language_name_types = {
[df.language_name_type.Library] = 'Library',
}

local stockpile_settings_flag_names = {
animals = 'Animal',
food = 'Food',
furniture = 'Furniture',
corpses = 'Corpse',
refuse = 'Refuse',
stone = 'Stone',
ammo = 'Ammo',
coins = 'Coins',
bars_blocks = 'Bars/Blocks',
gems = 'Gems',
finished_goods = 'Finished Goods',
leather = 'Leather',
cloth = 'Cloth',
wood = 'Wood',
weapons = 'Weapon',
armor = 'Armor',
sheet = 'Sheet'
}

local function get_location_religion(religion_id, religion_type)
if religion_type == df.religious_practice_type.NONE then return 'Temple'
else return locationselector.get_religion_string(religion_id, religion_type) or '' end
Expand Down Expand Up @@ -112,8 +132,16 @@ local function get_location_search_key(zone)
end

local function get_stockpile_search_key(stockpile)
if #stockpile.name ~= 0 then return stockpile.name
else return ('Stockpile #%s'):format(stockpile.stockpile_number) end
local result = {}
if #stockpile.name ~= 0 then table.insert(result, stockpile.name) end

local flags = stockpile.settings.flags
for flag, name in pairs(stockpile_settings_flag_names) do
if flags[flag] then table.insert(result, name) end
end

table.insert(result, ('Stockpile #%s'):format(stockpile.stockpile_number))
return table.concat(result, ' ')
end

local function get_workshop_search_key(workshop)
Expand Down
2 changes: 1 addition & 1 deletion scripts

0 comments on commit dd3f933

Please sign in to comment.