• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ itemstack_vector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中itemstack_vector的典型用法代码示例。如果您正苦于以下问题:C++ itemstack_vector类的具体用法?C++ itemstack_vector怎么用?C++ itemstack_vector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了itemstack_vector类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: item_entry

void inventory_selector::make_item_list(const indexed_invslice &slice, const item_category *def_cat)
{
    for( const auto &scit : slice ) {

        // That entry represents the item stack
        const itemstack_or_category item_entry(scit);
        const item_category *category = def_cat;
        if (category == NULL) {
            category = item_entry.category;
        }
        // Entry that represents the category header
        const itemstack_or_category cat_entry(category);
        itemstack_vector::iterator cat_iter = std::find(items.begin(), items.end(), cat_entry);
        if (cat_iter == items.end()) {
            // Category is not yet contained in the list, add it to the end
            items.push_back(cat_entry);
            cat_iter = items.end();
        } else {
            // Category is already contained, skip all the items that belong to the
            // category to insert the current item behind them (but before the next category)
            do {
                ++cat_iter;
            } while(cat_iter != items.end() && cat_iter->it != NULL);
        }
        items.insert(cat_iter, item_entry);
    }
}
开发者ID:ValidAQ,项目名称:Cataclysm-DDA,代码行数:27,代码来源:inventory_ui.cpp


示例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;
}
开发者ID:golgepapaz,项目名称:Cataclysm-DDA,代码行数:9,代码来源:inventory_ui.cpp


示例3: 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);
    }
}
开发者ID:UristMcCoder,项目名称:Cataclysm-DDA,代码行数:14,代码来源:inventory_ui.cpp


示例4: 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());
    }
}
开发者ID:golgepapaz,项目名称:Cataclysm-DDA,代码行数:45,代码来源:inventory_ui.cpp


示例5: 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 &current_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;
}
开发者ID:golgepapaz,项目名称:Cataclysm-DDA,代码行数:71,代码来源:inventory_ui.cpp


示例6: prepare_paging

void inventory_selector::prepare_paging()
{
    if (items.size() == 0) {
        in_inventory = false;
    }

    prepare_paging(items);
    prepare_paging(worn);
}
开发者ID:golgepapaz,项目名称:Cataclysm-DDA,代码行数:9,代码来源:inventory_ui.cpp



注:本文中的itemstack_vector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ iter类代码示例发布时间:2022-05-31
下一篇:
C++ item_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap