本文整理汇总了C++中Inventory::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::get方法的具体用法?C++ Inventory::get怎么用?C++ Inventory::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_player_inventory
static void draw_player_inventory(GameState* gs, Inventory& inv,
const BBox& bbox, int min_slot, int max_slot, int slot_selected = -1) {
int mx = gs->mouse_x(), my = gs->mouse_y();
int slot = min_slot;
for (int y = bbox.y1; y < bbox.y2; y += TILE_SIZE) {
for (int x = bbox.x1; x < bbox.x2; x += TILE_SIZE) {
if (slot >= max_slot)
break;
ItemSlot& itemslot = inv.get(slot);
BBox slotbox(x, y, x + TILE_SIZE, y + TILE_SIZE);
Colour outline(COL_UNFILLED_OUTLINE);
if (itemslot.amount > 0 && slot != slot_selected) {
outline = COL_FILLED_OUTLINE;
if (slotbox.contains(mx, my)) {
outline = COL_PALE_YELLOW;
draw_console_item_description(gs, itemslot.item);
}
}
if (slot != slot_selected)
draw_player_inventory_slot(gs, itemslot, x, y);
//draw rectangle over item edges
gl_draw_rectangle_outline(slotbox, outline);
slot++;
}
}
if (slot_selected != -1) {
draw_player_inventory_slot(gs, inv.get(slot_selected),
gs->mouse_x() - TILE_SIZE / 2, gs->mouse_y() - TILE_SIZE / 2);
}
}
示例2: setItem
//----------------------------------------- setItem()
void Borrow::setItem(istream& in, Inventory& inv, MovieFactory& mf) {
// assume that items can only be movies
string mediaCode = "Z"; string movieCode = "Z";
in >> mediaCode >> movieCode;
Item* target = mf.createItem(movieCode);
item = NULL;
if(target != NULL && mediaCode.c_str()[0] == 'D') {
target->parseTransactionData(in);
Item* movieInStore = NULL;
movieInStore = inv.get(target); // modify movieInStore
if(movieInStore != NULL) {
item = movieInStore;
} else {item = NULL;}
delete target;
} else {
in.ignore(256, '\n'); // consume the rest of the bad data
}
}