From 2a86d7d4841feef4dd99db5dadcb818f53ab5ca4 Mon Sep 17 00:00:00 2001 From: 8street Date: Fri, 3 Jan 2020 10:47:22 +0300 Subject: [PATCH 1/5] Editing game.cpp --- src/game.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index a3e546ebfc4e6..aacbccf504fc2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7067,7 +7067,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 ); // - @@ -7184,8 +7184,21 @@ 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 = 44; + int width = 44; + + //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; + } + } + if( width > TERMX ) { + width = TERMX; + } + const int offsetX = TERMX - VIEW_OFFSET_X - width; catacurses::window w_items = catacurses::newwin( TERMY - 2 - iInfoHeight - VIEW_OFFSET_Y * 2, @@ -7213,7 +7226,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; From 20872b3add1c5429b0b108baef5f7acc2449226f Mon Sep 17 00:00:00 2001 From: 8street Date: Fri, 3 Jan 2020 11:26:20 +0300 Subject: [PATCH 2/5] Some check change. --- src/game.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index aacbccf504fc2..e26051aba7951 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7195,8 +7195,8 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) width = item_len; } } - if( width > TERMX ) { - width = TERMX; + if( width > TERMX - VIEW_OFFSET_X ) { + width = TERMX - VIEW_OFFSET_X; } const int offsetX = TERMX - VIEW_OFFSET_X - width; From 2131ac6b159eb12416256b6205db75dadb9e20b6 Mon Sep 17 00:00:00 2001 From: 8street Date: Sat, 4 Jan 2020 10:12:06 +0300 Subject: [PATCH 3/5] Clamp the width. --- src/game.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index e26051aba7951..f10af2bc0aed5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7189,15 +7189,13 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) int width = 44; //find max length of item name and resize window width - for( const map_item_stack cur_item : ground_items ) { + 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; } } - if( width > TERMX - VIEW_OFFSET_X ) { - width = TERMX - VIEW_OFFSET_X; - } + width = clamp( width, 44, ( TERMX - VIEW_OFFSET_X ) / 3 ); const int offsetX = TERMX - VIEW_OFFSET_X - width; From e502f81e045db15d6fc03df4a389d7b06d2877db Mon Sep 17 00:00:00 2001 From: 8street Date: Wed, 8 Jan 2020 17:24:21 +0300 Subject: [PATCH 4/5] Resolving conflicts --- src/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.cpp b/src/game.cpp index a74e16ae27770..3f128fe13359f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7191,7 +7191,7 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) width = item_len; } } - width = clamp( width, 44, ( TERMX - VIEW_OFFSET_X ) / 3 ); + width = clamp( width, 45, ( TERMX - VIEW_OFFSET_X ) / 3 ); const int offsetX = TERMX - VIEW_OFFSET_X - width; From 3e361caf7429ff81d4ec172f5feb3101da638a34 Mon Sep 17 00:00:00 2001 From: 8street Date: Wed, 8 Jan 2020 17:25:48 +0300 Subject: [PATCH 5/5] Astyle --- src/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.cpp b/src/game.cpp index 3f128fe13359f..5fd0d1e0d1432 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7192,7 +7192,7 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) } } 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,