Beispiel #1
0
void CHUDAmmo::Update()
{

	HWEAPON hWeapon = g_pPlayerStats->GetCurrentWeaponRecord();
	HAMMO hAmmo = g_pPlayerStats->GetCurrentAmmoRecord();

	m_bDraw = (hWeapon && hAmmo);

	if (hAmmo)
	{
		DamageType dtAmmoInstDamageType = g_pWeaponDB->GetAmmoInstDamageType( hAmmo);
		if (dtAmmoInstDamageType == DT_MELEE)
			m_bDraw = false;
	}

	if (!m_bDraw) return;

	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon( );
	int nAmmoInClip = pClientWeapon ? pClientWeapon->GetAmmoInClips() : 0;
	int nAmmo = g_pPlayerStats->GetCurrentAmmoCount() - nAmmoInClip;

	HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);
	m_bInfinite = g_pWeaponDB->GetBool( hWpnData, WDB_WEAPON_bInfiniteAmmo );

	if (!m_bInfinite)
	{
		wchar_t wstr[32];
		FormatString("HUD_Ammo_Format",wstr,LTARRAYSIZE(wstr), nAmmoInClip, nAmmo < 0 ? 0 : nAmmo);

		if ((nAmmo > 0) || (nAmmoInClip > 0))
		{
			EnableFade(true);
		}
		else
		{
			ResetFade();
			EnableFade( false );
		}
		

		m_Text.SetText(wstr);
	}

	if (m_hLastAmmo != hAmmo)
	{
		HAMMODATA hAmmoData = g_pWeaponDB->GetAmmoData(hAmmo);
		m_hIconTexture.Load( g_pWeaponDB->GetString( hAmmoData, WDB_AMMO_sIcon ) );
		SetupQuadUVs(m_IconPoly, m_hIconTexture, 0.0f, 0.0f, 1.0f, 1.0f);
		m_hLastAmmo = hAmmo;
	}

	ResetFade();

}
Beispiel #2
0
void CHUDWeapon::Select(bool bSelected)
{
	if (bSelected)
	{
		m_vIconSize = m_vLargeSize;
		m_vTextOffset = m_vLargeOffset;
	}
	else
	{
		m_vIconSize = m_vSmallSize;
		m_vTextOffset = m_vSmallOffset;
	}
	m_bSelected = bSelected;

	float x = (float)(m_vBasePos.x + m_vIconOffset.x);
	float y = (float)(m_vBasePos.y + m_vIconOffset.y);
	DrawPrimSetXYWH(m_IconPoly,x,y,float(m_vIconSize.x),float(m_vIconSize.y));

	LTVector2 vPos;
	vPos.x = float( m_vBasePos.x + m_vTextOffset.x);
	vPos.y = float( m_vBasePos.y + m_vTextOffset.y);
	m_Text.SetPos(vPos);


	UpdateBar();
	ResetFade();
}
Beispiel #3
0
bool CSoundBase::HandleFade()
{
	AL_CHECK;
	if (m_ALSource == 0)
		return true;

	if (m_StartFadeTime != 0)
	{
		double currTime = timer_Time();
		double pctDone = std::min(1.0, (currTime - m_StartFadeTime) / (m_EndFadeTime - m_StartFadeTime));
		pctDone = std::max(0.0, pctDone);
		ALfloat curGain = ((m_EndVolume - m_StartVolume) * pctDone) + m_StartVolume;

		if  (curGain == 0)
		{
			if ( m_PauseAfterFade )
				Pause();
			else
				Stop();
		}
		else if (curGain == m_EndVolume)
		{
			if (m_ALSource != 0)
				alSourcef(m_ALSource, AL_GAIN, curGain);
			ResetFade();
		}
		else if (m_ALSource != 0)
			alSourcef(m_ALSource, AL_GAIN, curGain);

		AL_CHECK;
	}
	return true;
}
void CFadeManager::SetFade( int iFadeType, void( *func )( ))
{
	m_iFadeType = iFadeType;
	m_endWork = func;
	m_isFading = true;

	ResetFade( iFadeType );
}
Beispiel #5
0
void CSoundBase::ResetVars()
{
    m_ALSource = 0;
    m_SoundData = 0;
    m_LastPlay = false;
    m_Looping = false;
    m_StartFadeTime = 0;
    m_EndFadeTime = 0;
    m_StartVolume = 0;
    m_EndVolume = 0;

    ResetFade();
    m_Name = new std::string("sound name");
}
Beispiel #6
0
void CSoundBase::ResetVars()
{
	m_ALSource = 0;
	m_SoundData = 0;
	m_LastPlay = false;
	m_Looping = false;
	m_StartFadeTime = 0;
	m_EndFadeTime = 0;
	m_StartVolume = 0;
	m_EndVolume = 0;
	m_ShouldBePlaying = false;
	m_IsPaused = false;
	ResetFade();
}
Beispiel #7
0
// ----------------------------------------------------------------------- //
// Update values
// ----------------------------------------------------------------------- //
void CHUDWeapon::Update()
{
	if (!m_hWeapon)
	{
		m_Text.SetText(L"");
		m_cIconColor = m_cDisabledColor;
		UpdateBar();

		return;
	}
	HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(m_hWeapon, !USE_AI_DATA);
	HAMMO hDefaultAmmo = g_pWeaponDB->GetRecordLink( hWpnData, WDB_WEAPON_rAmmoName );

	uint32 nCount = g_pPlayerStats->GetAmmoCount(hDefaultAmmo);
	

	//if the number of items has changed
	if (nCount != m_nCount)
	{
		if (nCount > m_nCount)
		{
			ResetFade();
		}			

		m_nCount = nCount;

		//update our text
		wchar_t wstr[32];
		swprintf(wstr,L"%d", m_nCount );
		m_Text.SetText(wstr);

		if (nCount > 0)
		{
			m_cIconColor = m_cNormalColor;
		}
		else
		{
			m_cIconColor = m_cDisabledColor;
		}

		UpdateBar();

	}

}
Beispiel #8
0
void CHUDArmor::Update()
{
	uint8 nValue = g_pPlayerStats->GetArmor();
	if (nValue > m_nLastValue)
	{
		Flash("Pickup");
	}
	m_nLastValue = nValue;

	wchar_t szTmp[16] = L"";
	swprintf(szTmp,L"%d",nValue);
	m_Text.SetText(szTmp);

	ResetFade();
	EnableFade( (m_nFadeThreshold == 0) || g_pPlayerStats->GetArmor() > m_nFadeThreshold );

	if (!m_bFadeEnabled)
	{
		m_Text.SetColor(m_cTextColor);
		DrawPrimSetRGBA(m_IconPoly,m_cIconColor);
	}
	UpdateBar();
}