Skip to content

Commit

Permalink
Limit items shown when setting pocket filters
Browse files Browse the repository at this point in the history
  • Loading branch information
CalKerethi committed Feb 15, 2022
1 parent 973d737 commit 2632090
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/item_contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ bool pocket_favorite_callback::key( const input_context &, const input_event &ev
cata::flat_set<itype_id> nearby_itypes;
selector_menu.title = _( "Select an item from nearby" );
for( const std::list<item> *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<std::pair<itype_id, std::string>> listed_names;
Expand Down Expand Up @@ -182,7 +185,11 @@ bool pocket_favorite_callback::key( const input_context &, const input_event &ev
for( const std::pair<itype_id, std::string> &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();
Expand Down

0 comments on commit 2632090

Please sign in to comment.