From 139a84e2b2ce61ba4ebf25ad7fec12a0483a1b35 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 9 Jun 2024 23:18:00 -0700 Subject: [PATCH] remember filter settings between invocations --- changelog.txt | 1 + internal/caravan/pedestal.lua | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index 79267f73cd..cb3152d5ff 100644 --- a/changelog.txt +++ b/changelog.txt @@ -73,6 +73,7 @@ Template for new versions: - `caravan`: bring goods to depot screen now shows (approximate) distance from item to depot - `gui/design`: circles are more circular (now matches more pleasing shape generated by ``digcircle``) - `gui/quickfort`: you can now delete your blueprints from the blueprint load dialog +- `caravan`: remember filter settings for pedestal item assignment dialog - `quickfort`: new ``delete`` command for deleting player-owned blueprints (library and mod-added blueprints cannot be deleted) - `quickfort`: support enabling `logistics` features for autoforbid and autoclaim on stockpiles - `gui/quickfort`: allow farm plots, dirt roads, and paved roads to be designated around partial obstructions without callling it an error, matching vanilla behavior diff --git a/internal/caravan/pedestal.lua b/internal/caravan/pedestal.lua index faed8929f2..3246954a08 100644 --- a/internal/caravan/pedestal.lua +++ b/internal/caravan/pedestal.lua @@ -19,6 +19,14 @@ for k, v in pairs(STATUS) do STATUS_REVMAP[v.value] = k end +-- save filters (sans search string) between dialog invocations +local filters = { + min_quality=0, + max_quality=6, + hide_unreachable=true, + hide_forbidden=false, +} + -- ------------------- -- AssignItems -- @@ -214,8 +222,9 @@ function AssignItems:init() {label=common.CH_MONEY..'Masterful'..common.CH_MONEY, value=5}, {label='Artifact', value=6}, }, - initial_option=0, + initial_option=filters.min_quality, on_change=function(val) + filters.min_quality = val if self.subviews.max_quality:getOptionValue() < val then self.subviews.max_quality:setOption(val) end @@ -238,8 +247,9 @@ function AssignItems:init() {label=common.CH_MONEY..'Masterful'..common.CH_MONEY, value=5}, {label='Artifact', value=6}, }, - initial_option=6, + initial_option=filters.max_quality, on_change=function(val) + filters.max_quality = val if self.subviews.min_quality:getOptionValue() > val then self.subviews.min_quality:setOption(val) end @@ -269,8 +279,11 @@ function AssignItems:init() {label='Yes', value=true, pen=COLOR_GREEN}, {label='No', value=false} }, - initial_option=true, - on_change=function() self:refresh_list() end, + initial_option=filters.hide_unreachable, + on_change=function(val) + filters.hide_unreachable = val + self:refresh_list() + end, }, widgets.ToggleHotkeyLabel{ view_id='hide_forbidden', @@ -281,8 +294,12 @@ function AssignItems:init() {label='Yes', value=true, pen=COLOR_GREEN}, {label='No', value=false} }, - initial_option=false, - on_change=function() self:refresh_list() end, + option_gap=3, + initial_option=filters.hide_forbidden, + on_change=function(val) + filters.hide_forbidden = val + self:refresh_list() + end, }, }, },