Esempio n. 1
0
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);
	}
}
Esempio n. 2
0
//----------------------------------------- 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
	}
}