diff --git a/data/init/dfhack.tools.init b/data/init/dfhack.tools.init index 2ffad78ea5..8087c2af1c 100644 --- a/data/init/dfhack.tools.init +++ b/data/init/dfhack.tools.init @@ -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 diff --git a/docs/about/Removed.rst b/docs/about/Removed.rst index d3fecdb271..4c04ac72d8 100644 --- a/docs/about/Removed.rst +++ b/docs/about/Removed.rst @@ -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 diff --git a/docs/changelog.txt b/docs/changelog.txt index fca2a0e01b..8fb35ee219 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -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)`` diff --git a/docs/images/family-affairs.png b/docs/images/family-affairs.png deleted file mode 100644 index faf59390eb..0000000000 Binary files a/docs/images/family-affairs.png and /dev/null differ diff --git a/plugins/examples/persistent_per_save_example.cpp b/plugins/examples/persistent_per_save_example.cpp index 09645cfa60..c7a2ccde0f 100644 --- a/plugins/examples/persistent_per_save_example.cpp +++ b/plugins/examples/persistent_per_save_example.cpp @@ -83,7 +83,7 @@ static command_result do_command(color_ostream &out, vector ¶meters) static void do_cycle(color_ostream &out); DFhackCExport command_result plugin_init(color_ostream &out, std::vector &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( @@ -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; } @@ -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 @@ -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; } diff --git a/plugins/lua/buildingplan/planneroverlay.lua b/plugins/lua/buildingplan/planneroverlay.lua index f068d4545a..62e1a6c49c 100644 --- a/plugins/lua/buildingplan/planneroverlay.lua +++ b/plugins/lua/buildingplan/planneroverlay.lua @@ -462,12 +462,29 @@ end -- -- Used to store a table of the following format: --- table --- integer: quick filter slot +-- table +-- 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, @@ -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', @@ -886,36 +903,36 @@ 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}, @@ -923,9 +940,9 @@ function PlannerOverlay:init() 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}, diff --git a/plugins/lua/sort/places.lua b/plugins/lua/sort/places.lua index 89cd382167..3251a509e9 100644 --- a/plugins/lua/sort/places.lua +++ b/plugins/lua/sort/places.lua @@ -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 @@ -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) diff --git a/scripts b/scripts index 02d90fe979..c760fe161f 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 02d90fe979b3bb6b19ddd1ea7acc2b19ba684ea4 +Subproject commit c760fe161f4a17e989a6e781db0c8e44002f67ee