本文整理汇总了C++中itemstack_vector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ itemstack_vector::size方法的具体用法?C++ itemstack_vector::size怎么用?C++ itemstack_vector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类itemstack_vector
的用法示例。
在下文中一共展示了itemstack_vector::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
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);
}
示例2: get_selected_item_position
int inventory_selector::get_selected_item_position() const
{
const itemstack_vector &items = in_inventory ? this->items : this->worn;
const size_t &selected = in_inventory ? selected_i : selected_w;
if (selected < items.size() && items[selected].it != NULL) {
return items[selected].item_pos;
}
return INT_MIN;
}
示例3: prepare_paging
void inventory_selector::prepare_paging()
{
if (items.size() == 0) {
in_inventory = false;
}
prepare_paging(items);
prepare_paging(worn);
}
示例4: set_selected_to_drop
void inventory_selector::set_selected_to_drop(int count)
{
const itemstack_vector &items = in_inventory ? this->items : this->worn;
const size_t &selected = in_inventory ? selected_i: selected_w;
if (selected >= items.size()) {
return;
}
const itemstack_or_category &cur_entry = items[selected];
if (cur_entry.it != NULL && cur_entry.slice != NULL) {
set_drop_count(cur_entry.item_pos, count, *cur_entry.slice);
} else if (cur_entry.it != NULL) {
set_drop_count(cur_entry.item_pos, count, *cur_entry.it);
}
}
示例5: print_column
void inventory_selector::print_column(const itemstack_vector &items, size_t y, size_t w,
size_t selected, size_t current_page_offset) const
{
nc_color selected_line_color = inCategoryMode ? c_white_red : h_white;
if ((&items == &this->items) != in_inventory) {
selected_line_color = inCategoryMode ? c_ltgray_red : h_ltgray;
}
int cur_line = 2;
for (size_t a = 0; a + current_page_offset < items.size() && a < items_per_page; a++, cur_line++) {
const itemstack_or_category &cur_entry = items[a + current_page_offset];
if (cur_entry.category == NULL) {
continue;
}
if (cur_entry.it == NULL) {
const std::string name = trim_to(cur_entry.category->name, w);
mvwprintz(w_inv, cur_line, y, c_magenta, "%s", name.c_str());
continue;
}
const item &it = *cur_entry.it;
std::string item_name = it.display_name();
if (cur_entry.slice != NULL) {
const size_t count = cur_entry.slice->size();
if (count > 1) {
item_name = string_format("%d %s", count, it.display_name(count).c_str());
}
}
nc_color name_color = it.color_in_inventory();
nc_color invlet_color = c_white;
if (g->u.assigned_invlet.count(it.invlet)) {
invlet_color = c_yellow;
}
if (a + current_page_offset == selected) {
name_color = selected_line_color;
invlet_color = selected_line_color;
}
item_name = get_drop_icon(dropping.find(cur_entry.item_pos)) + item_name;
if (it.invlet != 0) {
mvwputch(w_inv, cur_line, y, invlet_color, it.invlet);
}
if (OPTIONS["ITEM_SYMBOLS"]) {
item_name = string_format("%c %s", it.symbol(), item_name.c_str());
}
trim_and_print(w_inv, cur_line, y + 2, w - 2, name_color, "%s", item_name.c_str());
}
}
示例6: handle_movement
bool inventory_selector::handle_movement(const std::string &action)
{
const itemstack_vector &items = in_inventory ? this->items : this->worn;
size_t &selected = in_inventory ? selected_i : selected_w;
size_t ¤t_page_offset = in_inventory ? current_page_offset_i : current_page_offset_w;
const item_category *cur_cat = (selected < items.size()) ? items[selected].category : NULL;
if (action == "CATEGORY_SELECTION") {
inCategoryMode = !inCategoryMode;
} else if (action == "LEFT") {
if (this->items.size() > 0) {
in_inventory = !in_inventory;
}
} else if (action == "DOWN") {
selected++;
if (inCategoryMode) {
while (selected < items.size() && items[selected].category == cur_cat) {
selected++;
}
}
// skip non-item entries, those can not be selected!
while (selected < items.size() && items[selected].it == NULL) {
selected++;
}
if (selected >= items.size()) { // wrap around
selected = 1; // first is the category!
}
current_page_offset = selected - (selected % items_per_page);
} else if (action == "UP") {
selected--;
if (inCategoryMode && selected == 0) {
selected = items.size() - 1;
}
if (inCategoryMode) {
while (selected < items.size() && items[selected].category == cur_cat) {
selected--;
}
}
// skip non-item entries, those can not be selected!
while (selected < items.size() && items[selected].it == NULL) {
selected--;
}
if (selected >= items.size()) { // wrap around, actually overflow
selected = items.size() - 1; // the last is always an item entry
}
current_page_offset = selected - (selected % items_per_page);
} else if (action == "NEXT_TAB") {
selected += items_per_page;
// skip non-item entries, those can not be selected!
while (selected < items.size() && items[selected].it == NULL) {
selected++;
}
if (selected >= items.size()) { // wrap around
selected = 1; // first is the category!
}
current_page_offset = selected - (selected % items_per_page);
} else if (action == "PREV_TAB") {
selected -= items_per_page;
// skip non-item entries, those can not be selected!
while (selected < items.size() && items[selected].it == NULL) {
selected--;
}
if (selected >= items.size()) { // wrap around, actually overflow
selected = items.size() - 1; // the last is always an item entry
}
current_page_offset = selected - (selected % items_per_page);
} else {
return false;
}
return true;
}