static void draw_player_weapon_actionbar(GameState* gs, PlayerInst* player, int x, int y) { int mx = gs->mouse_x(), my = gs->mouse_y(); Weapon weapon = player->weapon(); bool weapon_selected = player->spell_selected() == -1; Colour outline_col = weapon_selected ? COL_SELECTED_OUTLINE : COL_FILLED_OUTLINE; /* Draw only enough space for weapon if no projectile used */ bool draw_with_projectile = !player->projectile().empty(); BBox weaponbox(x + 1, y, x + 1 + TILE_SIZE, y + TILE_SIZE); BBox equipbox(weaponbox); if (draw_with_projectile) { equipbox.x2 += TILE_SIZE; } if (equipbox.contains(mx, my) && !weapon_selected) { outline_col = COL_PALE_YELLOW; } if (weaponbox.contains(mx, my)) { draw_console_item_description(gs, weapon, weapon.weapon_entry()); } /* Draw weapon*/ WeaponEntry& wentry = weapon.weapon_entry(); res::sprite(wentry.item_sprite).draw(Pos(x,y)); if (draw_with_projectile) { BBox projectilebox(weaponbox.translated(TILE_SIZE, 0)); Projectile projectile = player->projectile(); if (projectilebox.contains(mx, my)) { draw_console_item_description(gs, projectile, projectile.projectile_entry()); } ProjectileEntry& ptype = projectile.projectile_entry(); res::sprite(ptype.item_sprite).draw(Pos(x + TILE_SIZE, y)); /* Draw projectile amount */ gs->font().drawf(Colour(255, 255, 255), Pos(x + TILE_SIZE + 1, y + 1), "%d", player->projectile().amount); } ldraw::draw_rectangle_outline(outline_col, equipbox); }
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); } }