From db5ba7146328e15ad6a5600305090e24ac39db3f Mon Sep 17 00:00:00 2001 From: 8street Date: Fri, 3 Apr 2020 00:20:15 +0300 Subject: [PATCH] Extended shift-v items menu (#36663) --- src/game.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 174e3fe90296d..d51dd8133ff3e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7021,7 +7021,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 ); // - @@ -7135,8 +7135,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, @@ -7164,7 +7175,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;