本文整理汇总了C++中WeaponsResource::GetWeaponSlot方法的典型用法代码示例。如果您正苦于以下问题:C++ WeaponsResource::GetWeaponSlot方法的具体用法?C++ WeaponsResource::GetWeaponSlot怎么用?C++ WeaponsResource::GetWeaponSlot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeaponsResource
的用法示例。
在下文中一共展示了WeaponsResource::GetWeaponSlot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UserCmd_PrevWeapon
// Selects the previous item in the menu
void CHudAmmo::UserCmd_PrevWeapon( void )
{
if( gHUD.m_fPlayerDead || ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )))
return;
if( !gpActiveSel || gpActiveSel == (WEAPON *)1 )
gpActiveSel = m_pWeapon;
int pos = MAX_WEAPON_POSITIONS - 1;
int slot = MAX_WEAPON_SLOTS - 1;
if( gpActiveSel )
{
pos = gpActiveSel->iSlotPos - 1;
slot = gpActiveSel->iSlot;
}
for( int loop = 0; loop <= 1; loop++ )
{
for( ; slot >= 0; slot-- )
{
for( ; pos >= 0; pos-- )
{
WEAPON *wsp = gWR.GetWeaponSlot( slot, pos );
if( wsp && gWR.HasAmmo( wsp ))
{
gpActiveSel = wsp;
return;
}
}
pos = MAX_WEAPON_POSITIONS - 1;
}
slot = MAX_WEAPON_SLOTS - 1;
}
gpActiveSel = NULL;
}
示例2: UserCmd_NextWeapon
// Selects the next item in the weapon menu
void CHudAmmo::UserCmd_NextWeapon( void )
{
if( gHUD.m_fPlayerDead || ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )))
return;
if( !gpActiveSel || gpActiveSel == (WEAPON *)1 )
gpActiveSel = m_pWeapon;
int pos = 0;
int slot = 0;
if( gpActiveSel )
{
pos = gpActiveSel->iSlotPos + 1;
slot = gpActiveSel->iSlot;
}
for( int loop = 0; loop <= 1; loop++ )
{
for( ; slot < MAX_WEAPON_SLOTS; slot++ )
{
for( ; pos < MAX_WEAPON_POSITIONS; pos++ )
{
WEAPON *wsp = gWR.GetWeaponSlot( slot, pos );
if( wsp && gWR.HasAmmo( wsp ))
{
gpActiveSel = wsp;
return;
}
}
pos = 0;
}
slot = 0; // start looking from the first slot again
}
gpActiveSel = NULL;
}
示例3: DrawWList
//
// 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);
//.........这里部分代码省略.........
示例4: DrawWList
//
// Draw Weapon Menu
//
int CHudAmmo::DrawWList(float flTime)
{
// int r,g,b,x,y,a,i;
int baseX, baseY, x,y;
bool blFakeActive = false;
// Check if sliding is finished
if(m_blSliding)
{ if(m_flSlideTime + SLIDETIME < gHUD.m_flTime)
{ m_blSliding = false;
m_blSlideIn = false;
m_flSlideTime = 0;
}
}
// "Fake" active weapon so we can slide the weapon bar out with the correct information
if ( !gpActiveSel )
{ // start sliding
if(m_blPrevStatus)
{ m_blPrevStatus = false;
SlideIn();
blFakeActive = true;
gpActiveSel = gpLastSel;
if(!gpActiveSel)
return 0;
}
else if(m_blSliding)
{ blFakeActive = true;
gpActiveSel = gpLastSel;
if(!gpActiveSel)
return 0;
}
else
{ m_blPrevStatus = false;
return 0;
}
}
else
{ if(!m_blPrevStatus)
{ SlideOut();
}
m_blPrevStatus = true;
}
int iActiveSlot;
if ( gpActiveSel == (WEAPON *)1 )
iActiveSlot = -1; // current slot has no weapons
else
iActiveSlot = gpActiveSel->iSlot;
baseX=x=0;
baseY=y=GetYBase(m_iweapcenterHeight);
// Ensure that there are available choices in the active slot
if ( iActiveSlot > 0 )
{
if ( !gWR.GetFirstPos( iActiveSlot ) )
{
gpActiveSel = (WEAPON *)1;
iActiveSlot = -1;
}
}
// Draw left bar edge
SPR_Set(gHUD.GetSprite(m_HUD_wpleft), 255, 255, 255 );
SPR_DrawHoles(0,x,y, &gHUD.GetSpriteRect(m_HUD_wpleft));
// Move over drawing position to the end of the left bar
x+=m_iweapedgeWidth;
// Draw all of the buckets
for (int i = 0; i < MAX_WEAPON_SLOTS; i++)
{
// Set bucket rect
wrect_t bucketrect;
bucketrect.top = 0;
bucketrect.left = 0;
bucketrect.bottom = BUCKET_HEIGHT;
bucketrect.right = BUCKET_WIDTH;
// If this is the active slot, draw the bigger pictures,
WEAPON *p = gWR.GetFirstPos( i );
/* int iWidth = BUCKET_WIDTH;
int iHeight = BUCKET_HEIGHT;*/
if ( p )
{/* iWidth = p->rcActive.right - p->rcActive.left;
iHeight = p->rcActive.bottom - p->rcActive.top;*/
}
for ( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ )
{
p = gWR.GetWeaponSlot( i, iPos );
if ( !p || !p->iId )
//.........这里部分代码省略.........