void Hud::drawHotbar(u16 playeritem) { v2s32 centerlowerpos(m_displaycenter.X, m_screensize.Y); InventoryList *mainlist = inventory->getList("main"); if (mainlist == NULL) { //silently ignore this we may not be initialized completely return; } s32 hotbar_itemcount = player->hud_hotbar_itemcount; s32 width = hotbar_itemcount * (m_hotbar_imagesize + m_padding * 2); v2s32 pos = centerlowerpos - v2s32(width / 2, m_hotbar_imagesize + m_padding * 3); if ( (float) width / (float) porting::getWindowSize().X <= g_settings->getFloat("hud_hotbar_max_width")) { if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) { drawItems(pos, hotbar_itemcount, 0, mainlist, playeritem + 1, 0); } } else { pos.X += width/4; v2s32 secondpos = pos; pos = pos - v2s32(0, m_hotbar_imagesize + m_padding * 2); if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) { drawItems(pos, hotbar_itemcount/2, 0, mainlist, playeritem + 1, 0); drawItems(secondpos, hotbar_itemcount, hotbar_itemcount/2, mainlist, playeritem + 1, 0); } } }
void Hud::drawHotbar(u16 playeritem) { v2s32 centerlowerpos(m_displaycenter.X, m_screensize.Y); InventoryList *mainlist = inventory->getList("main"); if (mainlist == NULL) { //silently ignore this we may not be initialized completely return; } s32 hotbar_itemcount = player->hud_hotbar_itemcount; s32 width = hotbar_itemcount * (m_hotbar_imagesize + m_padding * 2); v2s32 pos = centerlowerpos - v2s32(width / 2, m_hotbar_imagesize + m_padding * 3); if ( (float) width / (float) porting::getWindowSize().X <= g_settings->getFloat("hud_hotbar_max_width")) { if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) { drawItems(pos, hotbar_itemcount, 0, mainlist, playeritem + 1, 0); } } else { pos.X += width/4; v2s32 secondpos = pos; pos = pos - v2s32(0, m_hotbar_imagesize + m_padding); if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) { drawItems(pos, hotbar_itemcount/2, 0, mainlist, playeritem + 1, 0); drawItems(secondpos, hotbar_itemcount, hotbar_itemcount/2, mainlist, playeritem + 1, 0); } } //////////////////////////// compatibility code to be removed ////////////// // this is ugly as hell but there's no other way to keep compatibility to // old servers if ( player->hud_flags & HUD_FLAG_HEALTHBAR_VISIBLE) drawStatbar(v2s32(floor(0.5 * (float) m_screensize.X + 0.5), floor(1 * (float) m_screensize.Y + 0.5)), HUD_CORNER_UPPER, 0, "heart.png", player->hp, v2s32((-10*24)-25,-(48+24+10)), v2s32(24,24)); if ((player->hud_flags & HUD_FLAG_BREATHBAR_VISIBLE) && (player->getBreath() < 11)) drawStatbar(v2s32(floor(0.5 * (float) m_screensize.X + 0.5), floor(1 * (float) m_screensize.Y + 0.5)), HUD_CORNER_UPPER, 0, "heart.png", player->getBreath(), v2s32(25,-(48+24+10)), v2s32(24,24)); //////////////////////////////////////////////////////////////////////////// }