void inventory_drop_selector::draw( WINDOW *w ) const { inventory_selector::draw( w ); // Make copy, remove to be dropped items from that // copy and let the copy recalculate the volume capacity // (can be affected by various traits). player tmp = u; remove_dropping_items(tmp); draw_inv_weight_vol( w, tmp.weight_carried(), tmp.volume_carried(), tmp.volume_capacity() ); mvwprintw(w, 1, 0, _("To drop x items, type a number and then the item hotkey.")); }
void inventory_selector::display(bool show_worn) const { const size_t ¤t_page_offset = in_inventory ? current_page_offset_i : current_page_offset_w; werase(w_inv); mvwprintw(w_inv, 0, 0, title.c_str()); if (multidrop) { mvwprintw(w_inv, 1, 0, _("To drop x items, type a number and then the item hotkey.")); } std::string msg_str; nc_color msg_color; if (inCategoryMode) { msg_str = _("Category selection; [TAB] switches mode, arrows select."); msg_color = c_white_red; } else { msg_str = _("Item selection; [TAB] switches mode, arrows select."); msg_color = h_white; } mvwprintz(w_inv, items_per_page + 4, FULL_SCREEN_WIDTH - utf8_width(msg_str), msg_color, msg_str.c_str()); print_left_column(); if(show_worn) { print_middle_column(); } print_right_column(); const size_t max_size = in_inventory ? items.size() : worn.size(); const size_t max_pages = (max_size + items_per_page - 1) / items_per_page; mvwprintw(w_inv, items_per_page + 4, 1, _("Page %d/%d"), current_page_offset / items_per_page + 1, max_pages); if (multidrop) { // Make copy, remove to be dropped items from that // copy and let the copy recalculate the volume capacity // (can be affected by various traits). player tmp = g->u; // first round: remove weapon & worn items, start with larges worn index for( const auto &elem : dropping ) { if( elem.first == -1 && elem.second == -1 ) { tmp.remove_weapon(); } else if( elem.first == -1 && elem.second != -1 ) { tmp.weapon.charges -= elem.second; } else if( elem.first < 0 ) { tmp.i_rem( elem.first ); } } remove_dropping_items(tmp); print_inv_weight_vol(tmp.weight_carried(), tmp.volume_carried(), tmp.volume_capacity()); } else { print_inv_weight_vol(g->u.weight_carried(), g->u.volume_carried(), g->u.volume_capacity()); } if (!multidrop && !compare) { mvwprintw(w_inv, 1, 61, _("Hotkeys: %d/%d "), g->u.allocated_invlets().size(), inv_chars.size()); } wrefresh(w_inv); }
void inventory_selector::display( const std::string &title, selector_mode mode ) const { werase(w_inv); mvwprintw(w_inv, 0, 0, title.c_str()); // Position of inventory columns is adaptive. They're aligned to the left if they occupy less than 2/3 of the screen. // Otherwise they're aligned symmetrically to the center of the screen. static const float min_ratio_to_center = 1.f / 3; const int free_space = getmaxx( w_inv ) - get_columns_width(); const bool center_align = std::abs( float( free_space ) / getmaxx( w_inv ) ) <= min_ratio_to_center; const int max_gap = ( columns.size() > 1 ) ? free_space / ( columns.size() - 1 ) : 0; const int gap = center_align ? max_gap : std::min<int>( max_gap, 4 ); const int gap_rounding_error = ( center_align && columns.size() > 1 ) ? free_space % ( columns.size() - 1 ) : 0; size_t x = 1; size_t y = 2; size_t active_x = 0; for( const auto &column : columns ) { if( &column == &columns.back() ) { x += gap_rounding_error; } if( !is_active_column( *column ) ) { column->draw( w_inv, x, y ); } else { active_x = x; } if( column->pages_count() > 1 ) { mvwprintw( w_inv, getmaxy( w_inv ) - 2, x, _( "Page %d/%d" ), column->page_index() + 1, column->pages_count() ); } x += column->get_width() + gap; } get_active_column().draw( w_inv, active_x, y ); if( mode == SM_PICK ) { mvwprintw(w_inv, 1, 61, _("Hotkeys: %d/%d "), u.allocated_invlets().size(), inv_chars.size()); } if (mode == SM_MULTIDROP) { // Make copy, remove to be dropped items from that // copy and let the copy recalculate the volume capacity // (can be affected by various traits). player tmp = u; // first round: remove weapon & worn items, start with larges worn index for( const auto &elem : dropping ) { if( elem.first == -1 && elem.second == -1 ) { tmp.remove_weapon(); } else if( elem.first == -1 && elem.second != -1 ) { tmp.weapon.charges -= elem.second; } else if( elem.first < 0 ) { tmp.i_rem( elem.first ); } } remove_dropping_items(tmp); print_inv_weight_vol(tmp.weight_carried(), tmp.volume_carried(), tmp.volume_capacity()); mvwprintw(w_inv, 1, 0, _("To drop x items, type a number and then the item hotkey.")); } else { print_inv_weight_vol(u.weight_carried(), u.volume_carried(), u.volume_capacity()); } if( empty() ) { center_print( w_inv, getmaxy( w_inv ) / 2, c_dkgray, _( "Your inventory is empty." ) ); } const std::string msg_str = ( navigation == navigation_mode::CATEGORY ) ? _( "Category selection; [TAB] switches mode, arrows select." ) : _( "Item selection; [TAB] switches mode, arrows select." ); const nc_color msg_color = ( navigation == navigation_mode::CATEGORY ) ? h_white : c_ltgray; if( center_align ) { center_print( w_inv, getmaxy( w_inv ) - 1, msg_color, msg_str.c_str() ); } else { trim_and_print( w_inv, getmaxy( w_inv ) - 1, 1, getmaxx( w_inv ), msg_color, msg_str.c_str() ); } wrefresh(w_inv); }