From 2632090e5960f47fcd63ed42ff079f7b04f38d68 Mon Sep 17 00:00:00 2001 From: CalKerethi Date: Sat, 12 Feb 2022 14:16:06 -0500 Subject: [PATCH] Limit items shown when setting pocket filters --- src/item_contents.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/item_contents.cpp b/src/item_contents.cpp index 7a5c4a97d2edb..316b0af849c9f 100644 --- a/src/item_contents.cpp +++ b/src/item_contents.cpp @@ -154,7 +154,10 @@ bool pocket_favorite_callback::key( const input_context &, const input_event &ev cata::flat_set nearby_itypes; selector_menu.title = _( "Select an item from nearby" ); for( const std::list *it_list : get_player_character().crafting_inventory().const_slice() ) { - nearby_itypes.insert( it_list->front().typeId() ); + item it = it_list->front(); + if( !it.is_null() && selected_pocket->is_compatible( it ).success() ) { + nearby_itypes.insert( it.typeId() ); + } } std::vector> listed_names; @@ -182,7 +185,11 @@ bool pocket_favorite_callback::key( const input_context &, const input_event &ev for( const std::pair &it : nearby_names ) { selector_menu.addentry( add_prefix + it.second ); } - selector_menu.query(); + if( selector_menu.entries.empty() ) { + popup( std::string( _( "No nearby items would fit here." ) ), PF_GET_KEY ); + } else { + selector_menu.query(); + } const int selected = selector_menu.ret; itype_id selected_id = itype_id::NULL_ID();