// // Draw Weapon Menu // int CHudAmmo::DrawWList(float flTime) { int r, g, b, x, y, a, i; if(!gpActiveSel) return 0; int iActiveSlot; if(gpActiveSel == (WEAPON *)1) iActiveSlot = -1; // current slot has no weapons else iActiveSlot = gpActiveSel->iSlot; x = 10; //!!! y = 10; //!!! // Ensure that there are available choices in the active slot if(iActiveSlot > 0) { if(!gWR.GetFirstPos(iActiveSlot)) { gpActiveSel = (WEAPON *)1; iActiveSlot = -1; } } // Draw top line for(i = 0; i < MAX_WEAPON_SLOTS; i++) { int iWidth; UnpackRGB(r, g, b, RGB_YELLOWISH); if(iActiveSlot == i) a = 255; else a = 192; ScaleColors(r, g, b, 255); SPR_Set(gHUD.GetSprite(m_HUD_bucket0 + i), r, g, b); // make active slot wide enough to accomodate gun pictures if(i == iActiveSlot) { WEAPON *p = gWR.GetFirstPos(iActiveSlot); if(p) iWidth = p->rcActive.right - p->rcActive.left; } else iWidth = giBucketWidth; if(i == iActiveSlot) SPR_DrawAdditive(0, x + 104, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i)); else SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i)); x += iWidth + 5; } a = 128; //!!! x = 10; // Draw all of the buckets for(i = 1; i < MAX_WEAPON_SLOTS + 1; i++) { y = giBucketHeight + 10; // If this is the active slot, draw the bigger pictures, // otherwise just draw boxes if(i == iActiveSlot) { WEAPON *p = gWR.GetFirstPos(i); int iWidth = giBucketWidth; if(p) iWidth = p->rcActive.right - p->rcActive.left; for(int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++) { p = gWR.GetWeaponSlot(i, iPos); if(!p || !p->iId) continue; UnpackRGB(r, g, b, RGB_YELLOWISH); // if active, then we must have ammo. if(gpActiveSel == p) { if(gWR.HasAmmo(p)) ScaleColors(r, g, b, 192); else { UnpackRGB(r, g, b, RGB_REDISH); ScaleColors(r, g, b, 128); } SPR_Set(p->hActive, r, g, b); SPR_DrawAdditive(0, x, y, &p->rcActive); } else { // Draw Weapon if Red if no ammo if(gWR.HasAmmo(p)) ScaleColors(r, g, b, 192); else { UnpackRGB(r, g, b, RGB_REDISH); ScaleColors(r, g, b, 128); } SPR_Set(p->hInactive, r, g, b); SPR_DrawAdditive(0, x, y, &p->rcInactive); } // Draw Ammo Bar DrawAmmoBar(p, x + giABWidth / 2, y, giABWidth, giABHeight); y += p->rcActive.bottom - p->rcActive.top + 5; } x += iWidth + 5; } else { // Draw Row of weapons. UnpackRGB(r, g, b, RGB_YELLOWISH); for(int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++) { WEAPON *p = gWR.GetWeaponSlot(i, iPos); if(!p || !p->iId) continue; if(gWR.HasAmmo(p)) { UnpackRGB(r, g, b, RGB_YELLOWISH); a = 128; } else { UnpackRGB(r, g, b, RGB_REDISH); a = 96; } FillRGBA(x, y, giBucketWidth, giBucketHeight, r, g, b, a); y += giBucketHeight + 5; } x += giBucketWidth + 5; } } return 1; }
// // Draw Weapon Menu // int CHudAmmo::DrawWList(float flTime) { int r,g,b,x,y,a,i; if ( !m_pActiveSel ) return 0; int iActiveSlot; if ( m_pActiveSel == ( CBasePlayerWeapon *)1 ) iActiveSlot = -1; // current slot has no weapons else iActiveSlot = m_pActiveSel->GetWeaponInfo()->GetBucket(); x = 10; //!!! y = 10; //!!! CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer(); // Ensure that there are available choices in the active slot if ( iActiveSlot > 0 ) { if ( !pPlayer->GetFirstPos( iActiveSlot ) ) { m_pActiveSel = ( CBasePlayerWeapon *)1; iActiveSlot = -1; } } // Shepard : determine how many buckets we should draw int iBucketsToDraw = 0; for ( i = 0; i < MAX_WEAPON_SLOTS; i++ ) { for ( int j = 0; j < MAX_WEAPONS; j++ ) { CBasePlayerWeapon *pWeapon = pPlayer->GetWeapon( i, j ); if ( pWeapon && pWeapon->GetWeaponInfo() && pWeapon->GetWeaponInfo()->GetBucket() > iBucketsToDraw ) iBucketsToDraw = pWeapon->GetWeaponInfo()->GetBucket(); } } iBucketsToDraw++; // Draw top line for ( i = 0; i < iBucketsToDraw; i++ ) { int iWidth; gHUD.GetPrimaryColor().UnpackRGB(r,g,b); if ( iActiveSlot == i ) a = 255; else a = 192; ScaleColors(r, g, b, 255); SPR_Set(gHUD.GetSprite(m_HUD_bucket0 + i), r, g, b ); // make active slot wide enough to accomodate gun pictures if ( i == iActiveSlot ) { CBasePlayerWeapon *p = pPlayer->GetFirstPos(iActiveSlot); if ( p ) iWidth = p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.right - p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.left; else iWidth = m_iBucketWidth; } else iWidth = m_iBucketWidth; SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i)); x += iWidth + 5; } a = 128; //!!! x = 10; // Draw all of the buckets for (i = 0; i < iBucketsToDraw; i++) { y = m_iBucketHeight + 10; // If this is the active slot, draw the bigger pictures, // otherwise just draw boxes if ( i == iActiveSlot ) { CBasePlayerWeapon *p = pPlayer->GetFirstPos( i ); int iWidth = m_iBucketWidth; if ( p ) iWidth = p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.right - p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.left; for ( int iPos = 0; iPos < MAX_WEAPONS; iPos++ ) { p = pPlayer->GetWeapon( i, iPos ); if ( !p || !p->GetWeaponInfo() ) continue; auto pHUDInfo = p->GetWeaponInfo()->GetHUDInfo(); gHUD.GetPrimaryColor().UnpackRGB( r,g,b ); // if active, then we must have ammo. if ( m_pActiveSel == p ) { SPR_Set( pHUDInfo->GetActive().hSprite, r, g, b ); SPR_DrawAdditive(0, x, y, &pHUDInfo->GetActive().rect ); SPR_Set(gHUD.GetSprite(m_HUD_selection), r, g, b ); SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_selection)); } else { // Draw Weapon if Red if no ammo if ( pPlayer->HasAmmo(p) ) ScaleColors(r, g, b, 192); else { gHUD.GetEmptyItemColor().UnpackRGB(r,g,b); ScaleColors(r, g, b, 128); } SPR_Set( pHUDInfo->GetInactive().hSprite, r, g, b ); SPR_DrawAdditive( 0, x, y, &pHUDInfo->GetInactive().rect ); } // Draw Ammo Bar DrawAmmoBar(p, x + m_iABWidth/2, y, m_iABWidth, m_iABHeight); y += pHUDInfo->GetActive().rect.bottom - pHUDInfo->GetActive().rect.top + 5; } x += iWidth + 5; } else { // Draw Row of weapons. gHUD.GetPrimaryColor().UnpackRGB(r,g,b); for ( int iPos = 0; iPos < MAX_WEAPONS; iPos++ ) { CBasePlayerWeapon *p = pPlayer->GetWeapon( i, iPos ); if ( !p || !p->GetWeaponInfo() ) continue; if ( pPlayer->HasAmmo(p) ) { gHUD.GetPrimaryColor().UnpackRGB(r,g,b); a = 128; } else { gHUD.GetEmptyItemColor().UnpackRGB(r,g,b); a = 96; } FillRGBA( x, y, m_iBucketWidth, m_iBucketHeight, r, g, b, a ); y += m_iBucketHeight + 5; } x += m_iBucketWidth + 5; } } return 1; }