//-------------------------------------------------------------------------------------------- int ui_drawBar( ui_id_t id, float vx, float vy, int current, int max, Uint8 bar_type ) { float x1, y1; // convert the virtual coordinates to screen coordinates ui_virtual_to_screen( vx, vy, &x1, &y1 ); //Draw the bar y1 = draw_one_bar( bar_type, x1, y1, current, max ); ui_virtual_to_screen( vx, y1, &x1, &y1 ); return y1; }
void CharacterStatus::draw() { //If object we are monitoring no longer exist, then destroy this GUI component const std::shared_ptr<Object> pchr = _object.lock(); if(!pchr) { destroy(); return; } int life_pips = pchr->getLife(); int life_pips_max = pchr->getAttribute(Ego::Attribute::MAX_LIFE); int mana_pips = pchr->getMana(); int mana_pips_max = pchr->getAttribute(Ego::Attribute::MAX_MANA); int yOffset = getY(); // draw the name yOffset = draw_string_raw(getX() + 8, yOffset, "%s", pchr->getName(false, false, true).c_str()); // draw the character's money yOffset = draw_string_raw(getX() + 8, yOffset, "$%4d", pchr->getMoney()) + 8; bool levelUp = false; if(pchr->isPlayer()) { levelUp = PlaStack.get_ptr(pchr->is_which_player)->_unspentLevelUp; } // draw the character's main icon draw_one_character_icon(pchr->getCharacterID(), getX() + 40, yOffset, false, levelUp ? COLOR_YELLOW : NOSPARKLE); // draw the left hand item icon draw_one_character_icon(pchr->holdingwhich[SLOT_LEFT], getX() + 8, yOffset, true, NOSPARKLE); // draw the right hand item icon draw_one_character_icon(pchr->holdingwhich[SLOT_RIGHT], getX() + 72, yOffset, true, NOSPARKLE); // skip to the next row yOffset += 32; //Draw the small XP progress bar yOffset = draw_character_xp_bar(pchr->getCharacterID(), getX() + 16, yOffset); // Draw the life bar if (pchr->isAlive()) { yOffset = draw_one_bar(pchr->getAttribute(Ego::Attribute::LIFE_BARCOLOR), getX(), yOffset, life_pips, life_pips_max); } else { // Draw a black bar yOffset = draw_one_bar(0, getX(), yOffset, 0, life_pips_max); } // Draw the mana bar if (mana_pips_max > 0) { yOffset = draw_one_bar(pchr->getAttribute(Ego::Attribute::MANA_BARCOLOR), getX(), yOffset, mana_pips, mana_pips_max); } //After rendering we know how high this GUI component actually is setHeight(yOffset - getY()); //Finally draw charge bar if applicable if(pchr->isPlayer()) { const player_t *ppla = PlaStack.get_ptr(pchr->is_which_player); if(ppla->_chargeBarFrame >= update_wld) { _chargeBar->setVisible(true); _chargeBar->setMaxValue(ppla->_maxCharge); _chargeBar->setValue(ppla->_currentCharge); _chargeBar->setTickWidth(ppla->_chargeTick); _chargeBar->setSize(getWidth(), 16); _chargeBar->setPosition(getX() - _chargeBar->getWidth() - 5, getY() + getHeight() / 2 - _chargeBar->getHeight()/2); _chargeBar->draw(); } else { _chargeBar->setVisible(false); } } }