static void DrawArmor(ABasicArmor * barmor, AHexenArmor * harmor, int x, int y) { int ap = 0; int bestslot = 4; if (harmor) { int ac = (harmor->Slots[0] + harmor->Slots[1] + harmor->Slots[2] + harmor->Slots[3] + harmor->Slots[4]); ac >>= FRACBITS; ap += ac; if (ac) { // Find the part of armor that protects the most bestslot = 0; for (int i = 1; i < 4; ++i) { if (harmor->Slots[i] > harmor->Slots[bestslot]) { bestslot = i; } } } } if (barmor) { ap += barmor->Amount; } if (ap) { // decide on color int fontcolor = ap < hud_armor_red ? CR_RED : ap < hud_armor_yellow ? CR_GOLD : ap <= hud_armor_green ? CR_GREEN : CR_BLUE; // Use the sprite of one of the predefined Hexen armor bonuses. // This is not a very generic approach, but it is not possible // to truly create new types of Hexen armor bonus items anyway. if (harmor && bestslot < 4) { char icon[] = "AR_1A0"; switch (bestslot) { case 1: icon[3] = '2'; break; case 2: icon[3] = '3'; break; case 3: icon[3] = '4'; break; default: break; } DrawImageToBox(TexMan.FindTexture(icon, FTexture::TEX_Sprite), x, y, 31, 17); } else if (barmor) DrawImageToBox(TexMan[barmor->Icon], x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, ap, x + 33, y + 17); } }
static void DrawHealth(int health, int x, int y) { // decide on the color first int fontcolor = health < hud_health_red ? CR_RED : health < hud_health_yellow ? CR_GOLD : health <= hud_health_green ? CR_GREEN : CR_BLUE; DrawImageToBox(healthpic, x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17); }
static void DrawFrags(player_t * CPlayer, int x, int y) { // [TP] If we're spectating, we don't have any frags to draw. if ( CPlayer->bSpectating ) return; // [TP] Depending on the gamemode, we may need to draw something else than frags int stat = CPlayer->fragcount; if( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSEARNWINS ) stat = CPlayer->ulWins; else if ( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSEARNPOINTS ) stat = CPlayer->lPointCount; DrawImageToBox(fragpic, x, y, 31, 17); DrawHudNumber(HudFont, CR_GRAY, stat /*CPlayer->fragcount*/, x + 33, y + 17); }
static void DrawHealth(player_t *CPlayer, int x, int y) { int health = CPlayer->health; // decide on the color first int fontcolor = health < hud_health_red ? CR_RED : health < hud_health_yellow ? CR_GOLD : health <= hud_health_green ? CR_GREEN : CR_BLUE; const bool haveBerserk = hud_berserk_health && NULL != berserkpic && NULL != CPlayer->mo->FindInventory< APowerStrength >(); DrawImageToBox(haveBerserk ? berserkpic : healthpic, x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, health, x + 33, y + 17); }
static void DrawArmor(AInventory * armor, int x, int y) { if (armor) { int ap=armor->Amount; // decide on color int fontcolor = ap < hud_armor_red ? CR_RED : ap < hud_armor_yellow ? CR_GOLD : ap <= hud_armor_green ? CR_GREEN : CR_BLUE; if (ap) { DrawImageToBox(TexMan[armor->Icon], x, y, 31, 17); DrawHudNumber(HudFont, fontcolor, ap, x + 33, y + 17); } } }
static void DrawFrags(player_t * CPlayer, int x, int y) { DrawImageToBox(fragpic, x, y, 31, 17); DrawHudNumber(HudFont, CR_GRAY, CPlayer->fragcount, x + 33, y + 17); }
void CHudAmmo::Paint( void ) { int r, g, b, a, nUnused; int x, y; Color clrAmmo; if (!ShouldDraw()) return; C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatWeapon *pActiveWeapon = GetActiveWeapon(); // find and display our current selection if ( !pPlayer || !pActiveWeapon ) { hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" ); hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" ); return; } hudlcd->SetGlobalStat( "(weapon_print_name)", pActiveWeapon ? pActiveWeapon->GetPrintName() : " " ); hudlcd->SetGlobalStat( "(weapon_name)", pActiveWeapon ? pActiveWeapon->GetName() : " " ); if ( ( pActiveWeapon->GetPrimaryAmmoType() == -1 ) && ( pActiveWeapon->GetSecondaryAmmoType() == -1 ) ) return; int nFontWidth = GetNumberFontWidth(); int nFontHeight = GetNumberFontHeight(); a = (int)max( MIN_ALPHA, m_flFade ); if ( m_flFade > 0 ) m_flFade -= ( gpGlobals->frametime * 20 ); (gHUD.m_clrYellowish).GetColor( r, g, b, nUnused ); clrAmmo.SetColor( r, g, b, a ); int nHudElemWidth, nHudElemHeight; GetSize( nHudElemWidth, nHudElemHeight ); // Does this weapon have a clip? y = nHudElemHeight - ( nFontHeight * 1.5 ); // Does weapon have any ammo at all? if ( pActiveWeapon->GetPrimaryAmmoType() != -1 ) { CHudTexture *icon_ammo = gWR.GetAmmoIconFromWeapon( pActiveWeapon->GetPrimaryAmmoType() ); if ( !icon_ammo ) { return; } int nIconWidth = icon_ammo->Width(); if ( pActiveWeapon->UsesClipsForAmmo1() ) { // room for the number and the '|' and the current ammo x = nHudElemWidth - (8 * nFontWidth) - nIconWidth; x = DrawHudNumber( x, y, pActiveWeapon->Clip1(), clrAmmo ); int nBarWidth = nFontWidth / 10; x += nFontWidth / 2; (gHUD.m_clrYellowish).GetColor( r, g, b, nUnused ); clrAmmo.SetColor( r, g, b, a ); // draw the | bar clrAmmo.SetColor( r, g, b, a ); vgui::surface()->DrawSetColor( clrAmmo ); vgui::surface()->DrawFilledRect( x, y, x + nBarWidth, y + nFontHeight ); x += nBarWidth + nFontWidth / 2; x = DrawHudNumber( x, y, pPlayer->GetAmmoCount( pActiveWeapon->GetPrimaryAmmoType() ), clrAmmo ); } else { // SPR_Draw a bullets only line x = nHudElemWidth - 4 * nFontWidth - nIconWidth; x = DrawHudNumber( x, y, pPlayer->GetAmmoCount( pActiveWeapon->GetPrimaryAmmoType() ), clrAmmo ); } // Draw the ammo Icon icon_ammo->DrawSelf( x, y, clrAmmo ); hudlcd->SetGlobalStat( "(ammo_primary)", VarArgs( "%d", pPlayer->GetAmmoCount( pActiveWeapon->GetPrimaryAmmoType() ) ) ); } else { hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" ); } // Does weapon have seconday ammo? if ( pActiveWeapon->GetSecondaryAmmoType() != -1 ) { CHudTexture *icon_ammo = gWR.GetAmmoIconFromWeapon( pActiveWeapon->GetSecondaryAmmoType() ); if ( !icon_ammo ) { return; } int nIconWidth = icon_ammo->Width(); // Do we have secondary ammo? if ( pPlayer->GetAmmoCount( pActiveWeapon->GetSecondaryAmmoType() ) > 0 ) { y -= ( nFontHeight * 1.25 ); x = nHudElemWidth - 4 * nFontWidth - nIconWidth; x = DrawHudNumber( x, y, pPlayer->GetAmmoCount( pActiveWeapon->GetSecondaryAmmoType() ), clrAmmo ); // Draw the ammo Icon icon_ammo->DrawSelf( x, y, clrAmmo ); } hudlcd->SetGlobalStat( "(ammo_secondary)", VarArgs( "%d", pPlayer->GetAmmoCount( pActiveWeapon->GetSecondaryAmmoType() ) ) ); } else { hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" ); } }