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

Colored selected item and extended win for long items name #36102

Closed
wants to merge 5 commits into from
Closed
Changes from all 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
36 changes: 35 additions & 1 deletion src/pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,15 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from )
mvwprintw( w_pickup, point_zero, _( "PICK" ) );
int selected = 0;
int iScrollPos = 0;
int selected_item_length = 0;
static int prev_selected_item_length = 0;
static int previous_selected = 0;

std::string filter;
std::string new_filter;
std::string selected_item_text;

nc_color selected_item_color;
// Indexes of items that match the filter
std::vector<int> matches;
bool filter_changed = true;
Expand Down Expand Up @@ -822,7 +828,7 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from )
const item &this_item = *stacked_here[true_it].front();
nc_color icolor = this_item.color_in_inventory();
if( cur_it == selected ) {
icolor = hilite( c_white );
icolor = hilite( icolor );
}

if( cur_it < static_cast<int>( pickup_chars.size() ) ) {
Expand Down Expand Up @@ -907,9 +913,35 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from )
}
trim_and_print( w_pickup, point( 6, 1 + ( cur_it % maxitems ) ), pickupW - 4, icolor,
item_name );

if( cur_it == selected ) {
selected_item_text = item_name;
selected_item_color = icolor;
selected_item_length = utf8_width( remove_color_tags( item_name ) );
}
}
}

int win_overlength = prev_selected_item_length - pickupW + 6;

//fill black color previous overlenght text
if( win_overlength > 0 ) {
catacurses::window w_dummy = catacurses::newwin( 1, win_overlength, point( pickupW,
1 + previous_selected ) );
trim_and_print( w_dummy, point( pickupW, selected ), win_overlength, c_black, " " );
wrefresh( w_dummy );
w_dummy = catacurses::window();
}

previous_selected = selected;
prev_selected_item_length = selected_item_length;

//extended windows for selected item
catacurses::window w_selected_item = catacurses::newwin( 1, selected_item_length, point( 6,
1 + selected ) );
trim_and_print( w_selected_item, point( 6, 1 + selected ), selected_item_length,
selected_item_color, selected_item_text );

mvwprintw( w_pickup, point( 0, maxitems + 1 ), _( "[%s] Unmark" ),
ctxt.get_desc( "LEFT", 1 ) );

Expand Down Expand Up @@ -966,6 +998,8 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from )
}

wrefresh( w_pickup );
wrefresh( w_selected_item );
w_selected_item = catacurses::window();

action = ctxt.handle_input();
raw_input_char = ctxt.get_raw_input().get_first_input();
Expand Down