Skip to content

Commit

Permalink
Extended shift-v items menu (#36663)
Browse files Browse the repository at this point in the history
  • Loading branch information
8street committed Apr 2, 2020
1 parent abb41f8 commit db5ba71
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); // -
Expand Down Expand Up @@ -7135,8 +7135,19 @@ void game::list_items_monsters()

game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
{
std::vector<map_item_stack> 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,
Expand Down Expand Up @@ -7164,7 +7175,6 @@ game::vmenu_ret game::list_items( const std::vector<map_item_stack> &item_list )
uistate.list_item_init = true;
}

std::vector<map_item_stack> ground_items = item_list;
//this stores only those items that match our filter
std::vector<map_item_stack> filtered_items =
!sFilter.empty() ? filter_item_stacks( ground_items, sFilter ) : ground_items;
Expand Down

0 comments on commit db5ba71

Please sign in to comment.