Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended shift-v items menu #36663

Merged
merged 15 commits into from
Apr 2, 2020
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); // -
Expand Down Expand Up @@ -7184,8 +7184,21 @@ 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 = 44;
int width = 44;

//find max length of item name and resize window width
for( const map_item_stack cur_item : ground_items ) {
8street marked this conversation as resolved.
Show resolved Hide resolved
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;
}

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 @@ -7213,7 +7226,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