void inventory_selector::print_right_column() const { if (right_column_width == 0) { return; } player &u = g->u; int drp_line = 1; drop_map::const_iterator dit = dropping.find(-1); if (dit != dropping.end()) { std::string item_name = u.weapname(); if (dit->second == -1) { item_name.insert(0, "+ "); } else { item_name = string_format("# %s {%d}", item_name.c_str(), dit->second); } const char invlet = invlet_or_space(u.weapon); item_name = trim_to(item_name, right_column_width - 2); // 2 for the invlet & space mvwprintz(w_inv, drp_line, right_column_offset, c_ltblue, "%c %s", invlet, item_name.c_str()); drp_line++; } for (size_t k = 0; k < u.worn.size(); k++) { // worn items can not be dropped partially if (dropping.count(player::worn_position_to_index(k)) == 0) { continue; } const char invlet = invlet_or_space(u.worn[k]); std::string item_name = trim_to(u.worn[k].display_name(), right_column_width - 4); // 2 for the invlet '+' & 2 space mvwprintz(w_inv, drp_line, right_column_offset, c_cyan, "%c + %s", invlet, item_name.c_str()); drp_line++; } for (drop_map::const_iterator a = dropping.begin(); a != dropping.end(); ++a) { if (a->first < 0) { // worn or wielded item, already displayed above continue; } const std::list<item> &stack = u.inv.const_stack(a->first); const item &it = stack.front(); const char invlet = invlet_or_space(it); const int count = a->second; const int display_count = (count == -1) ? (it.charges >= 0) ? it.charges : stack.size() : count; const nc_color col = it.color_in_inventory(); std::string item_name = it.tname( display_count ); if (count == -1) { if (stack.size() > 1) { item_name = string_format("%d %s", stack.size(), item_name.c_str()); } else { item_name.insert(0, "+ "); } } else { item_name = string_format("# %s {%d}", item_name.c_str(), count); } item_name = trim_to(item_name, right_column_width - 2); // 2 for the invlet & space mvwprintz(w_inv, drp_line, right_column_offset, col, "%c %s", invlet, item_name.c_str()); drp_line++; } }
void inventory_selector::display() 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; Press [TAB] to switch the mode."); msg_color = c_white_red; } else { msg_str = _("Item selection; Press [TAB] to switch the mode."); msg_color = h_white; } mvwprintz(w_inv, items_per_page + 4, FULL_SCREEN_WIDTH - utf8_width(msg_str.c_str()), msg_color, msg_str.c_str()); print_left_column(); 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 (drop_map::const_iterator a = dropping.begin(); a != dropping.end(); ++a) { if (a->first == -1 && a->second == -1) { tmp.remove_weapon(); } else if (a->first == -1 && a->second != -1) { tmp.weapon.charges -= a->second; } else if (a->first < 0) { tmp.worn.erase(tmp.worn.begin() + player::worn_position_to_index(a->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); }