Skip to content

Commit

Permalink
Merge pull request #1219 from myk002/myk_pedestal
Browse files Browse the repository at this point in the history
[caravan/pedestal] remember filter settings between invocations
  • Loading branch information
myk002 authored Jul 1, 2024
2 parents bea808e + f7886a5 commit 424659c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 29 additions & 8 deletions internal/caravan/pedestal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ 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,
inside_containers=true,
}

-- -------------------
-- AssignItems
--
Expand Down Expand Up @@ -214,8 +223,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
Expand All @@ -238,8 +248,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
Expand Down Expand Up @@ -269,8 +280,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',
Expand All @@ -281,8 +295,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,
},
},
},
Expand Down Expand Up @@ -366,8 +384,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.inside_containers,
on_change=function(val)
filters.inside_containers = val
self:refresh_list()
end,
},
widgets.WrappedLabel{
frame={b=0, l=0, r=0},
Expand Down

0 comments on commit 424659c

Please sign in to comment.