Enable category toggle in pickup selectors #58917
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Interface "Enable category toggling in pickup selectors"
Purpose of change
This change allows toggling between category view and hierarchy view in pickup menus.
Describe the solution
toggle_categorize_contained()
now categorizes or uncategorizes all column entries by either adding or removing their custom category. To preserve invlets between the map and selection columns,prepare_layout()
is called directly and the ui is invalidated, but not marked for resize, so that a redraw will occur but invlets will not be reassigned (mark_resize()
would end up callingprepare_layout()
in the resize callback, which would callreassign_custom_invlets()
and that would remove the selection columns invlets). All selected entries will then be re-toggled with their new invlets after paging.Describe alternatives you've considered
Somehow getting selection column entries to link to the other columns and then special-casing the selection column in layout code to avoid invlets being clobbered. This felt like a more extensive change which would require rewriting many things.
Testing
Tested with an inventory full of items, some containers, and gear ensuring that categories toggled properly and columns were in sync. Also tested other selection menus (multidrop and inventory) to ensure nothing broke.
Additional context
Thanks to @andrei8l for the code to get this started!
Demo:
pickup_toggle.mp4