//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDHudAmmo::PaintRifleGrenadeAmmo( CWeaponDODBase *pWpn )
{
    const CHudTexture *pAmmoIcon = pWpn->GetSpriteAmmo();

    Assert( pAmmoIcon );

    int xpos = small_icon_xpos, ypos = small_icon_ypos;
    int w = small_icon_width, t = small_icon_height;

    int nIconWidth = 0, nIconHeight = 0;
    float scale = 1.0f;

    if ( pAmmoIcon )
    {
        nIconWidth = pAmmoIcon->Width();
        nIconHeight = pAmmoIcon->Height();

        scale = GetScale( nIconWidth, nIconHeight, w, t );

        nIconWidth *= scale;
        nIconHeight *= scale;

        if ( nIconWidth < small_icon_width - XRES(2) ) // 2 is our buffer for when we need to re-calculate the xpos
        {
            xpos = small_icon_xpos + small_icon_width / 2.0 - nIconWidth / 2.0;
        }

        if ( nIconHeight < small_icon_height - YRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            ypos = small_icon_ypos + small_icon_height / 2.0 - nIconHeight / 2.0;
        }

        int ammo = m_iAmmo + m_iAmmo2;

        if ( ammo > 0 )
        {
            pAmmoIcon->DrawSelf( xpos, ypos, nIconWidth, nIconHeight, m_clrIcon );
            DrawAmmoCount( ammo );
        }
    }
}
Ejemplo n.º 2
0
void CNB_Vote_Panel::PerformLayout()
{
	BaseClass::PerformLayout();

	int x, y, w, t;
	GetBounds( x, y, w, t );

	m_pBackground->SetBounds( 0, 0, w, t );

	int border = YRES( 2 );
	m_pBackgroundInner->SetBounds( border, border, w - border * 2, t - border * 2 );

	int title_border = YRES( 3 );
	m_pTitleBG->SetBounds( title_border, title_border, w - title_border * 2, YRES( 18 ) );
	m_pTitleBGBottom->SetBounds( title_border, YRES( 15 ), w - title_border * 2, YRES( 6 ) );
	m_pTitle->SetBounds( title_border, title_border, w - title_border * 2, YRES( 18 ) );
}
Ejemplo n.º 3
0
int CHudStatusBar :: Draw( float fTime )
{
	if( m_bReparseString )
	{
		for( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
		{
			m_pflNameColors[i] = g_ColorYellow;
			ParseStatusString( i );
		}
		m_bReparseString = FALSE;
	}

	int Y_START = ScreenHeight - YRES( 32 + 4 );

	// Draw the status bar lines
	for( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
	{
		int TextHeight, TextWidth;
		GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );

		int x = 4;
		int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen

		// let user set status ID bar centering
		if(( i == STATUSBAR_ID_LINE ) && CVAR_GET_FLOAT( "hud_centerid" ))
		{
			x = max( 0, max( 2, (ScreenWidth - TextWidth)) / 2 );
			y = (ScreenHeight / 2) + (TextHeight * CVAR_GET_FLOAT( "hud_centerid" ));
		}

		if( m_pflNameColors[i] )
			DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );

		DrawConsoleString( x, y, m_szStatusBar[i] );
	}

	return 1;
}
void CASW_Hotbar_Entry::PerformLayout()
{
	BaseClass::PerformLayout();

	int w = YRES( 38); // halfwide, presuming 'extra' sized items
	int h = YRES( 38 );

	SetSize( w, h );

	int border = YRES( 2 );
	m_pMarineNameLabel->SetContentAlignment( vgui::Label::a_northeast );
	m_pMarineNameLabel->SetBounds( border, border, w - border * 2, YRES( 12 ) );
	m_pKeybindLabel->SetContentAlignment( vgui::Label::a_northwest );
	m_pKeybindLabel->SetBounds( border, border, w - border * 2, YRES( 12 ) );
	m_pQuantityLabel->SetContentAlignment( vgui::Label::a_southeast );
	m_pQuantityLabel->SetBounds( border, border, w - border * 2, h - border * 2 );

	border = YRES( 3 );
	m_pWeaponImage->SetBounds( border, border, w - border * 2, h - border * 2 );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDHudAmmo::PaintBazookaAmmo( CWeaponDODBase *pWpn )
{
    int panelX, panelY, panelW, panelT;
    GetBounds( panelX, panelY, panelW, panelT );

    const CHudTexture *pTubeIcon = pWpn->GetSpriteAmmo2();
    const CHudTexture *pRocketIcon = pWpn->GetSpriteAmmo();
    const CHudTexture *pExtraIcon = pWpn->GetSpriteAutoaim();

    Assert( pTubeIcon );
    Assert( pRocketIcon );
    Assert( pExtraIcon );

    int xpos = 0, ypos = 0;
    int nIconWidth = 0, nIconHeight = 0;
    float scale = 1.0f;

    if ( pTubeIcon && pRocketIcon )
    {
        nIconWidth = pTubeIcon->Width();
        nIconHeight = pTubeIcon->Height();

        xpos = large_icon_xpos;
        ypos = large_icon_ypos;

        // mad hax
        int width = large_icon_width + XRES(10);

        scale = GetScale( nIconWidth, nIconHeight, width, large_icon_height );

        nIconWidth *= scale;
        nIconHeight *= scale;

        if ( nIconWidth < large_icon_width - XRES(2) ) // 2 is our buffer for when we need to re-calculate the xpos
        {
            xpos = small_icon_xpos + small_icon_width / 2.0 - nIconWidth / 2.0;
        }

        if ( nIconHeight < large_icon_height - YRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            ypos = small_icon_ypos + small_icon_height / 2.0 - nIconHeight / 2.0;
        }

        pTubeIcon->DrawSelf( xpos, ypos, nIconWidth, nIconHeight, m_clrIcon );

        // If our clip is full, draw the rocket
        if( pRocketIcon )
        {
            if( m_iAmmo > 0 )
            {
                pRocketIcon->DrawSelf( xpos, ypos, nIconWidth, nIconHeight, m_clrIcon );
            }
        }
    }

    // Draw the extra rockets
    if( m_iAmmo2 > 0 && pExtraIcon )
    {
        // Align the extra clip on the same baseline as the large clip
        xpos = extra_clip_xpos;
        ypos = extra_clip_ypos;

        nIconWidth = pExtraIcon->Width();
        nIconHeight = pExtraIcon->Height();

        if ( nIconWidth > extra_clip_width || nIconHeight > extra_clip_height )
        {
            scale = GetScale( nIconWidth, nIconHeight, extra_clip_width, extra_clip_height );
            nIconWidth *= scale;
            nIconHeight *= scale;
        }

        if ( nIconWidth < extra_clip_width - XRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            xpos = extra_clip_xpos + extra_clip_width / 2.0 - nIconWidth / 2.0;
        }

        if ( nIconHeight < extra_clip_height - YRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            ypos = extra_clip_ypos + extra_clip_height / 2.0 - nIconHeight / 2.0;
        }

        pExtraIcon->DrawSelf( xpos, ypos, pExtraIcon->Width() * scale, pExtraIcon->Height() * scale, m_clrIcon );
        DrawAmmoCount( m_iAmmo2 );
    }
}
Ejemplo n.º 6
0
void ScorePanel::FillGrid()
{
	CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
	SchemeHandle_t hScheme = pSchemes->getSchemeHandle("Scoreboard Text");
	SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text");
	SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text");

	Font *sfont = pSchemes->getFont(hScheme);
	Font *tfont = pSchemes->getFont(hTitleScheme);
	Font *smallfont = pSchemes->getFont(hSmallScheme);

	// update highlight position
	int x, y;
	getApp()->getCursorPos(x, y);
	cursorMoved(x, y, this);

	// remove highlight row if we're not in squelch mode
	if (!GetClientVoiceMgr()->IsInSquelchMode())
	{
		m_iHighlightRow = -1;
	}

	bool bNextRowIsGap = false;

	for(int row=0; row < NUM_ROWS; row++)
	{
		CGrid *pGridRow = &m_PlayerGrids[row];
		pGridRow->SetRowUnderline(0, false, 0, 0, 0, 0, 0);

		if(row >= m_iRows)
		{
			for(int col=0; col < NUM_COLUMNS; col++)
				m_PlayerEntries[col][row].setVisible(false);
		
			continue;
		}

		bool bRowIsGap = false;
		if (bNextRowIsGap)
		{
			bNextRowIsGap = false;
			bRowIsGap = true;
		}

		for(int col=0; col < NUM_COLUMNS; col++)
		{
			CLabelHeader *pLabel = &m_PlayerEntries[col][row];

			pLabel->setVisible(true);
			pLabel->setText2("");
			pLabel->setImage(NULL);
			pLabel->setFont(sfont);
			pLabel->setTextOffset(0, 0);
			
			int rowheight = 13;
			if (ScreenHeight > 480)
			{
				rowheight = YRES(rowheight);
			}
			else
			{
				// more tweaking, make sure icons fit at low res
				rowheight = 15;
			}
			pLabel->setSize(pLabel->getWide(), rowheight);
			pLabel->setBgColor(0, 0, 0, 255);
			
			char sz[128];
			hud_player_info_t *pl_info = NULL;
			team_info_t *team_info = NULL;

			if (m_iIsATeam[row] == TEAM_BLANK)
			{
				pLabel->setText(" ");
				continue;
			}
			else if ( m_iIsATeam[row] == TEAM_YES )
			{
				// Get the team's data
				team_info = &g_TeamInfo[ m_iSortedRows[row] ];

				// team color text for team names
				pLabel->setFgColor(	iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0],
									iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1],
									iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2],
									0 );

				// different height for team header rows
				rowheight = 20;
				if (ScreenHeight >= 480)
				{
					rowheight = YRES(rowheight);
				}
				pLabel->setSize(pLabel->getWide(), rowheight);
				pLabel->setFont(tfont);

				pGridRow->SetRowUnderline(	0,
											true,
											YRES(3),
											iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0],
											iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1],
											iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2],
											0 );
			}
			else if ( m_iIsATeam[row] == TEAM_SPECTATORS )
			{
				// grey text for spectators
				pLabel->setFgColor(100, 100, 100, 0);

				// different height for team header rows
				rowheight = 20;
				if (ScreenHeight >= 480)
				{
					rowheight = YRES(rowheight);
				}
				pLabel->setSize(pLabel->getWide(), rowheight);
				pLabel->setFont(tfont);

				pGridRow->SetRowUnderline(0, true, YRES(3), 100, 100, 100, 0);
			}
			else
			{
				// team color text for player names
				pLabel->setFgColor(	iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0],
									iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1],
									iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2],
									0 );

				// Get the player's data
				pl_info = &g_PlayerInfoList[ m_iSortedRows[row] ];

				// Set background color
				if ( pl_info->thisplayer ) // if it is their name, draw it a different color
				{
					// Highlight this player
					pLabel->setFgColor(Scheme::sc_white);
					pLabel->setBgColor(	iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0],
										iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1],
										iTeamColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2],
										196 );
				}
				else if ( m_iSortedRows[row] == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime )
				{
					// Killer's name
					pLabel->setBgColor( 255,0,0, 255 - ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) );
				}
			}				

			// Align 
			if (col == COLUMN_NAME || col == COLUMN_CLASS)
			{
				pLabel->setContentAlignment( vgui::Label::a_west );
			}
			else if (col == COLUMN_TRACKER)
			{
				pLabel->setContentAlignment( vgui::Label::a_center );
			}
			else
			{
				pLabel->setContentAlignment( vgui::Label::a_east );
			}

			// Fill out with the correct data
			strcpy(sz, "");
			if ( m_iIsATeam[row] )
			{
				char sz2[128];

				switch (col)
				{
				case COLUMN_NAME:
					if ( m_iIsATeam[row] == TEAM_SPECTATORS )
					{
						sprintf( sz2, CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) );
					}
					else
					{
						sprintf( sz2, gViewPort->GetTeamName(team_info->teamnumber) );
					}

					strcpy(sz, sz2);

					// Append the number of players
					if ( m_iIsATeam[row] == TEAM_YES )
					{
						if (team_info->players == 1)
						{
							sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player" ) );
						}
						else
						{
							sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player_plural" ) );
						}

						pLabel->setText2(sz2);
						pLabel->setFont2(smallfont);
					}
					break;
				case COLUMN_VOICE:
					break;
				case COLUMN_CLASS:
					break;
				case COLUMN_KILLS:
					if ( m_iIsATeam[row] == TEAM_YES )
						sprintf(sz, "%d",  team_info->frags );
					break;
				case COLUMN_DEATHS:
					if ( m_iIsATeam[row] == TEAM_YES )
						sprintf(sz, "%d",  team_info->deaths );
					break;
				case COLUMN_LATENCY:
					if ( m_iIsATeam[row] == TEAM_YES )
						sprintf(sz, "%d", team_info->ping );
					break;
				default:
					break;
				}
			}
			else
			{
				bool bShowClass = false;

				switch (col)
				{
				case COLUMN_NAME:
					sprintf(sz, "%s  ", pl_info->name);
					break;
				case COLUMN_VOICE:
					sz[0] = 0;
					// in HLTV mode allow spectator to turn on/off commentator voice
					if (!pl_info->thisplayer || gEngfuncs.IsSpectateOnly() )
					{
						GetClientVoiceMgr()->UpdateSpeakerImage(pLabel, m_iSortedRows[row]);
					}
					break;
				case COLUMN_CLASS:
					// No class for other team's members (unless allied or spectator)
					if ( gViewPort && EV_TFC_IsAllyTeam( g_iTeamNumber, g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber )  )
						bShowClass = true;
					// Don't show classes if this client hasnt picked a team yet
					if ( g_iTeamNumber == 0 )
						bShowClass = false;

					if (bShowClass)
					{
						// Only print Civilian if this team are all civilians
						bool bNoClass = false;
						if ( g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass == 0 )
						{
							if ( gViewPort->GetValidClasses( g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber ) != -1 )
								bNoClass = true;
						}

						if (bNoClass)
							sprintf(sz, "");
						else
							sprintf( sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[ g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ] ) );
					}
					else
					{
						strcpy(sz, "");
					}
					break;

				case COLUMN_TRACKER:
					break;
				case COLUMN_KILLS:
					sprintf(sz, "%d",  g_PlayerExtraInfo[ m_iSortedRows[row] ].frags );
					break;
				case COLUMN_DEATHS:
					sprintf(sz, "%d",  g_PlayerExtraInfo[ m_iSortedRows[row] ].deaths );
					break;
				case COLUMN_LATENCY:
					sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping );
					break;
				default:
					break;
				}
			}

			pLabel->setText(sz);
		}
	}

	for(row=0; row < NUM_ROWS; row++)
	{
		CGrid *pGridRow = &m_PlayerGrids[row];

		pGridRow->AutoSetRowHeights();
		pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight());
		pGridRow->RepositionContents();
	}

	// hack, for the thing to resize
	m_PlayerList.getSize(x, y);
	m_PlayerList.setSize(x, y);
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_WeaponMortar::Redraw()
{
	BaseClass::Redraw();

	// If the player's dead, abort
	C_BaseTFPlayer *pPlayer = C_BaseTFPlayer::GetLocalPlayer();
	if ( pPlayer == NULL )
		return;
	if ( pPlayer->GetHealth() < 1 )
	{
		m_iFiringState = MORTAR_IDLE;
		m_bCarried = true;
		return;
	}

	// If it's reloading, tell the player
	if ( m_bMortarReloading )
	{
		int width, height;
		messagechars->GetStringLength( m_hFontText, &width, &height, "Mortar is reloading..." );
		messagechars->DrawString( m_hFontText, (ScreenWidth() - width) / 2, YRES(350), 192, 192, 192, 255, "Mortar is reloading...", IMessageChars::MESSAGESTRINGID_NONE );
		return;
	}

	// Handle power charging
	switch( m_iFiringState )
	{
	case MORTAR_IDLE:
		m_pPowerBar->m_flPower = 0;
		break;
	case MORTAR_CHARGING_POWER:
		m_pPowerBar->m_flPower = min( m_pPowerBar->m_flPower + ( (1.0 / MORTAR_CHARGE_POWER_RATE) * gpGlobals->curtimeDelta), 1.0f);
		m_pPowerBar->m_flFiringPower = 0;
		m_pPowerBar->m_flFiringAccuracy = 0;
		if ( m_pPowerBar->m_flPower >= 1.0 )
		{
			// Hit Max, start going down
			m_pPowerBar->m_flFiringPower = m_pPowerBar->m_flPower;
			m_iFiringState = MORTAR_CHARGING_ACCURACY;
			m_flNextClick = gpGlobals->curtime + 0.25;
		}
		break;
	case MORTAR_CHARGING_ACCURACY:
		// Calculate accuracy speed
		m_flAccuracySpeed = (1.0 / MORTAR_CHARGE_ACCURACY_RATE);
		if ( m_pPowerBar->m_flFiringPower > 0.5 )
		{
			// Shots over halfway suffer an increased speed to the accuracy power, making accurate shots harder
			float flAdjustedPower = (m_pPowerBar->m_flFiringPower - 0.5) * 3.0;
			m_flAccuracySpeed += (m_pPowerBar->m_flFiringPower * flAdjustedPower);
		}

		m_pPowerBar->m_flPower = max( m_pPowerBar->m_flPower - ( m_flAccuracySpeed * gpGlobals->curtimeDelta), -0.25f);
		if ( m_pPowerBar->m_flPower <= -0.25 )
		{
			// Hit Min, fire mortar
			m_pPowerBar->m_flFiringAccuracy = m_pPowerBar->m_flPower;
			m_iFiringState = MORTAR_IDLE;

			FireMortar();
			m_flNextClick = gpGlobals->curtime + 0.25;
		}
		break;
	default:
		break;
	}

	// Draw the rotate icon if the player's rotating the mortar
	if ( m_bRotating )
	{
		vgui::Panel *pParent = GetClientModeNormal()->GetViewport();
		int parentWidth, parentHeight;
		pParent->GetSize(parentWidth, parentHeight);
		int iWidth = 64;
		int iHeight = 64;
		int iX = (parentWidth - iWidth) / 2;
		int iY = (parentHeight - 216);

		IMesh* pMesh = materials->GetDynamicMesh( true, NULL, NULL, m_pRotateIcon );

		CMeshBuilder meshBuilder;
		meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

		meshBuilder.Color3f( 1.0, 1.0, 1.0 );
		meshBuilder.TexCoord2f( 0,0,0 );
		meshBuilder.Position3f( iX,iY,0 );
		meshBuilder.AdvanceVertex();

		meshBuilder.Color3f( 1.0, 1.0, 1.0 );
		meshBuilder.TexCoord2f( 0,1,0 );
		meshBuilder.Position3f( iX+iWidth, iY, 0 );
		meshBuilder.AdvanceVertex();

		meshBuilder.Color3f( 1.0, 1.0, 1.0 );
		meshBuilder.TexCoord2f( 0,1,1 );
		meshBuilder.Position3f( iX+iWidth, iY+iHeight, 0 );
		meshBuilder.AdvanceVertex();

		meshBuilder.Color3f( 1.0, 1.0, 1.0 );
		meshBuilder.TexCoord2f( 0,0,1 );
		meshBuilder.Position3f( iX, iY+iHeight, 0 );
		meshBuilder.AdvanceVertex();

		meshBuilder.End();
		pMesh->Draw();
	}

	// Update the ground line if it's moved
	if ( !m_bCarried && (m_flPrevMortarYaw != m_flMortarYaw ) && 
		gpGlobals->curtime > m_flLastGroundlineUpdateTime + g_CVMortarGroundLineUpdateInterval.GetFloat() )
	{
		// Create the Ground line start & end points
		Vector vecForward;
		AngleVectors( QAngle( 0, m_flMortarYaw, 0 ), &vecForward );
		Vector vecStart = m_vecMortarOrigin + (vecForward * MORTAR_RANGE_MIN);

		float flRange = MORTAR_RANGE_MAX_INITIAL;
		if ( pPlayer->HasNamedTechnology( "mortar_range" ) )
			flRange = MORTAR_RANGE_MAX_UPGRADED;
		Vector vecEnd = m_vecMortarOrigin + (vecForward * flRange);

		m_pDarkLine->SetParameters( m_vecMortarOrigin, vecStart, Vector( 0.1,0.1,0.1 ), Vector( 0.1,0.1,0.1 ), 0.5, 22 );
		m_pGroundLine->SetParameters( vecStart, vecEnd, Vector(0,1,0), Vector(1,0,0), 0.5, 22 );

		m_flPrevMortarYaw = m_flMortarYaw;

		m_flLastGroundlineUpdateTime = gpGlobals->curtime;
	}
}
Ejemplo n.º 8
0
void CNB_Vote_Panel::UpdateVoteLabels()
{
	m_pProgressBar->SetPos( YRES( 10 ), YRES( 40 ) );

	// update yes/no press buttons
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	m_pMapNameLabel->SetVisible( true );
	m_pYesVotesLabel->SetVisible( true );
	m_pNoVotesLabel->SetVisible( true );

	m_pTitle->SetText( "#asw_vote_mission_title" );

	if ( pPlayer->m_iMapVoted.Get() == 0 )
	{
		if ( gpGlobals->curtime > m_flCheckBindings )
		{
			Q_snprintf(m_szVoteYesKey, sizeof(m_szVoteYesKey), "%s", ASW_FindKeyBoundTo( "vote_yes" ) );
			Q_strupr(m_szVoteYesKey);
			Q_snprintf(m_szVoteNoKey, sizeof(m_szVoteNoKey), "%s", ASW_FindKeyBoundTo( "vote_no" ) );
			Q_strupr(m_szVoteNoKey);

			m_flCheckBindings += 1.0f;
		}		
		// copy the found key into wchar_t format (localize it if it's a token rather than a normal keyname)
		wchar_t keybuffer[ 12 ];
		wchar_t buffer[64];
		g_pVGuiLocalize->ConvertANSIToUnicode( m_szVoteYesKey, keybuffer, sizeof( keybuffer ) );		
		g_pVGuiLocalize->ConstructString( buffer, sizeof(buffer), g_pVGuiLocalize->Find("#press_to_vote_yes"), 1, keybuffer );
		m_pPressToVoteYesLabel->SetText( buffer );

		g_pVGuiLocalize->ConvertANSIToUnicode( m_szVoteNoKey, keybuffer, sizeof( keybuffer ) );		
		g_pVGuiLocalize->ConstructString( buffer, sizeof(buffer), g_pVGuiLocalize->Find("#press_to_vote_no"), 1, keybuffer );
		m_pPressToVoteNoLabel->SetText( buffer );
	}
	else if ( pPlayer->m_iMapVoted.Get() == 1 )
	{
		m_pPressToVoteYesLabel->SetText( "#asw_you_voted_no" );
		m_pPressToVoteNoLabel->SetText( "" );
	}
	else
	{
		m_pPressToVoteYesLabel->SetText( "#asw_you_voted_yes" );
		m_pPressToVoteNoLabel->SetText( "" );
	}

	// update timer
	/*
	int iSecondsLeft = ASWGameRules()->GetCurrentVoteTimeLeft();
	if (iSecondsLeft != m_iSecondsLeft)
	{
		m_iSecondsLeft = iSecondsLeft;
		char buffer[8];
		Q_snprintf(buffer, sizeof(buffer), "%d", iSecondsLeft);

		wchar_t wnumber[8];
		g_pVGuiLocalize->ConvertANSIToUnicode(buffer, wnumber, sizeof( wnumber ));

		wchar_t wbuffer[96];		
		g_pVGuiLocalize->ConstructString( wbuffer, sizeof(wbuffer),
			g_pVGuiLocalize->Find("#asw_time_left"), 1,
			wnumber);
		m_pCounterLabel->SetText(wbuffer);
	}
	*/
	m_pCounterLabel->SetText( "" );

	// update count and other labels
	if (m_iYesCount != ASWGameRules()->GetCurrentVoteYes())
	{
		m_iYesCount = ASWGameRules()->GetCurrentVoteYes();
		char buffer[8];
		Q_snprintf(buffer, sizeof(buffer), "%d", m_iYesCount);

		wchar_t wnumber[8];
		g_pVGuiLocalize->ConvertANSIToUnicode(buffer, wnumber, sizeof( wnumber ));

		wchar_t wbuffer[96];		
		g_pVGuiLocalize->ConstructString( wbuffer, sizeof(wbuffer),
			g_pVGuiLocalize->Find("#asw_yes_votes"), 1,
			wnumber);
		m_pYesVotesLabel->SetText(wbuffer);
	}
	if (m_iNoCount != ASWGameRules()->GetCurrentVoteNo())
	{
		m_iNoCount = ASWGameRules()->GetCurrentVoteNo();
		char buffer[8];
		Q_snprintf(buffer, sizeof(buffer), "%d", m_iNoCount);

		wchar_t wnumber[8];
		g_pVGuiLocalize->ConvertANSIToUnicode(buffer, wnumber, sizeof( wnumber ));

		wchar_t wbuffer[96];		
		g_pVGuiLocalize->ConstructString( wbuffer, sizeof(wbuffer),
			g_pVGuiLocalize->Find("#asw_no_votes"), 1,
			wnumber);
		m_pNoVotesLabel->SetText(wbuffer);
	}	
	if (Q_strcmp(m_szMapName, ASWGameRules()->GetCurrentVoteDescription()))
	{
		Q_snprintf(m_szMapName, sizeof(m_szMapName), "%s", ASWGameRules()->GetCurrentVoteDescription());

		wchar_t wmapname[64];
		g_pVGuiLocalize->ConvertANSIToUnicode(m_szMapName, wmapname, sizeof( wmapname ));

		wchar_t wbuffer[96];						
		if (ASWGameRules()->GetCurrentVoteType() == ASW_VOTE_CHANGE_MISSION)
		{
			m_pTitle->SetText( "#asw_vote_mission_title" );
			m_bVoteMapInstalled = true;
			if ( missionchooser && missionchooser->LocalMissionSource() )
			{
				if ( !missionchooser->LocalMissionSource()->GetMissionDetails( ASWGameRules()->GetCurrentVoteMapName() ) )
					m_bVoteMapInstalled = false;
			}

			if ( m_bVoteMapInstalled )
			{
				const char *szContainingCampaign = ASWGameRules()->GetCurrentVoteCampaignName();
				if ( !szContainingCampaign || !szContainingCampaign[0] )
				{
					_snwprintf( wbuffer, sizeof( wbuffer ), L"%s", wmapname );
				}
				else
				{
					_snwprintf( wbuffer, sizeof( wbuffer ), L"%s", wmapname );
				}
			}
			else
			{
				g_pVGuiLocalize->ConstructString( wbuffer, sizeof(wbuffer),
					g_pVGuiLocalize->Find("#asw_current_mission_vote_not_installed"), 1,
					wmapname);
			}
		}
		else if (ASWGameRules()->GetCurrentVoteType() == ASW_VOTE_SAVED_CAMPAIGN)
		{
			m_pTitle->SetText( "#asw_vote_saved_title" );
			g_pVGuiLocalize->ConstructString( wbuffer, sizeof(wbuffer),
				g_pVGuiLocalize->Find("#asw_current_saved_vote"), 1,
				wmapname);
		}

		int w, t;
		m_pMapNameLabel->GetSize(w, t);
		if (m_pMapNameLabel->GetTextImage())
			m_pMapNameLabel->GetTextImage()->SetSize(w, t);
		m_pMapNameLabel->SetText(wbuffer);
		m_pMapNameLabel->InvalidateLayout(true);
	}
}
Ejemplo n.º 9
0
void CNB_Mission_Summary::OnThink()
{
	BaseClass::OnThink();

	if ( !ASWGameResource() )
		return;

	int nSkillLevel = ASWGameRules()->GetSkillLevel();
	const wchar_t *pDifficulty = NULL;
	switch( nSkillLevel )
	{
		case 1: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_easy" ); break;
		default:
		case 2: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_normal" ); break;
		case 3: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_hard" ); break;
		case 4: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_insane" ); break;
		case 5: pDifficulty = g_pVGuiLocalize->Find( "#asw_difficulty_imba" ); break;
	}
	if ( !pDifficulty )
	{
		pDifficulty = L"";
	}

	if ( CAlienSwarm::IsOnslaught() )
	{
		wchar_t wszText[ 128 ];
		_snwprintf( wszText, sizeof( wszText ), L"%s %s", pDifficulty, g_pVGuiLocalize->FindSafe( "#nb_onslaught_title" ) );
		m_pDifficultyLabel->SetText( wszText );
	}
	else
	{
		m_pDifficultyLabel->SetText( pDifficulty );
	}

	CASWHudMinimap *pMap = GET_HUDELEMENT( CASWHudMinimap );
	if ( pMap )
	{
		m_pMissionLabel->SetText(pMap->m_szMissionTitle);
	}

	// compose objectives list
	wchar_t wszObjectivesBuffer[ 1024 ];
	wchar_t wszBuffer[ 1024 ];

	wszObjectivesBuffer[ 0 ] = 0;

	int nObjectives = 0;
	for ( int i = 0 ; i < ASW_MAX_OBJECTIVES; i++ )
	{
		C_ASW_Objective* pObjective = ASWGameResource()->GetObjective(i);
		if ( pObjective && !pObjective->IsObjectiveHidden() && !pObjective->IsObjectiveDummy() )
		{
			if ( nObjectives == 0 )
			{
				_snwprintf( wszObjectivesBuffer, sizeof( wszObjectivesBuffer ), L"- %s", pObjective->GetObjectiveTitle() );
			}
			else
			{
				_snwprintf( wszBuffer, sizeof( wszBuffer ), L"%s\n- %s", wszObjectivesBuffer, pObjective->GetObjectiveTitle() );
				_snwprintf( wszObjectivesBuffer , sizeof( wszObjectivesBuffer ), L"%s", wszBuffer );
			}
			nObjectives++;
		}
	}
	m_pObjectivesLabel->SetText( wszObjectivesBuffer );

	int nLabelWidth = YRES( 168 );
	m_pObjectivesLabel->SetSize( nLabelWidth, 400 );
	m_pObjectivesLabel->GetTextImage()->SetDrawWidth( nLabelWidth );
	m_pObjectivesLabel->InvalidateLayout( true );
	int texwide, texttall;	
	m_pObjectivesLabel->GetTextImage()->ResizeImageToContentMaxWidth( nLabelWidth );
	m_pObjectivesLabel->SetWrap( true );
	m_pObjectivesLabel->GetTextImage()->GetContentSize( texwide, texttall );	
	//m_pObjectivesLabel->SetSize( texwide, texttall );
	m_pObjectivesLabel->InvalidateLayout( true );
	m_pObjectivesLabel->GetTextImage()->GetContentSize( texwide, texttall );
	m_pObjectivesLabel->InvalidateLayout( true );
}
Ejemplo n.º 10
0
void ScorePanel::FillGrid()
{
	CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
	SchemeHandle_t hScheme = pSchemes->getSchemeHandle("Scoreboard Text");
	SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text");
	SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text");
	SchemeHandle_t hTinyScheme = pSchemes->getSchemeHandle("Scoreboard Tiny Text");

	Font *sfont = pSchemes->getFont(hScheme);
	Font *tfont = pSchemes->getFont(hTitleScheme);
	Font *smallfont = pSchemes->getFont(hSmallScheme);
	Font *tinyfont = pSchemes->getFont(hTinyScheme);

	// update highlight position
	int x, y;
	getApp()->getCursorPos(x, y);
	cursorMoved(x, y, this);
	
	// remove highlight row if we're not in squelch mode
	if (!GetClientVoiceMgr()->IsInSquelchMode())
	{
		m_iHighlightRow = -1;
	}
	
	bool bNextRowIsGap = false;
	
	for(int row=0; row < NUM_ROWS; row++)
	{
		CGrid *pGridRow = &m_PlayerGrids[row];
		pGridRow->SetRowUnderline(0, false, 0, 0, 0, 0, 0);
		
		if(row >= m_iRows)
		{
			for(int col=0; col < NUM_COLUMNS; col++)
				m_PlayerEntries[col][row].setVisible(false);
			
			continue;
		}
		
		bool bRowIsGap = false;
		if (bNextRowIsGap)
		{
			bNextRowIsGap = false;
			bRowIsGap = true;
		}
		
		// Get the player's data
		int theSortedRow = m_iSortedRows[row];
		hud_player_info_t* pl_info = &g_PlayerInfoList[theSortedRow];
		extra_player_info_t* theExtraPlayerInfo = &g_PlayerExtraInfo[theSortedRow];
		int thePlayerClass = theExtraPlayerInfo->playerclass;
		short theTeamNumber = theExtraPlayerInfo->teamnumber;
		string theCustomIcon = (string)theExtraPlayerInfo->customicon;
// puzl: 0001073
		short thePlayerAuthentication = theExtraPlayerInfo->auth;
		bool thePlayerIsDead = false;
		switch( thePlayerClass )
		{
		case PLAYERCLASS_DEAD_MARINE:
		case PLAYERCLASS_DEAD_ALIEN:
		case PLAYERCLASS_REINFORCING:
			thePlayerIsDead = true;
			break;
		}

		// Code to test DEBUG
#if 0
		#ifdef DEBUG
		extern int gGlobalDebugAuth;
		thePlayerAuthentication = 1;
		thePlayerAuthentication <<= gGlobalDebugAuth;
		#endif
#endif

		team_info_t* team_info = &g_TeamInfo[m_iSortedRows[row]];
		int theColorIndex = theTeamNumber % iNumberOfTeamColors;

        int theLocalPlayerTeam = 0;
        if(gEngfuncs.GetLocalPlayer())
        {
            theLocalPlayerTeam = gEngfuncs.GetLocalPlayer()->curstate.team;
        }
		
		for(int col=0; col < NUM_COLUMNS; col++)
		{
			CLabelHeader *pLabel = &m_PlayerEntries[col][row];

			pLabel->setVisible(true);
			pLabel->setText2("");
			pLabel->setImage(NULL);
			pLabel->setFont(sfont);
			pLabel->setTextOffset(0, 0);
			
			int rowheight = 13;
			if (ScreenHeight() > 480)
			{
				rowheight = YRES(rowheight);
			}
			else
			{
				// more tweaking, make sure icons fit at low res
				rowheight = 15;
			}
			pLabel->setSize(pLabel->getWide(), rowheight);
			pLabel->setBgColor(0, 0, 0, 255);
			
			char sz[128];

			Color gammaAdjustedTeamColor = BuildColor(kTeamColors[theColorIndex][0], kTeamColors[theColorIndex][1], kTeamColors[theColorIndex][2], gHUD.GetGammaSlope());
            pLabel->setFgColor(gammaAdjustedTeamColor[0], gammaAdjustedTeamColor[1], gammaAdjustedTeamColor[2], 0);

			if (m_iIsATeam[row] == TEAM_BLANK)
			{
				pLabel->setText(" ");
				continue;
			}
			else if ( m_iIsATeam[row] == TEAM_YES )
			{
				theColorIndex = team_info->teamnumber % iNumberOfTeamColors;

				// team color text for team names
				
				

				// different height for team header rows
				rowheight = 20;
				if (ScreenHeight() >= 480)
				{
					rowheight = YRES(rowheight);
				}
				pLabel->setSize(pLabel->getWide(), rowheight);
				pLabel->setFont(tfont);

				pGridRow->SetRowUnderline(	0,
											true,
											YRES(3),
											gammaAdjustedTeamColor[0],
											gammaAdjustedTeamColor[1],
											gammaAdjustedTeamColor[2],
											0 );
			}
			else if ( m_iIsATeam[row] == TEAM_SPECTATORS )
			{
				// grey text for spectators
				pLabel->setFgColor(100, 100, 100, 0);

				// different height for team header rows
				rowheight = 20;
				if (ScreenHeight() >= 480)
				{
					rowheight = YRES(rowheight);
				}
				pLabel->setSize(pLabel->getWide(), rowheight);
				pLabel->setFont(tfont);

				pGridRow->SetRowUnderline(0, true, YRES(3), 100, 100, 100, 0);
			}
			else
			{
				if(thePlayerIsDead)
				{
					pLabel->setFgColor(255, 0, 0, 0);
				}
				else
				{
					// team color text for player names
					pLabel->setFgColor(gammaAdjustedTeamColor[0], gammaAdjustedTeamColor[1], gammaAdjustedTeamColor[2], 0);
				}
				
				// Set background color
				if ( pl_info && pl_info->thisplayer ) // if it is their name, draw it a different color
				{
					// Highlight this player
					pLabel->setFgColor(Scheme::sc_white);
					pLabel->setBgColor(gammaAdjustedTeamColor[0], gammaAdjustedTeamColor[1], gammaAdjustedTeamColor[2], 196 );
				}
				else if ( theSortedRow == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime )
				{
					// Killer's name
					pLabel->setBgColor( 255,0,0, 255 - ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) );
				}
			}				

			// Align 
            switch(col)
            {
            case COLUMN_NAME:
            case COLUMN_CLASS:
                pLabel->setContentAlignment( vgui::Label::a_west );
                break;

            case COLUMN_TRACKER:
            case COLUMN_RANK_ICON:
            case COLUMN_VOICE:
                pLabel->setContentAlignment( vgui::Label::a_center );
                break;

            case COLUMN_SCORE:
            case COLUMN_KILLS:
            case COLUMN_DEATHS:
            case COLUMN_LATENCY:
            default:
                pLabel->setContentAlignment( vgui::Label::a_east );
                break;
            }

			// Fill out with the correct data
			strcpy(sz, "");
			if ( m_iIsATeam[row] )
			{
				char sz2[128];

				switch (col)
				{
				case COLUMN_NAME:
					if ( m_iIsATeam[row] == TEAM_SPECTATORS )
					{
						sprintf( sz2, CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) );
					}
					else
					{
						if(team_info)
						{
							sprintf( sz2, gViewPort->GetTeamName(team_info->teamnumber) );
						}
					}

					strcpy(sz, sz2);

					// Append the number of players
					if ( m_iIsATeam[row] == TEAM_YES && team_info)
					{
						if (team_info->players == 1)
						{
							sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player" ) );
						}
						else
						{
							sprintf(sz2, "(%d %s)", team_info->players, CHudTextMessage::BufferedLocaliseTextString( "#Player_plural" ) );
						}

						pLabel->setText2(sz2);
						pLabel->setFont2(smallfont);
					}
					break;
				case COLUMN_VOICE:
					break;
				case COLUMN_CLASS:
					break;
                case COLUMN_SCORE:
                    // Don't show score for enemies unless spectating or in RR
                    if ((m_iIsATeam[row] == TEAM_YES) && team_info && ((theLocalPlayerTeam == 0) || (theLocalPlayerTeam == team_info->teamnumber)))
                        sprintf(sz, "%d",  team_info->score);
                    break;
				case COLUMN_KILLS:
					if ((m_iIsATeam[row] == TEAM_YES) && team_info) 
						sprintf(sz, "%d",  team_info->frags );
					break;
				case COLUMN_DEATHS:
					if ((m_iIsATeam[row] == TEAM_YES) && team_info)
						sprintf(sz, "%d",  team_info->deaths );
					break;
				case COLUMN_LATENCY:
					if ((m_iIsATeam[row] == TEAM_YES) && team_info)
						sprintf(sz, "%d", team_info->ping );
					break;
				default:
					break;
				}
			}
			else
			{
				// Are these stats for an enemy?  Score and other stats shouldn't be drawn for enemies.
				bool theIsForEnemy = false;

				int theLocalPlayerTeam = 0;
				if(gEngfuncs.GetLocalPlayer())
				{
					theLocalPlayerTeam = gEngfuncs.GetLocalPlayer()->curstate.team;
				}

				if((theLocalPlayerTeam != 0) && (theExtraPlayerInfo->teamnumber != theLocalPlayerTeam))
				{
					theIsForEnemy = true;
				}
				
				switch (col)
				{
				case COLUMN_NAME:
					
					if (g_pTrackerUser)
					{
						int playerSlot = m_iSortedRows[row];
						int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot);
						const char *trackerName = g_pTrackerUser->GetUserName(trackerID);
						if (trackerName && *trackerName)
						{
							sprintf(sz, "   (%s)", trackerName);
							pLabel->setText2(sz);
						}
					}
					
					if(pl_info)
					{
						sprintf(sz, "%s  ", pl_info->name);
					}
					break;
				case COLUMN_VOICE:
					sz[0] = 0;
					// in HLTV mode allow spectator to turn on/off commentator voice
					if (pl_info && (!pl_info->thisplayer || gEngfuncs.IsSpectateOnly()))
					{
						GetClientVoiceMgr()->UpdateSpeakerImage(pLabel, theSortedRow);
					}
					break;
				case COLUMN_CLASS:
					// No class for other team's members (unless allied or spectator, and make sure player is on our team)
					strcpy(sz, "");

					if(team_info && ((theLocalPlayerTeam == theTeamNumber) || (gHUD.GetPlayMode() == PLAYMODE_OBSERVER)))
					{
						switch(thePlayerClass)
						{
						case (int)(PLAYERCLASS_DEAD_MARINE):
						case (int)(PLAYERCLASS_DEAD_ALIEN):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassDead));
							break;
						case (int)(PLAYERCLASS_REINFORCING):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassReinforcing));
							break;
						case (int)(PLAYERCLASS_REINFORCINGCOMPLETE):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassReinforcingComplete));
							break;
						case (int)(PLAYERCLASS_ALIVE_JETPACK_MARINE):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassJetpackMarine));
							break;
						case (int)(PLAYERCLASS_ALIVE_HEAVY_MARINE):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassHeavyMarine));
							break;
						case (int)(PLAYERCLASS_COMMANDER):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassCommander));
							break;
						case (int)(PLAYERCLASS_ALIVE_LEVEL1):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel1));
							break;
						case (int)(PLAYERCLASS_ALIVE_LEVEL2):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel2));
							break;
						case (int)(PLAYERCLASS_ALIVE_LEVEL3):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel3));
							break;
						case (int)(PLAYERCLASS_ALIVE_LEVEL4):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel4));
							break;
						case (int)(PLAYERCLASS_ALIVE_LEVEL5):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassLevel5));
							break;
						case (int)(PLAYERCLASS_ALIVE_DIGESTING):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassDigesting));
							break;
						case (int)(PLAYERCLASS_ALIVE_GESTATING):
							sprintf(sz, "%s", CHudTextMessage::BufferedLocaliseTextString(kClassGestating));
							break;
						default:
							break;
						}
					}
					break;
						
				case COLUMN_RANK_ICON:
// puzl: 0001073
#ifdef USE_OLDAUTH
					// Check if we have authority.  Right now these override the tracker icons.  Listed in increasing order of "importance".
					if(thePlayerAuthentication & PLAYERAUTH_CHEATINGDEATH)
					{
						// Red
						pLabel->setImage(m_pCheatingDeathIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pCheatingDeathIcon->setColor(BuildColor(255, 69, 9, gHUD.GetGammaSlope()));
					}
					if(thePlayerAuthentication & PLAYERAUTH_VETERAN)
					{
						// Yellow
						pLabel->setImage(m_pVeteranIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pVeteranIcon->setColor(BuildColor(248, 252, 0, gHUD.GetGammaSlope()));
					}
					if(thePlayerAuthentication & PLAYERAUTH_BETASERVEROP)
					{
						// Whitish
						pLabel->setImage(m_pServerOpIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pServerOpIcon->setColor(BuildColor(220, 220, 220, gHUD.GetGammaSlope()));
					}
					if(thePlayerAuthentication & PLAYERAUTH_CONTRIBUTOR)
					{
						// Light blue
						pLabel->setImage(m_pContribIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pContribIcon->setColor(BuildColor(117, 214, 241, gHUD.GetGammaSlope()));
					}
					if(thePlayerAuthentication & PLAYERAUTH_GUIDE)
					{
						// Magenta
						pLabel->setImage(m_pGuideIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pGuideIcon->setColor(BuildColor(208, 16, 190, gHUD.GetGammaSlope()));
					}
					if(thePlayerAuthentication & PLAYERAUTH_PLAYTESTER)
					{
						// Orange
						pLabel->setImage(m_pPTIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pPTIcon->setColor(BuildColor(255, 167, 54, gHUD.GetGammaSlope()));
					}
					if(thePlayerAuthentication & PLAYERAUTH_DEVELOPER)
					{
						// TSA blue
						pLabel->setImage(m_pDevIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pDevIcon->setColor(BuildColor(100, 215, 255, gHUD.GetGammaSlope()));
					}

					if(thePlayerAuthentication & PLAYERAUTH_SERVEROP)
					{
						// Bright green
						pLabel->setImage(m_pServerOpIcon);
						pLabel->setFgColorAsImageColor(false);
						m_pServerOpIcon->setColor(BuildColor(0, 255, 0, gHUD.GetGammaSlope()));
					}

					// Allow custom icons to override other general icons
					if(thePlayerAuthentication & PLAYERAUTH_CUSTOM)
					{
						if(theCustomIcon != "")
						{
							string theIconName = theCustomIcon.substr(0, strlen(theCustomIcon.c_str()) - 3);
							string theFullCustomIconString = string("gfx/vgui/640_") + theIconName + string(".tga");

							vgui::BitmapTGA *pIcon = GetIconPointer(theCustomIcon);

							//Icon hasnt been loaded, load it now and add it to list of icons.
							if(pIcon == NULL)
							{
								pIcon = vgui_LoadTGANoInvertAlpha(theFullCustomIconString.c_str());

								if(pIcon)
									m_CustomIconList.push_back( make_pair(pIcon, theCustomIcon) );
							}
							
							if(pIcon)
							{
								pLabel->setImage(pIcon);
								pLabel->setFgColorAsImageColor(false);

								// Parse color (last 3 bytes are the RGB values 1-9)
								string theColor = theCustomIcon.substr( strlen(theCustomIcon.c_str())-3, 3);
								int theRed = (MakeIntFromString(theColor.substr(0, 1))/9.0f)*255;
								int theGreen = (MakeIntFromString(theColor.substr(1, 1))/9.0f)*255;
								int theBlue = (MakeIntFromString(theColor.substr(2, 1))/9.0f)*255;

								pIcon->setColor(BuildColor(theRed, theGreen, theBlue, gHUD.GetGammaSlope()));
							}
						}
					}
					
					if(g_pTrackerUser)
					{
						int playerSlot = theSortedRow;
						int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot);

						if (g_pTrackerUser->IsFriend(trackerID) && trackerID != g_pTrackerUser->GetTrackerID())
						{
							pLabel->setImage(m_pTrackerIcon);
							pLabel->setFgColorAsImageColor(false);
							m_pTrackerIcon->setColor(Color(255, 255, 255, 0));
						}
					}
#else
					if( theExtraPlayerInfo->icon )
					{
						vgui::Bitmap* image = theExtraPlayerInfo->icon->getImage( this->GetIconFrame() );
						if( image ) { pLabel->setImage( image ); }
					}
#endif
					break;
                case COLUMN_SCORE:
                    if(!theIsForEnemy)
                    {
                        const float kDeltaDisplayTime = 3.0f;
                        float theTimeSinceChange = gHUD.GetTimeOfLastUpdate() - theExtraPlayerInfo->timeOfLastScoreChange;
                        if((theExtraPlayerInfo->score > theExtraPlayerInfo->lastScore) && (theTimeSinceChange > 0) && (theTimeSinceChange < kDeltaDisplayTime) && (theExtraPlayerInfo->teamnumber != 0))
                        {
                            // draw score with change
                            int theDelta = (theExtraPlayerInfo->score - theExtraPlayerInfo->lastScore);
                            sprintf(sz, "(+%d) %d",  theDelta, theExtraPlayerInfo->score);
                        }
                        else
                        {
                            sprintf(sz, "%d", theExtraPlayerInfo->score);
                        }
                        
                    }
                    break;

				case COLUMN_KILLS:
                    sprintf(sz, "%d", theExtraPlayerInfo->frags);
                    break;

				case COLUMN_DEATHS:
					sprintf(sz, "%d", theExtraPlayerInfo->deaths);
					break;
				case COLUMN_LATENCY:
					if(pl_info)
					{
						sprintf(sz, "%d", pl_info->ping );
					}
					break;
				default:
					break;
				}
			}

            pLabel->setText(sz);
		}
	}

	for(row=0; row < NUM_ROWS; row++)
	{
		CGrid *pGridRow = &m_PlayerGrids[row];

		pGridRow->AutoSetRowHeights();
		pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight());
		pGridRow->RepositionContents();
	}

	// hack, for the thing to resize
	m_PlayerList.getSize(x, y);
	m_PlayerList.setSize(x, y);
}
Ejemplo n.º 11
0
int CHudDeathNotice :: Draw( float flTime )
{
	int x, y, r, g, b;

	for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
	{
		if ( rgDeathNoticeList[i].iId == 0 )
			break;  // we've gone through them all

		if ( rgDeathNoticeList[i].flDisplayTime < flTime )
		{ // display time has expired
			// remove the current item from the list
			memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
			i--;  // continue on the next item;  stop the counter getting incremented
			continue;
		}

		rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );

		// Only draw if the viewport will let me
		if ( gViewPort && gViewPort->AllowedToPrintText() )
		{
			// Draw the death notice
			y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i);  //!!!

			int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId;
			x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);

			if ( !rgDeathNoticeList[i].iSuicide )
			{
				x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );

				// Draw killers name
				if ( rgDeathNoticeList[i].KillerColor )
					gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
				x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
			}

			r = 255;  g = 80;	b = 0;
			if ( rgDeathNoticeList[i].iTeamKill )
			{
				r = 10;	g = 240; b = 10;  // display it in sickly green
			}

			// Draw death weapon
			SPR_Set( gHUD.GetSprite(id), r, g, b );
			SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );

			x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);

			// Draw victims name (if it was a player that was killed)
			if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
			{
				if ( rgDeathNoticeList[i].VictimColor )
					gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
				x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
			}
		}
	}

	return 1;
}
Ejemplo n.º 12
0
//-----------------------------------------------------------------------------
// Purpose: Draw function for the element
//-----------------------------------------------------------------------------
void CTargetID::Paint()
{
	// No id if still choosing class
	if ( C_BaseTFPlayer::GetLocalPlayer()->GetClass() == TFCLASS_UNDECIDED )
		return;

	// Get our target's ent index
	int iEntIndex = C_BaseTFPlayer::GetLocalPlayer()->GetIDTarget();
	// Didn't find one?
	if ( !iEntIndex )
	{
		// Check to see if we should clear our ID
		if ( m_flLastChangeTime && (gpGlobals->curtime > (m_flLastChangeTime + 0.5)) )
		{
			m_flLastChangeTime = 0;
			m_sIDString[0] = 0;
			m_iLastEntIndex = 0;
		}
		else
		{
			// Keep re-using the old one
			iEntIndex = m_iLastEntIndex;
		}
	}
	else
	{
		m_flLastChangeTime = gpGlobals->curtime;
	}

	// Is this an entindex sent by the server?
	if ( iEntIndex )
	{
		C_BaseTFPlayer *pPlayer = static_cast<C_BaseTFPlayer*>(cl_entitylist->GetEnt( iEntIndex ));
		C_BaseTFPlayer *pLocalPlayer = C_BaseTFPlayer::GetLocalPlayer();

		// Some entities we always want to check, cause the text may change
		// even while we're looking at it
		// Is it a player?
		if ( IsPlayerIndex( iEntIndex ) )
		{
			if ( pPlayer->InSameTeam(pLocalPlayer) )
			{
				// Check distance to other player, and if the player is on the same team
				float flDistSq = pPlayer->GetRenderOrigin().DistToSqr( pLocalPlayer->GetRenderOrigin() );
				if ( flDistSq < PLAYER_HINT_DISTANCE_SQ )
				{
					Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nHealth: %.0f percent\nUse to donate resources",
						pPlayer->GetPlayerName(), ((float)pPlayer->GetHealth() / (float)pPlayer->GetMaxHealth() ) * 100 );
				}
				else
				{
					Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nHealth: %.0f percent",
						pPlayer->GetPlayerName(), ((float)pPlayer->GetHealth() / (float)pPlayer->GetMaxHealth() ) * 100 );
				}
			}
			else if (( pPlayer->GetHealth() == 0) && (pLocalPlayer->GetClass() == TFCLASS_INFILTRATOR) )
			{
				Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nUse to disguise as this player", pPlayer->GetPlayerName() );
			}
			else
			{
				m_sIDString[0] = 0;
				m_iLastEntIndex = 0;
			}
		}
		else
		{
			// Objects
			C_BaseEntity *pEnt = cl_entitylist->GetEnt( iEntIndex );
			if ( !pEnt || !pEnt->InSameTeam(pLocalPlayer) )
			{
				// This can happen because the object was destroyed
				m_sIDString[0] = 0;
				m_iLastEntIndex = 0;
			}
			else
			{
				// Don't check validity if it's sent by the server
				Q_strncpy( m_sIDString, pEnt->GetIDString(), sizeof(m_sIDString) );
				m_iLastEntIndex = iEntIndex;
			}
		}
	}

	// Draw our ID string
	if ( m_sIDString[0] )
	{
		int width, height;
		int ypos = YRES(300);

		// Messagechars can't handle multiple line strings, so parse out the \n's and give it one line at a time
		char *ch = m_sIDString;
		while ( *ch )
		{
			// Find the next newline
			char *next_line;
			for ( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ )
			{
			}

			// Stomp the newline
			char *top = next_line;
			if ( *top == '\n' )
			{
				*top = 0;
			}
			else
			{
				top = NULL;
			}

			// Draw the line
			messagechars->GetStringLength( m_hFont, &width, &height, ch );
			messagechars->DrawString( m_hFont, (ScreenWidth() - width) / 2, ypos, 255, 255, 245, 255, ch, IMessageChars::MESSAGESTRINGID_NONE );

			ypos += height;

			// Restore the newline
			if ( top ) 
			{
				*top = '\n';
			}

			// Move to the next line
			ch = next_line;
			if ( *ch == '\n' )
			{
				ch++;
			}
		}
	}
}
Ejemplo n.º 13
0
//-----------------------------------------------------------------------------
// Purpose: Constructs a message panel
//-----------------------------------------------------------------------------
CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iShadeFullscreen ? 100 : 255, iRemoveMe, x, y, wide, tall )
{
	// Get the scheme used for the Titles
	CSchemeManager *pSchemes = gViewPort->GetSchemeManager();

	// schemes
	SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
	SchemeHandle_t hMOTDText = pSchemes->getSchemeHandle( "Briefing Text" );

	// color schemes
	int r, g, b, a;

	// Create the window
	m_pBackgroundPanel = new CTransparentPanel( iShadeFullscreen ? 255 : 100, MOTD_WINDOW_X, MOTD_WINDOW_Y, MOTD_WINDOW_SIZE_X, MOTD_WINDOW_SIZE_Y );
	m_pBackgroundPanel->setParent( this );
	m_pBackgroundPanel->setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) );
	m_pBackgroundPanel->setVisible( true );

	int iXSize,iYSize,iXPos,iYPos;
	m_pBackgroundPanel->getPos( iXPos,iYPos );
	m_pBackgroundPanel->getSize( iXSize,iYSize );

	// Create the title
	Label *pLabel = new Label( "", iXPos + MOTD_TITLE_X, iYPos + MOTD_TITLE_Y );
	pLabel->setParent( this );
	pLabel->setFont( pSchemes->getFont(hTitleScheme) );
	pLabel->setFont( Scheme::sf_primary1 );

	pSchemes->getFgColor( hTitleScheme, r, g, b, a );
	pLabel->setFgColor( r, g, b, a );
	pLabel->setFgColor( Scheme::sc_primary1 );
	pSchemes->getBgColor( hTitleScheme, r, g, b, a );
	pLabel->setBgColor( r, g, b, a );
	pLabel->setContentAlignment( vgui::Label::a_west );
	pLabel->setText( "%s", szTitle);

	// Create the Scroll panel
	ScrollPanel *pScrollPanel = new CTFScrollPanel( iXPos + XRES(16), iYPos + MOTD_TITLE_Y*2 + YRES(16), iXSize - XRES(32), iYSize - (YRES(48) + BUTTON_SIZE_Y*2) );
	pScrollPanel->setParent(this);
	
	//force the scrollbars on so clientClip will take them in account after the validate
	pScrollPanel->setScrollBarAutoVisible(false, false);
	pScrollPanel->setScrollBarVisible(true, true);
	pScrollPanel->validate();

	// Create the text panel
	TextPanel *pText = new TextPanel( "", 0,0, 64,64);
	pText->setParent( pScrollPanel->getClient() );

	// get the font and colors from the scheme
	pText->setFont( pSchemes->getFont(hMOTDText) );
	pSchemes->getFgColor( hMOTDText, r, g, b, a );
	pText->setFgColor( r, g, b, a );
	pSchemes->getBgColor( hMOTDText, r, g, b, a );
	pText->setBgColor( r, g, b, a );
	pText->setText( szMOTD);

	// Get the total size of the MOTD text and resize the text panel
	int iScrollSizeX, iScrollSizeY;

	// First, set the size so that the client's wdith is correct at least because the
	//  width is critical for getting the "wrapped" size right.
	// You'll see a horizontal scroll bar if there is a single word that won't wrap in the
	//  specified width.
	pText->getTextImage()->setSize(pScrollPanel->getClientClip()->getWide(), pScrollPanel->getClientClip()->getTall());
	pText->getTextImage()->getTextSizeWrapped( iScrollSizeX, iScrollSizeY );
	
	// Now resize the textpanel to fit the scrolled size
	pText->setSize( iScrollSizeX , iScrollSizeY );

	//turn the scrollbars back into automode
	pScrollPanel->setScrollBarAutoVisible(true, true);
	pScrollPanel->setScrollBarVisible(false, false);

	pScrollPanel->validate();

	CommandButton *pButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_OK" ), iXPos + XRES(16), iYPos + iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
	pButton->addActionSignal(new CMenuHandler_TextWindow(HIDE_TEXTWINDOW));
	pButton->setParent(this);

}
Ejemplo n.º 14
0
void CHudLensFlare :: DrawLight ( void )
{
	// hud éteint
	if ( ! (m_iFlags & HUD_ACTIVE))
		return;

	// initialisation triapi

	int modelindex;
	struct model_s *mod = gEngfuncs.CL_LoadModel( FLASH_SPR , &modelindex );
	gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)mod, 0 );	

	gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );					//mode de transparence
	gEngfuncs.pTriAPI->CullFace( TRI_NONE );						//(des)activer le face culling
	gEngfuncs.pTriAPI->Brightness( 0.15 );						
	gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 0.75, 0.5 );

	vec3_t v_forward, v_right, v_up, vertex;
	AngleVectors ( v_angles, v_forward, v_right, v_up );


	gruntlight_t *p = m_pLight;

	while ( p != NULL )
	{
		
		cl_entity_t *ent = gEngfuncs.GetEntityByIndex( p->index );

		// vecteurs

		// attach 0 : muzzleflash
		// attach 1 : right hand

		vec3_t vecOrigin = ent->attachment[2];
		vec3_t vecDirFlash = ( ent->attachment[3] - ent->attachment[2] ).Normalize();

		pmtrace_t tr = *( gEngfuncs.PM_TraceLine( vecOrigin, vecOrigin+vecDirFlash*256, PM_WORLD_ONLY, 2, 1 ) );


/*		pmtrace_t tr;
		gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
		gEngfuncs.pEventAPI->EV_PlayerTrace( vecOrigin, vecOrigin+vecDirFlash*256, PM_WORLD_ONLY, -1, &tr );					
*/
	
		gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES );							//démarrage du tracé, en mode triangles .

			gEngfuncs.pTriAPI->TexCoord2f( 0.5, 1 );
			vertex = vecOrigin;
			gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

			gEngfuncs.pTriAPI->TexCoord2f( 0, 1-tr.fraction );
			vertex = vecOrigin + vecDirFlash*256*tr.fraction + v_up * 12*tr.fraction;
			gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

			gEngfuncs.pTriAPI->TexCoord2f( 1, 1-tr.fraction );
			vertex = vecOrigin + vecDirFlash*256*tr.fraction - v_up * 12*tr.fraction;
			gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );


		gEngfuncs.pTriAPI->End();									//fin du tracé

		p = p->pNext;

	}

	// ----------- lens flare-----------

	p = m_pLight;

	while ( p != NULL )
	{
		cl_entity_t *ent = gEngfuncs.GetEntityByIndex( p->index );

		vec3_t vecOrigin = ent->attachment[3];
		vec3_t vecDirFlash = ( ent->attachment[3] - ent->attachment[2] ).Normalize();
		vec3_t vecScrPos;

		// test de présence à l'écran

		if ( gEngfuncs.pTriAPI->WorldToScreen ( vecOrigin, vecScrPos ) )
		{
			p = p->pNext;
			continue;
		}

		vecScrPos [0] = XPROJECT ( vecScrPos [0] );
		vecScrPos [1] = YPROJECT ( vecScrPos [1] );

		if ( vecScrPos[0] < XRES(-10) || vecScrPos[0] > XRES(650) || vecScrPos[1] < YRES(-10) || vecScrPos[1] > YRES(490) )
		{
			p = p->pNext;
			continue;
		}

		// test de direction

		vec3_t vecAngFlash, vecAngDelta;
		VectorAngles ( -vecDirFlash, vecAngFlash );
		VectorAngles ( ((vecOrigin-v_origin).Normalize()), vecAngDelta );

		float flDifX = (float)fabs( (int)(vecAngFlash.x-vecAngDelta.x)%360 );
		flDifX = flDifX > 180 ? flDifX - 360 : flDifX;
		flDifX = flDifX < -180 ? flDifX + 360 : flDifX;

		float flDifY = (float)fabs( (int)(vecAngDelta.y-vecAngFlash.y)%360 );
		flDifY = flDifY > 180 ? flDifY - 360 : flDifY;
		flDifY = flDifY < -180 ? flDifY + 360 : flDifY;

		if ( fabs( flDifX ) > 45 ||	fabs( flDifY ) > 45 )
		{
			p = p->pNext;
			continue;
		}


		// test de visibilité

		pmtrace_t tr = *( gEngfuncs.PM_TraceLine( v_origin, vecOrigin, PM_TRACELINE_ANYVISIBLE, 2, 1 ) );

		if ( tr.fraction != 1.0 )
		{
			p = p->pNext;
			continue;
		}

		// brillance - position sur l'écran

		float brightnessratio = 1;

		float pixelDist = sqrt ( (vecScrPos[0]-XRES(320))*(vecScrPos[0]-XRES(320))
								+(vecScrPos[1]-YRES(240))*(vecScrPos[1]-YRES(240)) );

		float maxdist = sqrt ( XRES(330)*XRES(330) + YRES(250)*YRES(250) );

		brightnessratio *= pixelDist < XRES(80) ? 1.2 : 1.2 * ( 1 - (pixelDist-XRES(80)) / (maxdist-XRES(80)));


		// brillance - angle

		brightnessratio *= fabs( flDifY ) < 25 ? 1 : 1 - ( (fabs(flDifY)-25)/20 );
		brightnessratio *= fabs( flDifX ) < 25 ? 1 : 1 - ( (fabs(flDifX)-25)/20 );

		
		
		// affichage

		vec3_t	vecFlareOrg = v_origin + (vecOrigin - v_origin).Normalize()*10;
		vec3_t	vecFlareEnd = v_origin + v_forward*10;
		vec3_t	flUnit		= (vecFlareEnd - vecFlareOrg) / 100;

		for ( int i=0; i<MAX_FLARE; i++ )
		{
			// initialisation triapi

			mod = gEngfuncs.CL_LoadModel( lensflare_spritename[i] , &modelindex );
			gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)mod, 0 );	

			gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );					//mode de transparence
			gEngfuncs.pTriAPI->CullFace( TRI_NONE );						//(des)activer le face culling
			gEngfuncs.pTriAPI->Brightness( 200 );						
			gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0/*0.75*/, (float)((float)lensflare_spritevars[i][2] / 256.0f) * brightnessratio );

			vec3_t pos = vecFlareOrg + flUnit * lensflare_spritevars[i][0];
			vec3_t vertex;

			gEngfuncs.pTriAPI->Begin( TRI_QUADS );							//démarrage du tracé, en mode quads .

				gEngfuncs.pTriAPI->TexCoord2f( 0,0 );
				vertex = pos + v_up * lensflare_spritevars[i][1] / 20 - v_right * lensflare_spritevars[i][1] / 20;
				gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

				gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
				vertex = pos + v_up * lensflare_spritevars[i][1] / 20 + v_right * lensflare_spritevars[i][1] / 20;
				gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

				gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
				vertex = pos - v_up * lensflare_spritevars[i][1] / 20 + v_right * lensflare_spritevars[i][1] / 20;
				gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

				gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
				vertex = pos - v_up * lensflare_spritevars[i][1] / 20 - v_right * lensflare_spritevars[i][1] / 20;
				gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );


			gEngfuncs.pTriAPI->End();									//fin du tracé

		}

		// flash blanc

		// initialisation triapi

		mod = gEngfuncs.CL_LoadModel( "sprites/lensflare05.spr" , &modelindex );
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)mod, 0 );	

		gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );					//mode de transparence
		gEngfuncs.pTriAPI->CullFace( TRI_NONE );						//(des)activer le face culling
		gEngfuncs.pTriAPI->Brightness( 200 );						
		gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, (float)(220.0f / 256.0f) * brightnessratio );

		vec3_t pos = vecOrigin + vecDirFlash * 2;
		vec3_t vertex;

		gEngfuncs.pTriAPI->Begin( TRI_QUADS );							//démarrage du tracé, en mode quads .

			gEngfuncs.pTriAPI->TexCoord2f( 0,0 );
			vertex = pos + v_up * FLASH_BLANC_SIZE - v_right * FLASH_BLANC_SIZE;
			gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

			gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
			vertex = pos + v_up * FLASH_BLANC_SIZE + v_right * FLASH_BLANC_SIZE;
			gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

			gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
			vertex = pos - v_up * FLASH_BLANC_SIZE + v_right * FLASH_BLANC_SIZE;
			gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );

			gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
			vertex = pos - v_up * FLASH_BLANC_SIZE - v_right * FLASH_BLANC_SIZE;
			gEngfuncs.pTriAPI->Vertex3f( vertex.x, vertex.y, vertex.z );


		gEngfuncs.pTriAPI->End();									//fin du tracé






		p = p->pNext;
	}


}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFFreezePanel::FireGameEvent( IGameEvent * event )
{
	const char *pEventName = event->GetName();

	if ( Q_strcmp( "player_death", pEventName ) == 0 )
	{
		// see if the local player died
		int iPlayerIndexVictim = engine->GetPlayerForUserID( event->GetInt( "userid" ) );
		C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
		if ( pLocalPlayer && iPlayerIndexVictim == pLocalPlayer->entindex() )
		{
			// the local player is dead, see if this is a new nemesis or a revenge
			if ( event->GetInt( "dominated" ) > 0 )
			{
				m_iShowNemesisPanel = SHOW_NEW_NEMESIS;
			}
			else if ( event->GetInt( "revenge" ) > 0 )
			{
				m_iShowNemesisPanel = SHOW_REVENGE;
			}
			else
			{
				m_iShowNemesisPanel = SHOW_NO_NEMESIS;
			}
		}		
	}
	else if ( Q_strcmp( "hide_freezepanel", pEventName ) == 0 )
	{
		Hide();
	}
	else if ( Q_strcmp( "freezecam_started", pEventName ) == 0 )
	{
		ShowCalloutsIn( 1.0 );
		ShowSnapshotPanelIn( 1.25 );
	}
	else if ( Q_strcmp( "teamplay_win_panel", pEventName ) == 0 )
	{
		Hide();
	}
	else if ( Q_strcmp( "show_freezepanel", pEventName ) == 0 )
	{
		C_TF_PlayerResource *tf_PR = dynamic_cast<C_TF_PlayerResource *>(g_PR);
		if ( !tf_PR )
		{
			m_pNemesisSubPanel->SetDialogVariable( "nemesisname", NULL );
			return;
		}

		Show();

		ShowSnapshotPanel( false );
		m_bHoldingAfterScreenshot = false;

		if ( m_iBasePanelOriginalX > -1 && m_iBasePanelOriginalY > -1 )
		{
			m_pBasePanel->SetPos( m_iBasePanelOriginalX, m_iBasePanelOriginalY );
		}

		// Get the entity who killed us
		m_iKillerIndex = event->GetInt( "killer" );
		C_BaseEntity *pKiller =  ClientEntityList().GetBaseEntity( m_iKillerIndex );

		int xp,yp;
		GetPos( xp, yp );
		if ( TFGameRules()->RoundHasBeenWon() )
		{
			SetPos( xp, m_iYBase - YRES(50) );
		}
		else
		{
			SetPos( xp, m_iYBase );
		}

		if ( pKiller )
		{
			CTFPlayer *pPlayer = ToTFPlayer ( pKiller );
			int iMaxBuffedHealth = 0;

			if ( pPlayer )
			{
				iMaxBuffedHealth = pPlayer->m_Shared.GetMaxBuffedHealth();
			}

			int iKillerHealth = pKiller->GetHealth();
			if ( !pKiller->IsAlive() )
			{
				iKillerHealth = 0;
			}
			m_pKillerHealth->SetHealth( iKillerHealth, pKiller->GetMaxHealth(), iMaxBuffedHealth );

			if ( pKiller->IsPlayer() )
			{
				C_TFPlayer *pVictim = C_TFPlayer::GetLocalTFPlayer();
				CTFPlayer *pTFKiller = ToTFPlayer( pKiller );

				//If this was just a regular kill but this guy is our nemesis then just show it.
				if ( pVictim && pTFKiller && pTFKiller->m_Shared.IsPlayerDominated( pVictim->entindex() ) )
				{
					if ( !pKiller->IsAlive() )
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Nemesis_Dead" );
					}
					else
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Nemesis" );
					}
				}
				else
				{
					if ( !pKiller->IsAlive() )
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Killer_Dead" );
					}
					else
					{
						m_pFreezeLabel->SetText( "#FreezePanel_Killer" );
					}
				}

				m_pBasePanel->SetDialogVariable( "killername", g_PR->GetPlayerName( m_iKillerIndex ) );

				if ( m_pAvatar )
				{
					m_pAvatar->SetPlayer( (C_BasePlayer*)pKiller );
				}
			}
			else if ( pKiller->IsBaseObject() )
			{
				C_BaseObject *pObj = assert_cast<C_BaseObject *>( pKiller );
				C_TFPlayer *pOwner = pObj->GetOwner();

				Assert( pOwner && "Why does this object not have an owner?" );

				if ( pOwner )
				{
					m_iKillerIndex = pOwner->entindex();

					m_pBasePanel->SetDialogVariable( "killername", g_PR->GetPlayerName( m_iKillerIndex ) );

					if ( m_pAvatar )
					{
						m_pAvatar->SetPlayer( pOwner );
					}

					pKiller = pOwner;
				}

				if ( m_pFreezeLabel )
				{
					if ( pKiller && !pKiller->IsAlive() )
					{
						m_pFreezeLabel->SetText( "#FreezePanel_KillerObject_Dead" );
					}
					else
					{
						m_pFreezeLabel->SetText( "#FreezePanel_KillerObject" );
					}
				}
				const char *pszStatusName = pObj->GetStatusName();
				wchar_t *wszLocalized = g_pVGuiLocalize->Find( pszStatusName );

				if ( !wszLocalized )
				{
					m_pBasePanel->SetDialogVariable( "objectkiller", pszStatusName );
				}
				else
				{
					m_pBasePanel->SetDialogVariable( "objectkiller", wszLocalized );
				}
			}
			else if ( m_pFreezeLabel )
			{
				if ( !pKiller->IsAlive() )
				{
					m_pFreezeLabel->SetText( "#FreezePanel_Killer_Dead" );
				}
				else
				{
					m_pFreezeLabel->SetText( "#FreezePanel_Killer" );
				}
			}
		}
		
		// see if we should show nemesis panel
		const wchar_t *pchNemesisText = NULL;
		switch ( m_iShowNemesisPanel )
		{
		case SHOW_NO_NEMESIS:
			{
				C_TFPlayer *pVictim = C_TFPlayer::GetLocalTFPlayer();
				CTFPlayer *pTFKiller = ToTFPlayer( pKiller );
			
				//If this was just a regular kill but this guy is our nemesis then just show it.
				if ( pTFKiller && pTFKiller->m_Shared.IsPlayerDominated( pVictim->entindex() ) )
				{					
					pchNemesisText = g_pVGuiLocalize->Find( "#TF_FreezeNemesis" );
				}	
			}
			break;
		case SHOW_NEW_NEMESIS:
			{
				C_TFPlayer *pVictim = C_TFPlayer::GetLocalTFPlayer();
				CTFPlayer *pTFKiller = ToTFPlayer( pKiller );
				// check to see if killer is still the nemesis of victim; victim may have managed to kill him after victim's
				// death by grenade or some such, extracting revenge and clearing nemesis condition
				if ( pTFKiller && pTFKiller->m_Shared.IsPlayerDominated( pVictim->entindex() ) )
				{					
					pchNemesisText = g_pVGuiLocalize->Find( "#TF_NewNemesis" );
				}			
			}
			break;
		case SHOW_REVENGE:
			pchNemesisText = g_pVGuiLocalize->Find( "#TF_GotRevenge" );
			break;
		default:
			Assert( false );	// invalid value
			break;
		}
		m_pNemesisSubPanel->SetDialogVariable( "nemesisname", pchNemesisText );

		ShowNemesisPanel( NULL != pchNemesisText );
		m_iShowNemesisPanel = SHOW_NO_NEMESIS;
	}
}
Ejemplo n.º 16
0
int CHudHealth::Draw(float flTime)
{
	int r = 0, g = 0, b = 0;
	int x = 0, y = 0;
	int iDraw = 0;

	if ( gHUD.m_iHideHUDDisplay & (HIDEHUD_ALL) )
		return 1;

	if(g_iTeamNumber == UNDEFINED || g_iTeamNumber == SPECS )
	{
		gHUD.m_iHideHUDDisplay |= HIDEHUD_HEALTH;
		return 1;
	}

	if(g_iUser1 != 0)
		return 1;

	m_flHealth = g_flHealth;

	if ( !m_hSprite )
		m_hSprite = LoadSprite(PAIN_NAME);

	//hocked on here as this is a good palce as they are related.
	if(IEngineStudio.IsHardware())
		iDraw = gBackground.Draw(flTime);

	if(iDraw == 0)
	{
		gHUD.m_iHideHUDDisplay |= HIDEHUD_HEALTH;
		return 1;
	}
	else
	{
		gHUD.m_iHideHUDDisplay &= ~HIDEHUD_HEALTH;
	}

	gStamina.Draw(flTime);

	if(ScreenWidth >= 640)
		gMiddle.Draw(flTime);
	gHintBox.Draw(flTime);

	UnpackRGB(r, g, b, RGB_WHITEISH);

	HSPRITE m_hSprite = gHUD.GetSprite( m_HUD_health );
	wrect_t *m_SpriteArea = &gHUD.GetSpriteRect( m_HUD_health );

	int x_length, y_length;      // positions of the spots

	y_length = gHUD.GetSpriteRect(m_HUD_health).bottom - gHUD.GetSpriteRect(m_HUD_health).top;
	x_length = gHUD.GetSpriteRect(m_HUD_health).right - gHUD.GetSpriteRect(m_HUD_health).left;

	if(ScreenWidth >= 640)
		x = 5;
	else
		x = 2;	

	y = (YRES(480) - (y_length + ((ScreenWidth >= 640) ? 5 : 3)));

	if(!IEngineStudio.IsHardware())
	{
		UnpackRGB(r, g, b, RGB_WHITEISH);
		gStamina.Draw(flTime);
			
		if(ScreenWidth >= 640)
			x = 5;
		else
			x = 2;	

		y = (YRES(480) - (20 + ((ScreenWidth >= 640) ? 5 : 3)));		

		gHUD.DrawHudNumber(x, y, DHN_2DIGITS | DHN_DRAWZERO, m_flHealth, r, g, b);
		return 1;
	}

	SPR_Set(m_hSprite, r, g, b);

	int iClipLevel = (y_length - ((m_flHealth * y_length) / MAX_HEALTH));
	//clipper starts at the clipping level. its height is the full amount of health take away the mamount clipped
	SPR_EnableScissor(x, y+iClipLevel, 24 , y_length-iClipLevel);
	SPR_DrawHoles(0, x, y, m_SpriteArea);
	SPR_DisableScissor();

	DrawDamage(flTime);
	return DrawPain(flTime);
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDHudAmmo::PaintMGAmmo( CWeaponDODBase *pWpn )
{
    int panelX, panelY, panelW, panelT;
    GetBounds( panelX, panelY, panelW, panelT );

    const CHudTexture *pFullClip = pWpn->GetSpriteAmmo();
    const CHudTexture *pExtraClip = pWpn->GetSpriteAmmo2();

    Assert( pFullClip );
    Assert( pExtraClip );

    int xpos = 0, ypos = 0;
    int nIconWidth = 0, nIconHeight = 0;
    float scale = 1.0f;

    if ( pFullClip )
    {
        nIconWidth = pFullClip->Width();
        nIconHeight = pFullClip->Height();

        xpos = large_icon_xpos;
        ypos = large_icon_ypos;

        scale = GetScale( nIconWidth, nIconHeight, large_icon_width, large_icon_height );

        nIconWidth *= scale;
        nIconHeight *= scale;

        if ( nIconWidth < large_icon_width - XRES(2) ) // 2 is our buffer for when we need to re-calculate the xpos
        {
            xpos = small_icon_xpos + small_icon_width / 2.0 - nIconWidth / 2.0;
        }

        if ( nIconHeight < large_icon_height - YRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            ypos = small_icon_ypos + small_icon_height / 2.0 - nIconHeight / 2.0;
        }

        pFullClip->DrawSelf( xpos, ypos, nIconWidth, nIconHeight, m_clrIcon );

        char buf[16];
        Q_snprintf( buf, sizeof(buf), "%d", m_iAmmo );
        DrawText( buf, xpos + nIconWidth - ( (float)nIconWidth / 3.0 ), ypos + nIconHeight - ( (float)nIconHeight / 3.0 ), m_clrTextColor );
    }

    //how many full or partially full clips do we have?
    int clips = m_iAmmo2 / pWpn->GetMaxClip1();

    //account for the partial clip, if it exists
    if( clips * pWpn->GetMaxClip1() < m_iAmmo2 )
    {
        clips++;
    }

    if( clips > 0 && pExtraClip )
    {
        //align the extra clip on the same baseline as the large clip
        xpos = extra_clip_xpos;
        ypos = extra_clip_ypos;

        nIconWidth = pExtraClip->Width();
        nIconHeight = pExtraClip->Height();

        if ( nIconWidth > extra_clip_width || nIconHeight > extra_clip_height )
        {
            scale = GetScale( nIconWidth, nIconHeight, extra_clip_width, extra_clip_height );
            nIconWidth *= scale;
            nIconHeight *= scale;
        }

        if ( nIconWidth < extra_clip_width - XRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            xpos = extra_clip_xpos + extra_clip_width / 2.0 - nIconWidth / 2.0;
        }

        if ( nIconHeight < extra_clip_height - YRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            ypos = extra_clip_ypos + extra_clip_height / 2.0 - nIconHeight / 2.0;
        }

        pExtraClip->DrawSelf( xpos, ypos, pExtraClip->Width() * scale, pExtraClip->Height() * scale, m_clrIcon );
        DrawAmmoCount( clips );
    }
}
void C_PropVehicleDriveable::DrawHudElements( )
{
	CHudTexture *pIcon;
	int iIconX, iIconY;

	if (m_bHasGun)
	{
		// draw crosshairs for vehicle gun
		pIcon = gHUD.GetIcon( "gunhair" );

		if ( pIcon != NULL )
		{
			float x, y;

			if( UseVR() )
			{
				C_BasePlayer *pPlayer = (C_BasePlayer *)GetPassenger( VEHICLE_ROLE_DRIVER );
				Vector vecStart, vecDirection;
				pPlayer->EyePositionAndVectors( &vecStart, &vecDirection, NULL, NULL );
				Vector vecEnd = vecStart + vecDirection * MAX_TRACE_LENGTH;

				trace_t tr;
				UTIL_TraceLine( vecStart, vecEnd, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr );

				Vector screen;
				screen.Init();
				ScreenTransform(tr.endpos, screen);

				int vx, vy, vw, vh;
				vgui::surface()->GetFullscreenViewport( vx, vy, vw, vh );

				float screenWidth = vw;
				float screenHeight = vh;

				x = 0.5f * ( 1.0f + screen[0] ) * screenWidth + 0.5f;
				y = 0.5f * ( 1.0f - screen[1] ) * screenHeight + 0.5f;
			}
			else
			{
				Vector screen;

				x = ScreenWidth()/2;
				y = ScreenHeight()/2;

#if TRIANGULATED_CROSSHAIR
				ScreenTransform( m_vecGunCrosshair, screen );
				x += 0.5 * screen[0] * ScreenWidth() + 0.5;
				y -= 0.5 * screen[1] * ScreenHeight() + 0.5;
#endif
			}


			x -= pIcon->Width() / 2; 
			y -= pIcon->Height() / 2; 
			
			Color	clr = ( m_bUnableToFire ) ? gHUD.m_clrCaution : gHUD.m_clrNormal;
			pIcon->DrawSelf( x, y, clr );
		}

		if ( m_nScannerDisabledWeapons )
		{
			// Draw icons for scanners "weps disabled"  
			pIcon = gHUD.GetIcon( "dmg_bio" );
			if ( pIcon )
			{
				iIconY = 467 - pIcon->Height() / 2;
				iIconX = 385;
				if ( !m_bScannerWepIcon )
				{
					pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, 255, 255 ) );
					m_bScannerWepIcon = true;
					m_iScannerWepFlashTimer = 0;
					m_bScannerWepDim = true;
				}
				else
				{
					pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, GetFlashColorIntensity(55, 255, m_bScannerWepDim, 10, m_iScannerWepFlashTimer), 255 ) );
					m_iScannerWepFlashTimer++;
					m_iScannerWepFlashTimer %= 20;
					if(!m_iScannerWepFlashTimer)
						m_bScannerWepDim ^= 1;
				}
			}
		}
	}

	if ( m_nScannerDisabledVehicle )
	{
		// Draw icons for scanners "vehicle disabled"  
		pIcon = gHUD.GetIcon( "dmg_bio" );
		if ( pIcon )
		{
			iIconY = 467 - pIcon->Height() / 2;
			iIconX = 410;
			if ( !m_bScannerVehicleIcon )
			{
				pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, 255, 255 ) );
				m_bScannerVehicleIcon = true;
				m_iScannerVehicleFlashTimer = 0;
				m_bScannerVehicleDim = true;
			}
			else
			{
				pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, GetFlashColorIntensity(55, 255, m_bScannerVehicleDim, 10, m_iScannerVehicleFlashTimer), 255 ) );
				m_iScannerVehicleFlashTimer++;
				m_iScannerVehicleFlashTimer %= 20;
				if(!m_iScannerVehicleFlashTimer)
					m_bScannerVehicleDim ^= 1;
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDHudAmmo::PaintGunAmmo( CWeaponDODBase *pWpn )
{
    int panelX, panelY, panelW, panelT;
    GetBounds( panelX, panelY, panelW, panelT );

    //regular gun
    const CHudTexture *pEmptyClip = pWpn->GetSpriteAmmo();
    const CHudTexture *pFullClip = pWpn->GetSpriteAmmo2();
    const CHudTexture *pExtraClip = pWpn->GetSpriteAutoaim();

    Assert( pEmptyClip );
    Assert( pFullClip );
    Assert( pExtraClip );

    int xpos = 0, ypos = 0;
    int nIconWidth = 0, nIconHeight = 0;
    float scale = 1.0f;

    if ( pFullClip && pEmptyClip )
    {
        nIconWidth = pFullClip->Width();
        nIconHeight = pFullClip->Height();

        xpos = large_icon_xpos;
        ypos = large_icon_ypos;

        scale = GetScale( nIconWidth, nIconHeight, large_icon_width, large_icon_height );

        nIconWidth *= scale;
        nIconHeight *= scale;

        if ( nIconWidth < large_icon_width - XRES(2) ) // 2 is our buffer for when we need to re-calculate the xpos
        {
            xpos = small_icon_xpos + small_icon_width / 2.0 - nIconWidth / 2.0;
        }

        if ( nIconHeight < large_icon_height - YRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            ypos = small_icon_ypos + small_icon_height / 2.0 - nIconHeight / 2.0;
        }

        pFullClip->DrawSelf( xpos, ypos, nIconWidth, nIconHeight, m_clrIcon );

        // base percent is how much of the bullet clip to always draw.
        // total cropped height of the bullet sprite will be
        // base percent + bullet height * bullets
        float flBasePercent			= (float)pWpn->GetDODWpnData().m_iHudClipBaseHeight / (float)pWpn->GetDODWpnData().m_iHudClipHeight;
        float flBulletHeightPercent = (float)pWpn->GetDODWpnData().m_iHudClipBulletHeight / (float)pWpn->GetDODWpnData().m_iHudClipHeight;

        float flHeight = (float)pEmptyClip->Height();

        //Now we draw the bullets inside based on how full our clip is
        float flDrawHeight = flHeight * ( 1.0 - ( flBasePercent + flBulletHeightPercent * m_iAmmo ) );

        int nOffset = (int)flDrawHeight;
        int yPosOffset = nOffset * scale;

        pEmptyClip->DrawSelfCropped( xpos, ypos + yPosOffset, 0, nOffset, pEmptyClip->Width(), pEmptyClip->Height() - nOffset, nIconWidth, nIconHeight - yPosOffset, m_clrIcon );
    }

    // how many full or partially full clips do we have?
    int clips = m_iAmmo2 / pWpn->GetMaxClip1();

    // account for the partial clip, if it exists
    if( clips * pWpn->GetMaxClip1() < m_iAmmo2 )
    {
        clips++;
    }

    if( clips > 0 && pExtraClip )
    {
        //align the extra clip on the same baseline as the large clip
        xpos = extra_clip_xpos;
        ypos = extra_clip_ypos;

        nIconWidth = pExtraClip->Width();
        nIconHeight = pExtraClip->Height();

        if ( nIconWidth > extra_clip_width || nIconHeight > extra_clip_height )
        {
            scale = GetScale( nIconWidth, nIconHeight, extra_clip_width, extra_clip_height );
            nIconWidth *= scale;
            nIconHeight *= scale;
        }

        if ( nIconWidth < extra_clip_width - XRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            xpos = extra_clip_xpos + extra_clip_width / 2.0 - nIconWidth / 2.0;
        }

        if ( nIconHeight < extra_clip_height - YRES(2) ) // 2 is our buffer for when we need to re-calculate the ypos
        {
            ypos = extra_clip_ypos + extra_clip_height / 2.0 - nIconHeight / 2.0;
        }

        pExtraClip->DrawSelf( xpos, ypos, pExtraClip->Width() * scale, pExtraClip->Height() * scale, m_clrIcon );
        DrawAmmoCount( clips );
    }
}
Ejemplo n.º 20
0
void ScorePanel::FillGrid()
{
	CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
	SchemeHandle_t hScheme = pSchemes->getSchemeHandle("Scoreboard Text");
	SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text");
	SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text");

	Font *sfont = pSchemes->getFont(hScheme);
	Font *tfont = pSchemes->getFont(hTitleScheme);
	/* Font *smallfont = */
	pSchemes->getFont(hSmallScheme);
	int i = 0;

	// update highlight position
	int x, y;
	getApp()->getCursorPos(x, y);
	cursorMoved(x, y, this);

	// remove highlight row if we're not in squelch mode
	if (!GetClientVoiceMgr()->IsInSquelchMode())
	{
		m_iHighlightRow = -1;
	}

	for(int row=0; row < NUM_ROWS; row++)
	{
		CGrid *pGridRow = &m_PlayerGrids[row];
		pGridRow->SetRowUnderline(0, false, 0, 0, 0, 0, 0);

		if(row >= m_iRows)
		{
			for(int col=0; col < NUM_COLUMNS; col++)
				m_PlayerEntries[col][row].setVisible(false);
		
			continue;
		}

		for(int col=0; col < NUM_COLUMNS; col++)
		{
			CLabelHeader *pLabel = &m_PlayerEntries[col][row];

			pLabel->setVisible(true);
			pLabel->setText2("");
			pLabel->setImage(NULL);
			pLabel->setFont(sfont);
			pLabel->setTextOffset(0, 0);
			
			int rowheight = 13;
			if (ScreenHeight > 480)
			{
				rowheight = YRES(rowheight);
			}
			else
			{
				// more tweaking, make sure icons fit at low res
				rowheight = 15;
			}
			pLabel->setSize(pLabel->getWide(), rowheight);
			pLabel->setBgColor(0, 0, 0, 255);
			
			char sz[128];
			hud_player_info_t *pl_info = NULL;
			team_info_t *team_info = NULL;

			if (m_iIsATeam[row] == TEAM_SPECTATORS)
			{
				pLabel->setText(" ");
				continue;
			}
			else if ( m_iIsATeam[row] == TEAM_YES )
			{
				// Get the team's data
				team_info = &g_TeamInfo[ m_iSortedRows[row] ];

				// team color text for team names
				pLabel->setFgColor(	iTeamColors[team_info->teamnumber % 5][0],
									iTeamColors[team_info->teamnumber % 5][1],
									iTeamColors[team_info->teamnumber % 5][2],
									0 );

				// different height for team header rows
				rowheight = 20;
				if (ScreenHeight >= 480)
				{
					rowheight = YRES(rowheight);
				}
				pLabel->setSize(pLabel->getWide(), rowheight);
				pLabel->setFont(tfont);

				pGridRow->SetRowUnderline(	0,
											true,
											YRES(3),
											iTeamColors[team_info->teamnumber % 5][0],
											iTeamColors[team_info->teamnumber % 5][1],
											iTeamColors[team_info->teamnumber % 5][2],
											0 );
			}
			else if ( m_iIsATeam[row] == TEAM_SPECTATORS )
			{
				// grey text for spectators
				pLabel->setFgColor(100, 100, 100, 0);

				// different height for team header rows
				rowheight = 20;
				if (ScreenHeight >= 480)
				{
					rowheight = YRES(rowheight);
				}
				pLabel->setSize(pLabel->getWide(), rowheight);
				pLabel->setFont(tfont);

				pGridRow->SetRowUnderline(0, true, YRES(3), 100, 100, 100, 0);
			}
			else
			{
				// team color text for player names
				pLabel->setFgColor(	g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0],
									g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1],
									g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2],
									0 );

				// Get the player's data
				pl_info = &g_PlayerInfoList[ m_iSortedRows[row] ];

				// Set background color
				if ( pl_info->thisplayer ) // if it is their name, draw it a different color
				{
					// Highlight this player
					pLabel->setFgColor(Scheme::sc_white);
					pLabel->setBgColor(	g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][0],
										g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][1],
										g_iaDiscColors[ g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber % iNumberOfTeamColors ][2],
										196 );
				}
				else if ( m_iSortedRows[row] == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime )
				{
					// Killer's name
					pLabel->setBgColor( 255,0,0, 255 - ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) );
				}
			}				

			// Align 
			if (col == COLUMN_NAME )
			{
				pLabel->setContentAlignment( vgui::Label::a_west );
			}
			else if (col == COLUMN_TRACKER)
			{
				pLabel->setContentAlignment( vgui::Label::a_center );
			}
			else
			{
				pLabel->setContentAlignment( vgui::Label::a_east );
			}

			// Fill out with the correct data
			strcpy(sz, "");
			if ( m_iIsATeam[row] )
			{
				char sz2[128];

				switch (col)
				{
				case COLUMN_NAME:
					if ( m_iIsATeam[row] == TEAM_UNASSIGNED )
					{
						sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#Queue" ) );
					}
					else if ( m_iIsATeam[row] == TEAM_SPECTATORS )
					{
						sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) );
					}
					else
					{
						sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( team_info->name ) );
					}

					// Uppercase it
					for ( i = 0; i < (int)strlen(sz2); i++)
					{
						if ( *(sz2 + i) )
							sz[i] = toupper( *(sz2 + i) );
					}
					sz[i] = '\0';

					// Append the number of players
					if ( m_iIsATeam[row] == TEAM_YES )
					{
						const char *pszTemp = NULL;

						if ( team_info->players == 1 )
						{
							pszTemp = "#Player";
						}
						else
						{
							pszTemp = "#Player_plural";
						}

						sprintf(sz, "%s (%d %s)", sz, team_info->players, CHudTextMessage::BufferedLocaliseTextString( pszTemp ) );
					}
			
					break;
				case COLUMN_VOICE:
					break;
				case COLUMN_CLASS:
					break;
				case COLUMN_KILLS: //Wins
					if ( g_iArenaMode == FALSE )
						 strcpy ( sz, " " );
					else
					{
						if ( m_iIsATeam[row] == TEAM_YES )
							sprintf(sz, "%d",  team_info->deaths );
					}
					break;
				case COLUMN_DEATHS: //Points
					if ( m_iIsATeam[row] == TEAM_YES )
						sprintf(sz, "%d",  team_info->frags );
					break;
				case COLUMN_LATENCY:
					if ( m_iIsATeam[row] == TEAM_YES )
						sprintf(sz, "%d", team_info->ping );
					break;
				default:
					break;
				}
			}
			else
			{
				switch (col)
				{
				case COLUMN_NAME:
					/*
					if (g_pTrackerUser)
					{
						int playerSlot = m_iSortedRows[row];
						int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot);
						const char *trackerName = g_pTrackerUser->GetUserName(trackerID);
						if (trackerName && *trackerName)
						{
							sprintf(sz, "   (%s)", trackerName);
							pLabel->setText2(sz);
						}
					}
					*/
					sprintf(sz, "%s  ", pl_info->name);
					break;
				case COLUMN_VOICE:
					sz[0] = 0;
					GetClientVoiceMgr()->UpdateSpeakerImage(pLabel, m_iSortedRows[row]);
					break;
				case COLUMN_CLASS:
					
						if ( g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber == 0 && g_iArenaMode == TRUE )
						{
							sprintf(sz, "%d",  g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass );
						}
						else
						{
							strcpy(sz, "");
						}
					
					break;

				case COLUMN_TRACKER:
						/*
					if (g_pTrackerUser)
					{
						int playerSlot = m_iSortedRows[row];
						int trackerID = gEngfuncs.GetTrackerIDForPlayer(playerSlot);

						if (g_pTrackerUser->IsFriend(trackerID) && trackerID != g_pTrackerUser->GetTrackerID())
						{
							pLabel->setImage(m_pTrackerIcon);
							pLabel->setFgColorAsImageColor(false);
							m_pTrackerIcon->setColor(Color(255, 255, 255, 0));
						}
					}*/
					break;

				case COLUMN_KILLS: //Wins
			        if ( g_iArenaMode == TRUE )
					     sprintf(sz, "%d",  g_PlayerExtraInfo[ m_iSortedRows[row] ].deaths );
					break;
				case COLUMN_DEATHS: //Points
					sprintf(sz, "%d",  g_PlayerExtraInfo[ m_iSortedRows[row] ].frags );
					break;
				case COLUMN_LATENCY:
					sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping );
					break;
				default:
					break;
				}
			}

			pLabel->setText(sz);
		}
	}

	for(int row = 0; row < NUM_ROWS; row++)
	{
		CGrid *pGridRow = &m_PlayerGrids[row];

		pGridRow->AutoSetRowHeights();
		pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight());
		pGridRow->RepositionContents();
	}

	// hack, for the thing to resize
	m_PlayerList.getSize(x, y);
	m_PlayerList.setSize(x, y);
}
Ejemplo n.º 21
0
//-----------------------------------------------------------------------------
// Purpose: Create the ScoreBoard panel
//-----------------------------------------------------------------------------
ScorePanel::ScorePanel(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
{
	CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
	SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle("Scoreboard Title Text");
	SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Scoreboard Small Text");
	SchemeHandle_t hTinyScheme = pSchemes->getSchemeHandle("Scoreboard Tiny Text");
	Font *tfont = pSchemes->getFont(hTitleScheme);
	Font *smallfont = pSchemes->getFont(hSmallScheme);
	Font *tinyfont = pSchemes->getFont(hTinyScheme);
	
	setBgColor(0, 0, 0, 96);
	m_pCurrentHighlightLabel = NULL;
	m_iHighlightRow = -1;
	// puzl: 0001073
	m_pTrackerIcon = NULL;
	m_pDevIcon = NULL;
	m_pPTIcon = NULL;
	m_pGuideIcon = NULL;
	m_pServerOpIcon = NULL;
	m_pContribIcon = NULL;
	m_pCheatingDeathIcon = NULL;
	m_pVeteranIcon = NULL;
	
	m_pTrackerIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardtracker.tga");
	m_pDevIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboarddev.tga");
	m_pPTIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardpt.tga");
	m_pGuideIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardguide.tga");
	m_pServerOpIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardserverop.tga");
	m_pContribIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardcontrib.tga");
	m_pCheatingDeathIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardcd.tga");
	m_pVeteranIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_scoreboardveteran.tga");

	m_iIconFrame = 0;
	m_iLastFrameIncrementTime = gHUD.GetTimeOfLastUpdate();
	
	// Initialize the top title.
	m_TitleLabel.setFont(tfont);
	m_TitleLabel.setText("");
	m_TitleLabel.setBgColor( 0, 0, 0, 255 );
	m_TitleLabel.setFgColor( Scheme::sc_primary1 );
	m_TitleLabel.setContentAlignment( vgui::Label::a_west );

	LineBorder *border = new LineBorder(Color(60, 60, 60, 128));
	setBorder(border);
	setPaintBorderEnabled(true);

	int xpos = g_ColumnInfo[0].m_Width + 3;
	if (ScreenWidth() >= 640)
	{
		// only expand column size for res greater than 640
		xpos = XRES(xpos);
	}
	m_TitleLabel.setBounds(xpos, 4, wide, SBOARD_TITLE_SIZE_Y);
	m_TitleLabel.setContentFitted(false);
	m_TitleLabel.setParent(this);

	// Setup the header (labels like "name", "class", etc..).
	m_HeaderGrid.SetDimensions(NUM_COLUMNS, 1);
	m_HeaderGrid.SetSpacing(0, 0);
	
	for(int i=0; i < NUM_COLUMNS; i++)
	{
		if (g_ColumnInfo[i].m_pTitle && g_ColumnInfo[i].m_pTitle[0] == '#')
			m_HeaderLabels[i].setText(CHudTextMessage::BufferedLocaliseTextString(g_ColumnInfo[i].m_pTitle));
		else if(g_ColumnInfo[i].m_pTitle)
			m_HeaderLabels[i].setText(g_ColumnInfo[i].m_pTitle);

		int xwide = g_ColumnInfo[i].m_Width;
		if (ScreenWidth() >= 640)
		{
			xwide = XRES(xwide);
		}
		else if (ScreenWidth() == 400)
		{
			// hack to make 400x300 resolution scoreboard fit
			if (i == 1)
			{
				// reduces size of player name cell
				xwide -= 28;
			}
			else if (i == 0)
			{
				// tracker icon cell
				xwide -= 8;
			}
		}
		
		m_HeaderGrid.SetColumnWidth(i, xwide);
		m_HeaderGrid.SetEntry(i, 0, &m_HeaderLabels[i]);

		m_HeaderLabels[i].setBgColor(0,0,0,255);
		m_HeaderLabels[i].setBgColor(0,0,0,255);
		
        int theColorIndex = 0;
        Color gammaAdjustedTeamColor = BuildColor(kTeamColors[theColorIndex][0], kTeamColors[theColorIndex][1], kTeamColors[theColorIndex][2], gHUD.GetGammaSlope());
        int theR, theG, theB, theA;
        gammaAdjustedTeamColor.getColor(theR, theG, theB, theA);
        m_HeaderLabels[i].setFgColor(theR, theG, theB, theA);

		m_HeaderLabels[i].setFont(smallfont);
		m_HeaderLabels[i].setContentAlignment(g_ColumnInfo[i].m_Alignment);

		int yres = 12;
		if (ScreenHeight() >= 480)
		{
			yres = YRES(yres);
		}
		m_HeaderLabels[i].setSize(50, yres);
	}

	// Set the width of the last column to be the remaining space.
	int ex, ey, ew, eh;
	m_HeaderGrid.GetEntryBox(NUM_COLUMNS - 2, 0, ex, ey, ew, eh);
	m_HeaderGrid.SetColumnWidth(NUM_COLUMNS - 1, (wide - X_BORDER) - (ex + ew));

	m_HeaderGrid.AutoSetRowHeights();
	m_HeaderGrid.setBounds(X_BORDER, SBOARD_TITLE_SIZE_Y, wide - X_BORDER*2, m_HeaderGrid.GetRowHeight(0));
	m_HeaderGrid.setParent(this);
	m_HeaderGrid.setBgColor(0,0,0,255);


	// Now setup the listbox with the actual player data in it.
	int headerX, headerY, headerWidth, headerHeight;
	m_HeaderGrid.getBounds(headerX, headerY, headerWidth, headerHeight);
	m_PlayerList.setBounds(headerX, headerY+headerHeight, headerWidth, tall - headerY - headerHeight - 6);
	m_PlayerList.setBgColor(0,0,0,255);
	m_PlayerList.setParent(this);

	for(int row=0; row < NUM_ROWS; row++)
	{
		CGrid *pGridRow = &m_PlayerGrids[row];

		pGridRow->SetDimensions(NUM_COLUMNS, 1);
		
		for(int col=0; col < NUM_COLUMNS; col++)
		{
			m_PlayerEntries[col][row].setContentFitted(false);
			m_PlayerEntries[col][row].setRow(row);
			m_PlayerEntries[col][row].addInputSignal(this);
			pGridRow->SetEntry(col, 0, &m_PlayerEntries[col][row]);
		}

		pGridRow->setBgColor(0,0,0,255);
//		pGridRow->SetSpacing(2, 0);f
		pGridRow->SetSpacing(0, 0);
		pGridRow->CopyColumnWidths(&m_HeaderGrid);
		pGridRow->AutoSetRowHeights();
		pGridRow->setSize(PanelWidth(pGridRow), pGridRow->CalcDrawHeight());
		pGridRow->RepositionContents();

		m_PlayerList.AddItem(pGridRow);
	}


	// Add the hit test panel. It is invisible and traps mouse clicks so we can go into squelch mode.
	m_HitTestPanel.setBgColor(0,0,0,255);
	m_HitTestPanel.setParent(this);
	m_HitTestPanel.setBounds(0, 0, wide, tall);
	m_HitTestPanel.addInputSignal(this);

	m_pCloseButton = new CommandButton( "x", wide-XRES(12 + 4), YRES(2), XRES( 12 ) , YRES( 12 ) );
	m_pCloseButton->setParent( this );
	m_pCloseButton->addActionSignal( new CMenuHandler_StringCommandWatch( "-showscores", true ) );
	m_pCloseButton->setBgColor(0,0,0,255);
	m_pCloseButton->setFgColor( 255, 255, 255, 0 );
	m_pCloseButton->setFont(tfont);
	m_pCloseButton->setBoundKey( (char)255 );
	m_pCloseButton->setContentAlignment(Label::a_center);
	Initialize();
}
Ejemplo n.º 22
0
void StatsReport::PerformLayout()
{
	BaseClass::PerformLayout();

	int padding = YRES( 6 );
	int paddingSmall = YRES( 2 );

	int nCategoryButtonX, nCategoryButtonY, nCategoryButtonW, nCategoryButtonH;
	nCategoryButtonY = m_pCategoryButtons[ 0 ]->GetTall();
	m_pCategoryButtons[ 0 ]->SizeToContents();
	m_pCategoryButtons[ 0 ]->SetTall( nCategoryButtonY );
	m_pCategoryButtons[ 0 ]->GetBounds( nCategoryButtonX, nCategoryButtonY, nCategoryButtonW, nCategoryButtonH );

	nCategoryButtonX += nCategoryButtonW + padding;

	// align stat lines in a vertical list one after the other
	for ( int i = 1; i < ASW_STATS_REPORT_CATEGORIES; i++ )
	{
		m_pCategoryButtons[ i ]->SetPos( nCategoryButtonX, nCategoryButtonY );
		m_pCategoryButtons[ i ]->SizeToContents();
		m_pCategoryButtons[ i ]->SetTall( nCategoryButtonH );
		nCategoryButtonW = m_pCategoryButtons[ i ]->GetWide();

		nCategoryButtonX += nCategoryButtonW + padding;
	}

	// Check box
	int nPlayerBoundsW, nPlayerBoundsH;
	int nReadyCheckImageX, nReadyCheckImageY, nReadyCheckImageYOffset, nReadyCheckImageW, nReadyCheckImageH;
	m_pPlayerNamesPosition->GetBounds( nReadyCheckImageX, nReadyCheckImageY, nPlayerBoundsW, nPlayerBoundsH );
	m_fPlayerNamePosY[ 0 ] = nReadyCheckImageY;
	nReadyCheckImageW = m_pReadyCheckImages[ 0 ]->GetTall();
	nReadyCheckImageH = m_pReadyCheckImages[ 0 ]->GetTall();

	nReadyCheckImageYOffset = nPlayerBoundsH / 2 - nReadyCheckImageH / 2;

	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		m_pReadyCheckImages[ i ]->SetPos( nReadyCheckImageX, nReadyCheckImageY + nReadyCheckImageYOffset );
		m_pReadyCheckImages[ i ]->SetSize( nReadyCheckImageW, nReadyCheckImageH );
		m_fPlayerNamePosY[ i ] = nReadyCheckImageY;

		nReadyCheckImageY += nPlayerBoundsH + paddingSmall;
	}

	nPlayerBoundsW -= nReadyCheckImageW + paddingSmall;

	// Avatar
	int nAvatarImageX, nAvatarImageYOffset, nAvatarImageW, nAvatarImageH;
	nAvatarImageX = nReadyCheckImageX + nReadyCheckImageW + padding;
	nAvatarImageW = m_pAvatarImages[ 0 ]->GetWide();
	nAvatarImageH = m_pAvatarImages[ 0 ]->GetTall();

	nAvatarImageYOffset = nPlayerBoundsH / 2 - nAvatarImageH / 2;

	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		m_pAvatarImages[ i ]->SetPos( nAvatarImageX, m_fPlayerNamePosY[ i ] + nAvatarImageYOffset );
		m_pAvatarImages[ i ]->SetSize( nAvatarImageW, nAvatarImageH );

		CAvatarImage *pImage = static_cast< CAvatarImage* >( m_pAvatarImages[ i ]->GetImage() );
		if ( pImage )
		{
			pImage->SetAvatarSize( nAvatarImageW, nAvatarImageH );
		}
	}

	nPlayerBoundsW -= nAvatarImageW + paddingSmall;

	// Player name
	int nPlayerNameX;
	nPlayerNameX = nAvatarImageX + nAvatarImageW + paddingSmall;

	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		m_pPlayerNames[ i ]->SetPos( nPlayerNameX, m_fPlayerNamePosY[ i ] );
		m_pPlayerNames[ i ]->SetSize( nPlayerBoundsW, nPlayerBoundsH );
	}

	SetStatCategory( 1 );
}
Ejemplo n.º 23
0
void CNB_Horiz_List::OnThink()
{
	BaseClass::OnThink();

	if ( MouseOverScrollbar() )
	{
		// No slidy auto scroll while using the scrollbar
		m_fScrollVelocity = 0.0f;
		m_fScrollChange = 0.0f;
	}
	else
	{
		int nMouseX, nMouseY;
		ASWInput()->GetFullscreenMousePos( &nMouseX, &nMouseY );
		ScreenToLocal( nMouseX, nMouseY );

		float fVelocityMax = 1200.0f;

		const float fAccelerationMax = 3000.0f;
		float fScrollAcceleration = 0.0f;

		if ( nMouseX > 0 && nMouseX < GetWide() && nMouseY > 0 && nMouseY < GetTall() )
		{
			const float fDeadZoneSize = 0.55f;
			float fMouseXInterp = static_cast<float>( nMouseX ) / GetWide();

			if ( fMouseXInterp > 0.5f + fDeadZoneSize * 0.5f )
			{
				fMouseXInterp = 0.25f + ( fMouseXInterp - ( 0.5f + fDeadZoneSize * 0.5f ) ) / ( ( 1.0f - fDeadZoneSize ) * 0.666666666f );
			}
			else if ( fMouseXInterp < 0.5f - fDeadZoneSize * 0.5f )
			{
				fMouseXInterp = -0.25f - ( ( 0.5f - fDeadZoneSize * 0.5f ) - fMouseXInterp ) / ( ( 1.0f - fDeadZoneSize ) * 0.666666666f );
			}
			else
			{
				fMouseXInterp = 0.0f;
			}

			fScrollAcceleration = fMouseXInterp * fAccelerationMax;
			fVelocityMax *= fabsf( fMouseXInterp );
		}

		if ( fScrollAcceleration == 0.0f )
		{
			// Dampen velocity in the dead zone
			m_fScrollVelocity = Approach( 0.0f, m_fScrollVelocity, gpGlobals->frametime * fAccelerationMax * 0.75f );
		}
		else
		{
			// Apply acceleration to the velocity
			m_fScrollVelocity = clamp( m_fScrollVelocity + fScrollAcceleration * gpGlobals->frametime, -fVelocityMax, fVelocityMax );
		}

		// Accumulate into a float for smaller than 1 changes
		m_fScrollChange += m_fScrollVelocity * gpGlobals->frametime;

		// Apply the integer amount
		int nScrollChange = m_fScrollChange;

		if ( nScrollChange <= -1 || nScrollChange >= 1 )
		{
			bool bChanged = ChangeScrollValue( nScrollChange );

			if ( bChanged )
			{
				m_fScrollChange -= nScrollChange;
			}
			else
			{
				// Hit the end
				m_fScrollVelocity = 0.0f;
				m_fScrollChange = 0.0f;
			}
		}
	}

	if ( m_bHighlightOnMouseOver )
	{
		for ( int i = 0; i < m_Entries.Count(); i++ )
		{
			if ( m_Entries[i]->IsCursorOver() )
			{
				SetHighlight( i );
				break;
			}
		}
	}

	vgui::Panel *pHighlighted = GetHighlightedEntry();
	if ( !pHighlighted )
		return;

	int x, y;
	pHighlighted->GetPos( x, y );
	m_flContainerTargetPos = YRES( 154 ) - x;

	if ( m_bInitialPlacement )
	{
		m_bInitialPlacement = false;
		m_flContainerPos = m_flContainerTargetPos;
	}
	else
	{
		if ( m_flContainerPos < m_flContainerTargetPos )
		{
			m_flContainerPos = MIN( m_flContainerPos + gpGlobals->frametime * SCROLL_SPEED, m_flContainerTargetPos );
		}
		else if ( m_flContainerPos > m_flContainerTargetPos )
		{
			m_flContainerPos = MAX( m_flContainerPos - gpGlobals->frametime * SCROLL_SPEED, m_flContainerTargetPos );
		}
	}
	//Msg( "m_flContainerPos = %f target = %f\n", m_flContainerPos, m_flContainerTargetPos );
	if ( !m_bShowScrollBar )
	{
		m_pChildContainer->SetPos( m_flContainerPos, 0 );
	}

	m_pLeftArrowButton->SetEnabled( m_nHighlightedEntry > 0 );
	m_pRightArrowButton->SetEnabled( m_nHighlightedEntry < m_Entries.Count() - 1 );
}
Ejemplo n.º 24
0
int CHudLensflare::Draw(float flTime)
{  
	return 0;





	vec3_t sunangles, sundir , suntarget;
	vec3_t             v_forward, v_right, v_up, angles; 
	vec3_t             forward, right, up, screen;  
	pmtrace_t tr,tr1;

	//Sun position
	if(Sunanglex != NULL && Sunangley != NULL)
	{
	sunangles.x = Sunanglex;
	sunangles.y = Sunangley;
	}
	else
	{
	sunangles.x = -90;
	sunangles.y = 0;
	}

	text[0] = SPR_Load("sprites/lens/lens21.spr");
	red[0] = green[0] = blue[0] = 1.0;
	scale[0] = 25;
	multi[0] = -0.45;

	text[1] = SPR_Load("sprites/lens/lens7.spr");
	red[1] = green[0] = blue[0] = 1.0;
	scale[1] = 25;
	multi[1] = 0.2;

	text[2] = SPR_Load("sprites/lens/glow01.spr");
	red[2] = 132/255;
	green[2] = 1.0;
	blue[2] = 153/255;
	scale[2] = 35;
	multi[2] = 0.3;

	text[3] = SPR_Load("sprites/lens/glow.spr");
	red[3] = 1.0;
	green[3] = 164/255;
	blue[3] = 164/255;
	scale[3] = 40;
	multi[3] = 0.46;

	text[4] = SPR_Load("sprites/lens/lens11.spr");
	red[4] = 1.0;
	green[4] = 164/255;
	blue[4] = 164/255;
	scale[4] = 52;
	multi[4] = 0.5;

	text[5] = SPR_Load("sprites/lens/lens7.spr");
	red[5] = green[5] = blue[5] = 1.0;
	scale[5] = 31;
	multi[5] = 0.54;

	text[6] = SPR_Load("sprites/lens/lens7.spr");
	red[6] = 0.6;
	green[6] = 1.0;
	blue[6] = 0.6;
	scale[6] = 26;
	multi[6] = 0.64;

	text[7] = SPR_Load("sprites/lens/glow01.spr");
	red[7] = 0.5;
	green[7] = 1.0;
	blue[7] = 0.5;
	scale[7] = 20;
	multi[7] = 0.77;

	text[8] = SPR_Load("sprites/lens/lens11.spr");

	text[9] = SPR_Load("sprites/lens/lens21.spr");

	flPlayerBlend = 0.0;
	flPlayerBlend2 = 0.0;

	AngleVectors( v_angles, forward, null, null );

	AngleVectors( sunangles, sundir, null, null );

	suntarget = v_origin + sundir * 16384;	

	tr = *(gEngfuncs.PM_TraceLine( v_origin, suntarget, PM_TRACELINE_PHYSENTSONLY, 2, -1 ));

	if( gEngfuncs.PM_PointContents( tr.endpos, null ) == CONTENTS_SKY)
	{		
		flPlayerBlend = max( DotProduct( forward, sundir ) - 0.63, 0.0 ) * 5.8;
		if (flPlayerBlend > 1.0 )
		flPlayerBlend = 1.0;

		flPlayerBlend4 = max( DotProduct( forward, sundir ) - 0.85, 0.0 ) * 5;
		if (flPlayerBlend4 > 1.0 )
		flPlayerBlend4 = 1.0;

		flPlayerBlend6 = max( DotProduct( forward, sundir ) - 0.55, 0.0 ) * 5.7;
		if (flPlayerBlend6 > 1.0 )
		flPlayerBlend6 = 1.0;

		flPlayerBlend2 = flPlayerBlend6 * 100.0 ;
		flPlayerBlend3 = flPlayerBlend * 190.0 ;
		flPlayerBlend5 = flPlayerBlend4 * 222.0 ;

		vec3_t normal,point,origin;

		gEngfuncs.GetViewAngles((float*)normal);
		AngleVectors(normal,forward,right,up);

		VectorCopy( tr.endpos, origin );

		gEngfuncs.pTriAPI->WorldToScreen( tr.endpos, screen );

		Suncoordx = XPROJECT( screen[ 0 ] );
		Suncoordy = YPROJECT( screen[ 1 ] ); 


		if (Suncoordx < XRES( -10 ) || Suncoordx > XRES( 650 ) || Suncoordy < YRES( -10 ) || Suncoordy > YRES( 490 )) 
		return 1;

		Screenmx = ScreenWidth/2;
		Screenmy = ScreenHeight/2;

		Sundistx = Screenmx - Suncoordx;
		Sundisty = Screenmy - Suncoordy;

		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensflare1.spr")) , 0);//use hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(255/255, 255/255 , 255/255, flPlayerBlend3/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy + 190, 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 190, Suncoordy - 190, 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy - 190, 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 190, Suncoordy + 190, 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);


		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/glow1.spr")) , 0);//use hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(255/255, 255/255 , 255/255, flPlayerBlend3/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend3/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy + 160, 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx + 160, Suncoordy - 160, 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy - 160, 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Suncoordx - 160, Suncoordy + 160, 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(SPR_Load("sprites/lens/lensglare1.spr")) , 0);//use hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(1.0, 1.0 , 1.0, flPlayerBlend5/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend5/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(0, 0, 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(0, ScreenHeight, 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, ScreenHeight, 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, 0, 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		int i = 1;
		Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
		Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
		Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
		Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
		Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
		Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
		Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		Lensx[i] = (Suncoordx + (Sundistx * multi[i]));
		Lensy[i] = (Suncoordy + (Sundisty * multi[i]));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(red[i], green[i] , green[i], flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] + scale[i], 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] + scale[i], Lensy[i] - scale[i], 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] - scale[i], 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx[i] - scale[i], Lensy[i] + scale[i], 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		int scale1 = 32;
		int Lensx1,Lensy1 = 0;
		Lensx1 = (Suncoordx + (Sundistx * 0.88));
		Lensy1 = (Suncoordy + (Sundisty * 0.88));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);

		i++;
		scale1 = 140;
		Lensx1 = (Suncoordx + (Sundistx * 1.1));
		Lensy1 = (Suncoordy + (Sundisty * 1.1));
		gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); //additive
		gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *) gEngfuncs.GetSpritePointer(text[i]) , 0); //hotglow, or any other sprite for the texture
		gEngfuncs.pTriAPI->CullFace( TRI_NONE ); //no culling
		gEngfuncs.pTriAPI->Color4f(0.9, 0.9 , 0.9, flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Brightness(flPlayerBlend2/255.0);
		gEngfuncs.pTriAPI->Begin(TRI_QUADS); //start our quad
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 + scale1, 0); //top left
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 + scale1, Lensy1 - scale1, 0); //bottom left
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 - scale1, 0); //bottom right
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);gEngfuncs.pTriAPI->Vertex3f(Lensx1 - scale1, Lensy1 + scale1, 0); //top right
		gEngfuncs.pTriAPI->End(); //end our list of vertexes
		gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
	}
	return 1;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointProgressBar::UpdateBarText( void )
{
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer || !m_pBarText || !m_pAttachedToIcon )
		return;

	m_pBarText->SetVisible( true );

	int iCP = m_pAttachedToIcon->GetCapIndex();
	int iCappingTeam = ObjectiveResource()->GetCappingTeam( iCP );
	int iPlayerTeam = pPlayer->GetTeamNumber();
	int iOwnerTeam = ObjectiveResource()->GetOwningTeam( iCP );

	m_pBarText->SetPos( XRES(25), YRES(20) );

	if ( !TeamplayGameRules()->PointsMayBeCaptured() )
	{
		m_pBarText->SetText( "#Team_Capture_NotNow" );
		return;
	}

	if ( mp_blockstyle.GetInt() == 1 && iCappingTeam != TEAM_UNASSIGNED && iCappingTeam != iPlayerTeam )
	{
		if ( ObjectiveResource()->IsCPBlocked(iCP) )
		{
			m_pBarText->SetText( "#Team_Blocking_Capture" );
			return;
		}
		else if ( iOwnerTeam == TEAM_UNASSIGNED )
		{
			m_pBarText->SetText( "#Team_Reverting_Capture" );
			return;
		}
	}

	if ( ObjectiveResource()->GetOwningTeam(iCP) == iPlayerTeam )
	{
		// If the opponents can never recapture this point back, we use a different string
		if ( iPlayerTeam != TEAM_UNASSIGNED )
		{
			int iEnemyTeam = ( iPlayerTeam == TF_TEAM_RED ) ? TF_TEAM_BLUE : TF_TEAM_RED;
			if ( !ObjectiveResource()->TeamCanCapPoint( iCP, iEnemyTeam ) )
			{
				m_pBarText->SetText( "#Team_Capture_Owned" );
				return;
			}
		}

		m_pBarText->SetText( "#Team_Capture_OwnPoint" );
		m_pBarText->SetPos( XRES(30), YRES(20) );
		return;
	}

	if ( !TeamplayGameRules()->TeamMayCapturePoint( iPlayerTeam, iCP ) )
	{
		if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->IsInArenaMode() == true )
		{
			m_pBarText->SetText( "#Team_Capture_NotNow" );
		}
		else
		{
			m_pBarText->SetText( "#Team_Capture_Linear" );
		}

		return;
	}

	char szReason[256];
	if ( !TeamplayGameRules()->PlayerMayCapturePoint( pPlayer, iCP, szReason, sizeof(szReason) ) )
	{
		m_pBarText->SetText( szReason );
		return;
	}

	bool bHaveRequiredPlayers = true;

	// In Capstyle 1, more players simply cap faster, no required amounts.
	if ( mp_capstyle.GetInt() != 1 )
	{
		int nNumTeammates = ObjectiveResource()->GetNumPlayersInArea( iCP, iPlayerTeam );
		int nRequiredTeammates = ObjectiveResource()->GetRequiredCappers( iCP, iPlayerTeam );
		bHaveRequiredPlayers = (nNumTeammates >= nRequiredTeammates);
	}

	if ( iCappingTeam == iPlayerTeam && bHaveRequiredPlayers )
	{
		m_pBarText->SetText( "#Team_Capture_Blocked" );
		return;
	}

	if ( !ObjectiveResource()->TeamCanCapPoint( iCP, iPlayerTeam ) )
	{
		m_pBarText->SetText( "#Team_Cannot_Capture" );
		return;
	}

	m_pBarText->SetText( "#Team_Waiting_for_teammate" );
}
int CDODDeathStatsPanel::DrawDeathNoticeItem( int x, int y )
{
	// Get the team numbers for the players involved
	int iKillerTeam = TEAM_UNASSIGNED;
	int iVictimTeam = TEAM_UNASSIGNED;

	if( g_PR )
	{
		iKillerTeam = g_PR->GetTeam( m_DeathRecord.Killer.iEntIndex );
		iVictimTeam = g_PR->GetTeam( m_DeathRecord.Victim.iEntIndex );
	}	

	wchar_t victim[ 256 ];
	wchar_t killer[ 256 ];

	g_pVGuiLocalize->ConvertANSIToUnicode( m_DeathRecord.Victim.szName, victim, sizeof( victim ) );
	g_pVGuiLocalize->ConvertANSIToUnicode( m_DeathRecord.Killer.szName, killer, sizeof( killer ) );

	// Get the local position for this notice
	int len = UTIL_ComputeStringWidth( m_hTextFont, victim );

	int iconWide;
	int iconTall;

	CHudTexture *icon = m_DeathRecord.iconDeath;

	Assert( icon );

	if ( !icon )
		return 0;

	if( icon->bRenderUsingFont )
	{
		iconWide = surface()->GetCharacterWidth( icon->hFont, icon->cCharacterInFont );
		iconTall = surface()->GetFontTall( icon->hFont );
	}
	else
	{
		float scale = GetScale( icon->Width(), icon->Height(), XRES(cl_deathicon_width.GetInt()), YRES(cl_deathicon_height.GetInt()) );
		iconWide = (int)( scale * (float)icon->Width() );
		iconTall = (int)( scale * (float)icon->Height() );
	}

	int spacerX = XRES(5);

	//int x = xRight - len - spacerX - iconWide - XRES(10);

	surface()->DrawSetTextFont( m_hTextFont );
	int iFontTall = vgui::surface()->GetFontTall( m_hTextFont );
	int yText = y + ( iconTall - iFontTall ) / 2;

	int boxWidth = len + iconWide + spacerX;
	int boxHeight = min( iconTall, m_flLineHeight );	
	int boxBorder = XRES(2);

	// Only draw killers name if it wasn't a suicide
	if ( !m_DeathRecord.bSuicide )
	{
		int nameWidth = UTIL_ComputeStringWidth( m_hTextFont, killer ) + spacerX;	// gap

		//x -= nameWidth;
		boxWidth += nameWidth;

		Panel::DrawBox( x-boxBorder,
			y-boxBorder,
			boxWidth+2*boxBorder,
			boxHeight+2*boxBorder,
			m_ActiveBackgroundColor,
			1.0 );

		Color c = g_PR->GetTeamColor( iKillerTeam );
		surface()->DrawSetTextColor( c );

		// Draw killer's name			
		surface()->DrawSetTextPos( x, yText );
		const wchar_t *p = killer;
		while ( *p )
		{
			surface()->DrawUnicodeChar( *p++ );
		}
		surface()->DrawGetTextPos( x, yText );

		x += spacerX;
	}
	else
	{
		Panel::DrawBox( x-boxBorder,
			y-boxBorder,
			boxWidth+2*boxBorder,
			boxHeight+2*boxBorder,
			m_ActiveBackgroundColor,
			1.0 );
	}

	Color iconColor( 255, 80, 0, 255 );

	// Draw death weapon
	//If we're using a font char, this will ignore iconTall and iconWide
	icon->DrawSelf( x, y, iconWide, iconTall, iconColor );
	x += iconWide + spacerX;

	Color c = g_PR->GetTeamColor( iVictimTeam );
	surface()->DrawSetTextColor( c );

	// Draw victims name
	surface()->DrawSetTextFont( m_hTextFont );	//reset the font, draw icon can change it
	surface()->DrawSetTextPos( x, yText );
	const wchar_t *p = victim;
	while ( *p )
	{
		surface()->DrawUnicodeChar( *p++ );
	}

	return boxWidth;
}
Ejemplo n.º 27
0
/*
==================
V_CalcSpectatorRefdef

==================
*/
void V_CalcSpectatorRefdef ( struct ref_params_s * pparams )
{
	static vec3_t			velocity ( 0.0f, 0.0f, 0.0f);

	static int lastWeaponModelIndex = 0;
	static int lastViewModelIndex = 0;
		
	cl_entity_t	 * ent = gEngfuncs.GetEntityByIndex( g_iUser2 );
	
	pparams->onlyClientDraw = false;

	// refresh position
	VectorCopy ( pparams->simorg, v_sim_org );

	// get old values
	VectorCopy ( pparams->cl_viewangles, v_cl_angles );
	VectorCopy ( pparams->viewangles, v_angles );
	VectorCopy ( pparams->vieworg, v_origin );

	if (  ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) && ent )
	{
		// calculate player velocity
		float timeDiff = ent->curstate.msg_time - ent->prevstate.msg_time;

		if ( timeDiff > 0 )
		{
			vec3_t distance;
			VectorSubtract(ent->prevstate.origin, ent->curstate.origin, distance);
			VectorScale(distance, 1/timeDiff, distance );

			velocity[0] = velocity[0]*0.9f + distance[0]*0.1f;
			velocity[1] = velocity[1]*0.9f + distance[1]*0.1f;
			velocity[2] = velocity[2]*0.9f + distance[2]*0.1f;
			
			VectorCopy(velocity, pparams->simvel);
		}

		// predict missing client data and set weapon model ( in HLTV mode or inset in eye mode )
#ifdef _TFC
		if ( gEngfuncs.IsSpectateOnly() || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE )
#else
		if ( gEngfuncs.IsSpectateOnly() )
#endif
		{
			V_GetInEyePos( g_iUser2, pparams->simorg, pparams->cl_viewangles );

			pparams->health = 1;

			cl_entity_t	 * gunModel = gEngfuncs.GetViewModel();

			if ( lastWeaponModelIndex != ent->curstate.weaponmodel )
			{
				// weapon model changed

				lastWeaponModelIndex = ent->curstate.weaponmodel;
				lastViewModelIndex = V_FindViewModelByWeaponModel( lastWeaponModelIndex );
				if ( lastViewModelIndex )
				{
					gEngfuncs.pfnWeaponAnim(0,0);	// reset weapon animation
				}
				else
				{
					// model not found
					gunModel->model = NULL;	// disable weapon model
					lastWeaponModelIndex = lastViewModelIndex = 0;
				}
			}

			if ( lastViewModelIndex )
			{
				gunModel->model = IEngineStudio.GetModelByIndex( lastViewModelIndex );
				gunModel->curstate.modelindex = lastViewModelIndex;
				gunModel->curstate.frame = 0;
				gunModel->curstate.colormap = 0; 
				gunModel->index = g_iUser2;
			}
			else
			{
				gunModel->model = NULL;	// disable weaopn model
			}
		}
		else
		{
			// only get viewangles from entity
			VectorCopy ( ent->angles, pparams->cl_viewangles );
			pparams->cl_viewangles[PITCH]*=-3.0f;	// see CL_ProcessEntityUpdate()
		}
	}

	v_frametime = pparams->frametime;

	if ( pparams->nextView == 0 )
	{
		// first renderer cycle, full screen

		switch ( g_iUser1 )
		{
			case OBS_CHASE_LOCKED:	V_GetChasePos( g_iUser2, NULL, v_origin, v_angles );
									break;

			case OBS_CHASE_FREE:	V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles );
									break;

			case OBS_ROAMING	:	VectorCopy (v_cl_angles, v_angles);
									VectorCopy (v_sim_org, v_origin);
									
									// override values if director is active
									gHUD.m_Spectator.GetDirectorCamera(v_origin, v_angles);
									break;

			case OBS_IN_EYE		:   V_CalcNormalRefdef ( pparams );
									break;
				
			case OBS_MAP_FREE  :	pparams->onlyClientDraw = true;
									V_GetMapFreePosition( v_cl_angles, v_origin, v_angles );
									break;

			case OBS_MAP_CHASE  :	pparams->onlyClientDraw = true;
									V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles );
									break;
		}

		if ( gHUD.m_Spectator.m_pip->value )
			pparams->nextView = 1;	// force a second renderer view

		gHUD.m_Spectator.m_iDrawCycle = 0;

	}
	else
	{
		// second renderer cycle, inset window

		// set inset parameters
		pparams->viewport[0] = XRES(gHUD.m_Spectator.m_OverviewData.insetWindowX);	// change viewport to inset window
		pparams->viewport[1] = YRES(gHUD.m_Spectator.m_OverviewData.insetWindowY);
		pparams->viewport[2] = XRES(gHUD.m_Spectator.m_OverviewData.insetWindowWidth);
		pparams->viewport[3] = YRES(gHUD.m_Spectator.m_OverviewData.insetWindowHeight);
		pparams->nextView	 = 0;	// on further view

		// override some settings in certain modes
		switch ( (int)gHUD.m_Spectator.m_pip->value )
		{
			case INSET_CHASE_FREE : V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles );
									break;	

			case INSET_IN_EYE	 :	V_CalcNormalRefdef ( pparams );
									break;

			case INSET_MAP_FREE  :	pparams->onlyClientDraw = true;
									V_GetMapFreePosition( v_cl_angles, v_origin, v_angles );
									break;

			case INSET_MAP_CHASE  :	pparams->onlyClientDraw = true;

									if ( g_iUser1 == OBS_ROAMING )
										V_GetMapChasePosition( 0, v_cl_angles, v_origin, v_angles );
									else
										V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles );

									break;
		}

		gHUD.m_Spectator.m_iDrawCycle = 1;
	}

	// write back new values into pparams
	VectorCopy ( v_cl_angles, pparams->cl_viewangles );
	VectorCopy ( v_angles, pparams->viewangles )
	VectorCopy ( v_origin, pparams->vieworg );

}
Ejemplo n.º 28
0
COrdiMenuPanel :: COrdiMenuPanel(int iTrans, int iRemoveMe, int x,int y,int wide,int tall) : CMenuPanel(iTrans, iRemoveMe, x,y,wide,tall)
{
	//constructeur du vgui - initialise les elements sans les afficher
	//fonction appelée a chaque chargement de niveau
	//aucun texte pour l instant - celui ci est cree lors de l affichage des menus

	Initialize();

	//===================================
	// chargement des polices
	//===================================

	pSchemes = gViewPort->GetSchemeManager();

	hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
	hInfoText = pSchemes->getSchemeHandle( "Briefing Text" );

	pTitleFont = pSchemes->getFont( hTitleScheme );
	pTextFont = pSchemes->getFont( hInfoText );

	pSchemes->getFgColor( hTitleScheme, r[0], g[0], b[0], a[0] );
	pSchemes->getBgColor( hTitleScheme, r[1], g[1], b[1], a[1] );

	pSchemes->getFgColor( hInfoText, r[2], g[2], b[2], a[2] );
	pSchemes->getBgColor( hInfoText, r[3], g[3], b[3], a[3] );



	//====================================
	// éléments des menus
	//====================================

	// fenetre

	m_pWindow = new CTransparentPanel( 255, ORDIMENU_WINDOW_X, ORDIMENU_WINDOW_Y, ORDIMENU_WINDOW_SIZE_X, ORDIMENU_WINDOW_SIZE_Y );
    m_pWindow->setParent( this );
    m_pWindow->setBorder( new LineBorder( Color(255*0.7,170*0.7,0,0 )) );

	// boutton quitter

    m_pCancelButton = new CommandButton( "", ORDIMENU_CANCEL_BUTTON_X, ORDIMENU_CANCEL_BUTTON_Y, ORDIMENU_STANDART_BUTTON_SIZE_X, ORDIMENU_STANDART_BUTTON_SIZE_Y);
    m_pCancelButton->setParent( m_pWindow );
    m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow(HIDE_TEXTWINDOW) );

	char txt [ORDI_STRING_LEN];
	GetOrdiText ( "BOUTON_QUITER", txt, pTitleFont, 9999 );
	m_pCancelButton->setText( txt );

	// titre

	m_pTitle = new Label ( ""/*TITLE_TEXT*/, ORDIMENU_TITLE_X, ORDIMENU_TITLE_Y );
	m_pTitle->setFont( pTitleFont ); 
	m_pTitle->setParent( m_pWindow );
	m_pTitle->setFgColor( r[0], g[0], b[0], a[0] );
	m_pTitle->setBgColor( r[1], g[1], b[1], a[1] );
	m_pTitle->setContentAlignment( vgui::Label::a_west );

	GetOrdiText ( "TITLE_TEXT", txt, pTitleFont, 9999 );
	m_pTitle->setText( txt );


	// texte

	m_pText[0] = new TextPanel( " ", ORDIMENU_TEXT_X + 15 ,ORDIMENU_TEXT_Y + 15, ORDIMENU_TEXT_SIZE_X -30, ORDIMENU_TEXT_SIZE_Y -30 );
	m_pText[0]->setParent( m_pWindow );
	m_pText[0]->setFont( pTextFont );
	m_pText[0]->setFgColor( r[2], g[2], b[2], a[2] );
	m_pText[0]->setBgColor( r[3], g[3], b[3], a[3] );


	// bordure du texte

	m_pBorder[0] = new TextPanel( " ",   ORDIMENU_TEXT_X,ORDIMENU_TEXT_Y, ORDIMENU_TEXT_SIZE_X, ORDIMENU_TEXT_SIZE_Y );
	m_pBorder[0]->setParent( m_pWindow );
	m_pBorder[0]->setBorder( new LineBorder( Color(255*0.7,170*0.7,0,0 )) );
	m_pBorder[0]->setFgColor( r[2], g[2], b[2], a[2] );
	m_pBorder[0]->setBgColor( r[3], g[3], b[3], a[3] );

	// deuxieme bordure
	

	m_pBorder[1] = new TextPanel( "",   ORDIMENU_TEXT_X,ORDIMENU_TEXT_Y, ORDIMENU_TEXT_SIZE_X, ORDIMENU_TEXT_SIZE_Y/3 );
	m_pBorder[1]->setParent( m_pWindow );
	m_pBorder[1]->setVisible ( false );
	m_pBorder[1]->setBorder( new LineBorder( Color(255*0.7,170*0.7,0,0 )) );
	m_pBorder[1]->setFgColor( r[2], g[2], b[2], a[2] );
	m_pBorder[1]->setBgColor( r[3], g[3], b[3], a[3] );



	// boutons

	int posY = ORDIMENU_GBUTTONS_Y;

	for ( int i = 0; i < MAX_GBUTTONS ; i++ )
	{
		m_pGButton[i] = new CommandButton( " ", ORDIMENU_GBUTTONS_X, posY, ORDIMENU_STANDART_BUTTON_SIZE_X, ORDIMENU_STANDART_BUTTON_SIZE_Y);
		m_pGButton[i]->setParent( m_pWindow );
		m_pGButton[i]->setVisible ( false );
		posY += ORDIMENU_STANDART_BUTTON_SIZE_Y + 20;
	}


	GetOrdiText ( "BOUTON_ENTREE", txt, pTextFont, 9999);
	m_pGButton[0]->setText( txt );

	GetOrdiText ( "BOUTON_APPLICATIONS", txt, pTextFont, 9999 );
	m_pGButton[1]->setText( txt );

	GetOrdiText ( "BOUTON_MESSAGERIE", txt, pTextFont, 9999 );
	m_pGButton[2]->setText( txt );

	GetOrdiText ( "BOUTON_INFORMATIONS", txt, pTextFont, 9999 );
	m_pGButton[3]->setText( txt );

	GetOrdiText ( "BOUTON_DONNEESSYSTEME", txt, pTextFont, 9999 );
	m_pGButton[4]->setText( txt );
	m_pGButton[5]->setVisible ( false );

	GetOrdiText ( "BOUTON_SECURITE", txt, pTextFont, 9999 );
	m_pGButton[6]->setText( txt );

	m_pGButton[0]->addActionSignal( new CMenuHandler_OrdiMenu( HANDLER_REFRESH, MENU_PRINCIPAL, this ) );
	m_pGButton[1]->addActionSignal( new CMenuHandler_OrdiMenu( HANDLER_REFRESH, MENU_REFUSE, this ) );
	m_pGButton[2]->addActionSignal( new CMenuHandler_OrdiMenu( HANDLER_REFRESH, MENU_MESSAGE, this ) );
	m_pGButton[3]->addActionSignal( new CMenuHandler_OrdiMenu( HANDLER_REFRESH, MENU_INFO, this ) );
	m_pGButton[4]->addActionSignal( new CMenuHandler_OrdiMenu( HANDLER_REFRESH, MENU_REFUSE, this ) );
	m_pGButton[6]->addActionSignal( new CMenuHandler_OrdiMenu( HANDLER_REFRESH, MENU_KEYPAD_CAM, this ) );


	// keypad

	m_pText[1] = new TextPanel( "1", XRES(412),YRES(238), XRES(30), YRES(30));
	m_pText[2] = new TextPanel( "2", XRES(457),YRES(238), XRES(30), YRES(30));
	m_pText[3] = new TextPanel( "3", XRES(502),YRES(238), XRES(30), YRES(30));
	
	m_pText[4] = new TextPanel( "4", XRES(412),YRES(283), XRES(30), YRES(30));
	m_pText[5] = new TextPanel( "5", XRES(457),YRES(283), XRES(30), YRES(30));
	m_pText[6] = new TextPanel( "6", XRES(502),YRES(283), XRES(30), YRES(30));

	m_pText[7] = new TextPanel( "7", XRES(412),YRES(328), XRES(30), YRES(30));
	m_pText[8] = new TextPanel( "8", XRES(457),YRES(328), XRES(30), YRES(30));
	m_pText[9] = new TextPanel( "9", XRES(502),YRES(328), XRES(30), YRES(30));

	m_pText[10] = new TextPanel( "0", XRES(457),YRES(373), XRES(30), YRES(30));

	m_pKeypad[1] = new CommandButton( " ", XRES(400), YRES(230), XRES(30), YRES(30) );
	m_pKeypad[2] = new CommandButton( " ", XRES(445), YRES(230), XRES(30), YRES(30) );
	m_pKeypad[3] = new CommandButton( " ", XRES(490), YRES(230), XRES(30), YRES(30) );

	m_pKeypad[4] = new CommandButton( " ", XRES(400), YRES(275), XRES(30), YRES(30) );
	m_pKeypad[5] = new CommandButton( " ", XRES(445), YRES(275), XRES(30), YRES(30) );
	m_pKeypad[6] = new CommandButton( " ", XRES(490), YRES(275), XRES(30), YRES(30) );

	m_pKeypad[7] = new CommandButton( " ", XRES(400), YRES(320), XRES(30), YRES(30) );
	m_pKeypad[8] = new CommandButton( " ", XRES(445), YRES(320), XRES(30), YRES(30) );
	m_pKeypad[9] = new CommandButton( " ", XRES(490), YRES(320), XRES(30), YRES(30) );

	m_pKeypad[0] = new CommandButton( " ", XRES(445), YRES(365), XRES(30), YRES(30) );

	for ( int j = 1; j < 11 ; j++ )
	{
		m_pText[j]->setParent( m_pWindow );
		m_pText[j]->setFgColor( r[2], g[2], b[2], a[2] );
		m_pText[j]->setBgColor( r[3], g[3], b[3], a[3] );
	}

	for ( int k = 0; k < 10 ; k++ )
	{
		m_pKeypad[k]->setParent( m_pWindow );

		m_pKeypad[k]->addActionSignal( new CMenuHandler_OrdiMenu( HANDLER_KEYPAD, k, this ) );

	}

	// affichage du code

	m_pBorder[2] = new TextPanel( "coucou", XRES(440) ,YRES(400), XRES(70), YRES(30) );
	m_pBorder[2]->setParent( m_pWindow );
	m_pBorder[2]->setFont( pTitleFont );
	m_pBorder[2]->setFgColor( r[2], g[2], b[2], a[2] );
	m_pBorder[2]->setBgColor( r[3], g[3], b[3], a[3] );





}
Ejemplo n.º 29
0
void SpectatorPanel::Initialize()
{
	int x, y, wide, tall;

	getBounds(x, y, wide, tall);

	CSchemeManager *pSchemes = gViewPort->GetSchemeManager();

	SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle("Team Info Text");

	m_TopBorder = new CTransparentPanel(64, 0, 0, ScreenWidth, PANEL_HEIGHT);
	m_TopBorder->setParent(this);

	m_BottomBorder = new CTransparentPanel(64, 0, ScreenHeight - PANEL_HEIGHT, ScreenWidth, PANEL_HEIGHT);
	m_BottomBorder->setParent(this);

	setPaintBackgroundEnabled(false);

	m_ExtraInfo = new Label("Extra Info", 0, 0, wide, PANEL_HEIGHT);
	m_ExtraInfo->setParent(m_TopBorder);
	m_ExtraInfo->setFont(pSchemes->getFont(hSmallScheme));

	m_ExtraInfo->setPaintBackgroundEnabled(false);
	m_ExtraInfo->setFgColor(143, 143, 54, 0);
	m_ExtraInfo->setContentAlignment(vgui::Label::a_west);

	m_TimerImage = new CImageLabel("timer", 0, 0, 14, 14);
	m_TimerImage->setParent(m_TopBorder);

	m_TopBanner = new CImageLabel("banner", 0, 0, XRES(BANNER_WIDTH), YRES(BANNER_HEIGHT));
	m_TopBanner->setParent(this);

	m_CurrentTime = new Label("00:00", 0, 0, wide, PANEL_HEIGHT);
	m_CurrentTime->setParent(m_TopBorder);
	m_CurrentTime->setFont(pSchemes->getFont(hSmallScheme));
	m_CurrentTime->setPaintBackgroundEnabled(false);
	m_CurrentTime->setFgColor(143, 143, 54, 0);
	m_CurrentTime->setContentAlignment(vgui::Label::a_west);

	m_Separator = new Panel(0, 0, XRES(64), YRES(96));
	m_Separator->setParent(m_TopBorder);
	m_Separator->setFgColor(59, 58, 34, 48);
	m_Separator->setBgColor(59, 58, 34, 48);

	for(int j = 0; j < TEAM_NUMBER; j++)
	{
		m_TeamScores[j] = new Label("   ", 0, 0, wide, PANEL_HEIGHT);
		m_TeamScores[j]->setParent(m_TopBorder);
		m_TeamScores[j]->setFont(pSchemes->getFont(hSmallScheme));
		m_TeamScores[j]->setPaintBackgroundEnabled(false);
		m_TeamScores[j]->setFgColor(143, 143, 54, 0);
		m_TeamScores[j]->setContentAlignment(vgui::Label::a_west);
		m_TeamScores[j]->setVisible(false);
	}

	// Initialize command buttons.
	//	m_OptionButton = new ColorButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
	m_OptionButton = new DropDownButton(CHudTextMessage::BufferedLocaliseTextString("#SPECT_OPTIONS"), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false);
	m_OptionButton->setParent(m_BottomBorder);
	m_OptionButton->setContentAlignment(vgui::Label::a_center);
	m_OptionButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
	m_OptionButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_OPTIONS));
	m_OptionButton->setUnArmedBorderColor(59, 58, 34, 48);
	m_OptionButton->setArmedBorderColor(194, 202, 54, 0);
	m_OptionButton->setUnArmedColor(143, 143, 54, 0);
	m_OptionButton->setArmedColor(194, 202, 54, 0);

	m_CamButton = new DropDownButton(CHudTextMessage::BufferedLocaliseTextString("#CAM_OPTIONS"), ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15), YRES(6), XRES(CAMOPTIONS_BUTTON_X), YRES(20), false, false);
	m_CamButton->setParent(m_BottomBorder);
	m_CamButton->setContentAlignment(vgui::Label::a_center);
	m_CamButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
	m_CamButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_CAMERA));
	m_CamButton->setUnArmedBorderColor(59, 58, 34, 48);
	m_CamButton->setArmedBorderColor(194, 202, 54, 0);
	m_CamButton->setUnArmedColor(143, 143, 54, 0);
	m_CamButton->setArmedColor(194, 202, 54, 0);

	//	m_PrevPlayerButton= new ColorButton("<", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
	m_PrevPlayerButton = new CImageButton("arrowleft", XRES(15 + OPTIONS_BUTTON_X + 15), YRES(6), XRES(24), YRES(20), false, false);
	m_PrevPlayerButton->setParent(m_BottomBorder);
	m_PrevPlayerButton->setContentAlignment(vgui::Label::a_center);
	m_PrevPlayerButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
	m_PrevPlayerButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_PREVPLAYER));
	m_PrevPlayerButton->setUnArmedBorderColor(59, 58, 34, 48);
	m_PrevPlayerButton->setArmedBorderColor(194, 202, 54, 0);
	m_PrevPlayerButton->setUnArmedColor(143, 143, 54, 0);
	m_PrevPlayerButton->setArmedColor(194, 202, 54, 0);

	//	m_NextPlayerButton= new ColorButton(">", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
	m_NextPlayerButton = new CImageButton("arrowright", (ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15), YRES(6), XRES(24), YRES(20), false, false);
	m_NextPlayerButton->setParent(m_BottomBorder);
	m_NextPlayerButton->setContentAlignment(vgui::Label::a_center);
	m_NextPlayerButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
	m_NextPlayerButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_NEXTPLAYER));
	m_NextPlayerButton->setUnArmedBorderColor(59, 58, 34, 48);
	m_NextPlayerButton->setArmedBorderColor(194, 202, 54, 0);
	m_NextPlayerButton->setUnArmedColor(143, 143, 54, 0);
	m_NextPlayerButton->setArmedColor(194, 202, 54, 0);

	// Initialize the bottom title.

	float flLabelSize = ((ScreenWidth - (XRES(CAMOPTIONS_BUTTON_X) + 15)) - XRES(24 + 15)) - XRES((15 + OPTIONS_BUTTON_X + 15) + 38);

	m_BottomMainButton = new DropDownButton("Spectator Bottom",
	                                        XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6), flLabelSize, YRES(20),
	                                        false, false);

	m_BottomMainButton->setParent(m_BottomBorder);
	m_BottomMainButton->setPaintBackgroundEnabled(false);
	m_BottomMainButton->setFgColor(Scheme::sc_primary1);
	m_BottomMainButton->setContentAlignment(vgui::Label::a_center);
	m_BottomMainButton->setBorder(new LineBorder(Color(59, 58, 34, 48)));
	m_BottomMainButton->setBoundKey((char)255); // special no bound to avoid leading spaces in name
	m_BottomMainButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_PLAYERS));
	m_BottomMainButton->setUnArmedBorderColor(59, 58, 34, 48);
	m_BottomMainButton->setArmedBorderColor(194, 202, 54, 0);
	m_BottomMainButton->setUnArmedColor(143, 143, 54, 0);
	m_BottomMainButton->setArmedColor(194, 202, 54, 0);

	m_BottomMainLabel = new Label("Spectator Bottom",
	                              XRES((15 + OPTIONS_BUTTON_X + 15) + 31), YRES(6), flLabelSize, YRES(20));

	m_BottomMainLabel->setParent(m_BottomBorder);
	m_BottomMainLabel->setPaintBackgroundEnabled(false);
	m_BottomMainLabel->setFgColor(Scheme::sc_primary1);
	m_BottomMainLabel->setContentAlignment(vgui::Label::a_center);
	m_BottomMainLabel->setBorder(NULL);
	m_BottomMainLabel->setVisible(false);

	m_InsetViewButton = new ColorButton("", XRES(2), YRES(2), XRES(240), YRES(180), false, false);
	m_InsetViewButton->setParent(this);
	m_InsetViewButton->setBoundKey((char)255);
	m_InsetViewButton->addActionSignal(new CSpectatorHandler_Command(this, SPECTATOR_PANEL_CMD_TOGGLE_INSET));
	m_InsetViewButton->setUnArmedBorderColor(59, 58, 34, 48);
	m_InsetViewButton->setArmedBorderColor(194, 202, 54, 0);
	m_InsetViewButton->setUnArmedColor(143, 143, 54, 0);
	m_InsetViewButton->setArmedColor(194, 202, 54, 0);

	m_menuVisible  = false;
	m_insetVisible = false;
	//	m_HideButton->setVisible(false);
	m_CamButton->setVisible(false);
	m_OptionButton->setVisible(false);
	m_NextPlayerButton->setVisible(false);
	m_PrevPlayerButton->setVisible(false);
	m_TopBanner->setVisible(false);
	m_ExtraInfo->setVisible(false);
	m_Separator->setVisible(false);
	m_TimerImage->setVisible(false);
}
void CDODDeathStatsPanel::Paint( void )
{
	int deathNoticeWidth = 0;

	if ( m_DeathRecord.Victim.iEntIndex > 0 )
		deathNoticeWidth = DrawDeathNoticeItem( m_iDeathNoticeX, m_iDeathNoticeY );

	const int minWidth = XRES(160);

	int panelWidth = ( deathNoticeWidth < minWidth ? minWidth : deathNoticeWidth );

	int wide, tall;

	// set width of summary label to death notice width
	m_pSummaryLabel->GetSize( wide, tall );
	m_pSummaryLabel->SetSize( panelWidth, tall );

	C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer();

	if ( !pLocalPlayer )
		return;

	char buf[512];
	buf[0] = '\0';

	if ( !m_DeathRecord.bSuicide )
	{
		bool bStart = true;
		bool bHit = false;

		for ( int i=0;i<4;i++ )
		{
			if ( pLocalPlayer->m_iHitsOnAttacker[i] > 0 )
			{
				bHit = true;
				if ( bStart )
				{
					Q_snprintf( buf, sizeof(buf), "You hit %s %i %s in the %s\n",
						m_DeathRecord.Killer.szName,
						pLocalPlayer->m_iHitsOnAttacker[i],
						pLocalPlayer->m_iHitsOnAttacker[i] == 1 ? "time" : "times",
						szHitgroupNames[i] );

					bStart = false;
				}
				else
				{
					Q_snprintf( buf, sizeof(buf), "%s and %i %s in the %s\n",
						buf,
						pLocalPlayer->m_iHitsOnAttacker[i],
						pLocalPlayer->m_iHitsOnAttacker[i] == 1 ? "time" : "times",
						szHitgroupNames[i] );
				}
			}
		}
	}	

	Q_strncat( buf, "\n", sizeof(buf), COPY_ALL_CHARACTERS );

	if ( pLocalPlayer->m_iPerLifeKills )
	{
		Q_snprintf( buf, sizeof(buf), "%sKills: %i\n\n",
			buf,
			pLocalPlayer->m_iPerLifeKills );
	}

	if ( pLocalPlayer->m_iPerLifeWounded )
	{
		Q_snprintf( buf, sizeof(buf), "%sWounded: %i\n\n",
			buf,
			pLocalPlayer->m_iPerLifeWounded );
	}

	if ( pLocalPlayer->m_iPerLifeCaptures )
	{
		Q_snprintf( buf, sizeof(buf), "%sFlag Captures: %i\n\n",
			buf,
			pLocalPlayer->m_iPerLifeCaptures );
	}

	if ( pLocalPlayer->m_iPerLifeDefenses )
	{
		Q_snprintf( buf, sizeof(buf), "%sFlag Defenses: %i\n\n",
			buf,
			pLocalPlayer->m_iPerLifeDefenses );
	}

	m_pAttackerHistoryLabel->SetText( buf );
	m_pAttackerHistoryLabel->SizeToContents();

	int panel_h = YRES(160);

	SetSize( panelWidth, panel_h );
}