diff --git a/src/game.cpp b/src/game.cpp index bffd0f45d37c7..5fd0d1e0d1432 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7066,7 +7066,7 @@ bool game::take_screenshot( const std::string &path ) const //helper method so we can keep list_items shorter void game::reset_item_list_state( const catacurses::window &window, int height, bool bRadiusSort ) { - const int width = 44; + const int width = getmaxx( window ); for( int i = 1; i < TERMX; i++ ) { if( i < width ) { mvwputch( window, point( i, 0 ), c_light_gray, LINE_OXOX ); // - @@ -7180,8 +7180,19 @@ void game::list_items_monsters() game::vmenu_ret game::list_items( const std::vector &item_list ) { + std::vector ground_items = item_list; int iInfoHeight = std::min( 25, TERMY / 2 ); - const int width = 45; + int width = 45; + + //find max length of item name and resize window width + for( const map_item_stack &cur_item : ground_items ) { + const int item_len = utf8_width( remove_color_tags( cur_item.example->display_name() ) ) + 15; + if( item_len > width ) { + width = item_len; + } + } + width = clamp( width, 45, ( TERMX - VIEW_OFFSET_X ) / 3 ); + const int offsetX = TERMX - VIEW_OFFSET_X - width; catacurses::window w_items = catacurses::newwin( TERMY - 2 - iInfoHeight - VIEW_OFFSET_Y * 2, @@ -7209,7 +7220,6 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) uistate.list_item_init = true; } - std::vector ground_items = item_list; //this stores only those items that match our filter std::vector filtered_items = !sFilter.empty() ? filter_item_stacks( ground_items, sFilter ) : ground_items;