static void draw_spells_known(GameState* gs, const BBox& bbox, SpellsKnown& spells, int ind_low, int ind_high) { const int spell_n = spells.amount(); int mx = gs->mouse_x(), my = gs->mouse_y(); int spellidx = ind_low; int selected_spell = gs->local_player()->spell_selected(); gl_draw_rectangle_outline(bbox, COL_UNFILLED_OUTLINE); int x = bbox.x1, ex = bbox.x2; for (int y = bbox.y1; y < bbox.y2; y += TILE_SIZE) { if (spellidx >= spell_n) break; spell_id spell = spells.get(spellidx); SpellEntry& spl_entry = game_spell_data.at(spell); draw_spell_icon_and_name(gs, spl_entry, Colour(), x, y); BBox entry_box(x, y, ex, y + TILE_SIZE); Colour bbox_col = COL_FILLED_OUTLINE; if (spellidx == selected_spell) { bbox_col = COL_WHITE; } if (entry_box.contains(mx, my)) { bbox_col = COL_GOLD; draw_console_spell_description(gs, spl_entry); } gl_draw_rectangle_outline(entry_box, bbox_col); spellidx++; } }
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); } }
void ConfigContent::draw(GameState* gs) const { GameSettings& settings = gs->game_settings(); gl_draw_rectangle_outline(bbox, COL_UNFILLED_OUTLINE); BBox entry_box(bbox.x1, bbox.y1, bbox.x2, bbox.y1 + TILE_SIZE); draw_option(gs, entry_box, settings.autouse_mana_potions, get_sprite_by_name("mana_potion"), "Auto-Use Mana Potions"); entry_box = entry_box.translated(0, TILE_SIZE); draw_option(gs, entry_box, settings.autouse_health_potions, get_sprite_by_name("health_potion"), "Auto-Use Health Potions"); }
static void draw_option(GameState* gs, const BBox& bbox, bool option_set, sprite_id sprite, const char* text) { Colour bbox_col = option_set ? COL_WHITE : COL_FILLED_OUTLINE; if (bbox.contains(gs->mouse_pos())) { bbox_col = COL_GOLD; } gl_draw_sprite(sprite, bbox.x1, bbox.y1, COL_WHITE.with_alpha(option_set ? 255 : 100)); /* Draw item name */ gl_printf_bounded(gs->primary_font(), option_set ? COL_WHITE : COL_MID_GRAY, bbox.x1 + TILE_SIZE * 1.25, bbox.y1 + TILE_SIZE / 2, bbox.width() - TILE_SIZE, true, "%s", text); gl_draw_rectangle_outline(bbox, bbox_col); }