void CHud::RenderHealthArmor(CEntity *pEntity) { int iHealthTex = static_cast<int>(pEntity->GetLife()) / 10; if(iHealthTex > 10) iHealthTex = 10; else if(iHealthTex < 0) iHealthTex = 0; CMaterial *pHealthTex = m_HealthTextures[iHealthTex]; const core::dimension2du &HealthImgSize = pHealthTex->GetFrame(0)->getSize(); core::position2di HealthDestPos(30, 30); core::recti HealthSrcRect(0, 0, HealthImgSize.Width, HealthImgSize.Height); m_pGame->GetVideoDriver()->draw2DImage(pHealthTex->GetFrame(0), HealthDestPos, HealthSrcRect, 0, video::SColor(96, 255, 255, 255), true); int iEnviroTex = static_cast<int>(pEntity->GetArmor()) / 10; if(iEnviroTex > 10) iEnviroTex = 10; else if(iEnviroTex < 0) iEnviroTex = 0; CMaterial *pEnviroTex = m_EnviroTextures[iEnviroTex]; const core::dimension2du &EnviroImgSize = pEnviroTex->GetFrame(0)->getSize(); core::position2di EnviroDestPos(10, 10); core::recti EnviroSrcRect(0, 0, EnviroImgSize.Width, EnviroImgSize.Height); m_pGame->GetVideoDriver()->draw2DImage(pEnviroTex->GetFrame(0), EnviroDestPos, EnviroSrcRect, 0, video::SColor(96, 255, 255, 255), true); gui::IGUIFont *pFont = m_pFont ? m_pFont : m_pGame->GetGuiEnv()->getBuiltInFont(); wchar_t wszBuf[64]; core::recti HealthTextRect(70, 55, 100, 80); swprintf(wszBuf, L"%.0f", pEntity->GetLife()); pFont->draw(wszBuf, HealthTextRect, video::SColor(255, 255, 255, 0), true, true); core::recti EnviroTextRect(110, 55, 140, 80); swprintf(wszBuf, L"%.0f", pEntity->GetArmor()); pFont->draw(wszBuf, EnviroTextRect, video::SColor(255, 255, 255, 0), true, true); }
void CHud::RenderAmmo(CEntity *pEntity) { if(!pEntity->GetWeapon()) return; bool bHasClip = (pEntity->GetWeapon()->GetClass()->nClipSize > 0); unsigned cClipAmmo = pEntity->GetWeapon()->GetAmmo(); unsigned cAmmo = pEntity->GetAmmo(pEntity->GetWeapon()->GetClass()->pAmmoType); bool bHasAmmo = cClipAmmo > 0 || (!bHasClip && cAmmo > 0); const core::dimension2du &ScrSize = m_pGame->GetVideoDriver()->getScreenSize(); const core::dimension2du &AmmoBarSize = m_pAmmoBarTex->GetFrame(0)->getSize(); core::position2di AmmoBarDestPos(ScrSize.Width - AmmoBarSize.Width - 30, 30); core::recti AmmoBarSrcRect(0, 0, AmmoBarSize.Width, AmmoBarSize.Height); m_pGame->GetVideoDriver()->draw2DImage(m_pAmmoBarTex->GetFrame(0), AmmoBarDestPos, AmmoBarSrcRect, 0, video::SColor(96, 255, 255, 255), true); CMaterial *pSignalTex = bHasAmmo ? m_pAmmoSignalGreenTex : m_pAmmoSignalRedTex; const core::dimension2du &AmmoSignalSize = pSignalTex->GetFrame(0)->getSize(); core::position2di AmmoSignalDestPos(ScrSize.Width - AmmoBarSize.Width - 30 - AmmoSignalSize.Width, 30); core::recti AmmoSignalSrcRect(0, 0, AmmoSignalSize.Width, AmmoSignalSize.Height); m_pGame->GetVideoDriver()->draw2DImage(pSignalTex->GetFrame(0), AmmoSignalDestPos, AmmoSignalSrcRect, 0, video::SColor(96, 255, 255, 255), true); gui::IGUIFont *pFont = m_pFont ? m_pFont : m_pGame->GetGuiEnv()->getBuiltInFont(); wchar_t wszBuf[64]; core::recti AmmoInClipRect(AmmoBarDestPos.X, AmmoBarDestPos.Y, AmmoBarDestPos.X + AmmoBarSize.Width*2/5, AmmoBarDestPos.Y + AmmoBarSize.Height); swprintf(wszBuf, L"%u", cClipAmmo); pFont->draw(wszBuf, AmmoInClipRect, video::SColor(255, 255, 255, 0), true, true); core::recti TotalAmmoRect(AmmoBarDestPos.X + AmmoBarSize.Width*2/5, AmmoBarDestPos.Y, AmmoBarDestPos.X + AmmoBarSize.Width, AmmoBarDestPos.Y + AmmoBarSize.Height); swprintf(wszBuf, L"%u", cAmmo); pFont->draw(wszBuf, TotalAmmoRect, video::SColor(255, 255, 255, 0), true, true); }