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 pickup window #36492

Merged
merged 12 commits into from
Dec 31, 2019
9 changes: 9 additions & 0 deletions src/pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,15 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from )
int pickupH = maxitems + pickupBorderRows;
int pickupW = 44;

//find max length of item name and resize pickup window width
for( size_t cur_it = 0; cur_it < stacked_here.size(); cur_it++ ) {
const item &this_item = *stacked_here[cur_it].front();
Copy link
Contributor

@Qrox Qrox Dec 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cur_it in your code is only used to access the elements of stacked_here, so it can be simplified to a range-based for loop. You only need to change

        for( size_t cur_it = 0; cur_it < stacked_here.size(); cur_it++ ) {
            const item &this_item = *stacked_here[cur_it].front();

to

        for( const std::list<item_stack::iterator> &cur_list : stacked_here ) {
            const item &this_item = *cur_list.front();

int item_len = utf8_width( remove_color_tags( this_item.display_name() ) ) + 10;
if( item_len > pickupW && item_len < TERMX ) {
pickupW = item_len;
}
}

int itemsW = pickupW;

int pickupX = 0;
Expand Down