Ejemplo n.º 1
0
void CHUDScores::Update()
{
	if (m_nDraw <= 0) return;

	uint32 textCol = (m_bScreen ? m_nScreenTextColor : m_nTextColor);
	uint32 playerTextCol = (m_bScreen ? m_nScreenPlayerTextColor : m_nPlayerTextColor);

	float fScale = g_pInterfaceResMgr->GetXRatio();
	if (fScale != m_fScale)
	{
		m_fScale = fScale;
		m_Server.SetScale(fScale);
		m_SingleFrame.SetScale(fScale);
		for (int team = 0; team < kNumTeams; team++)
		{
			m_Team[team].SetScale(fScale);
			m_Rounds[team].SetScale(fScale);
			m_Header[team].SetScale(fScale);
			m_Frame[team].SetScale(fScale);

			for (int i = 0; i < kMaxPlayers; i++)
			{
				m_Columns[team][i].SetScale(fScale);
			}
		}

	}

	if (IsTeamGameType())
	{
		CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile();

		for( uint8 team = 0; team < kNumTeams; ++team )
		{
			CTeam* pTeam = CTeamMgr::Instance().GetTeam(team);
			if (!pTeam) continue;
			
			char szTmp[128];
			sprintf(szTmp,"%s : %d",pTeam->GetName(),pTeam->GetScore());
			m_Team[team].SetString(szTmp);

			sprintf(szTmp,"%s : %d", LoadTempString(IDS_ROUNDS), pTeam->GetRoundScore( ));
			m_Rounds[team].SetString(szTmp);
		
			m_Header[team].Show(LTTRUE);
		}

	}
	else
	{
		m_Team[0].SetString("");
		m_Rounds[0].SetString("");
		m_Header[1].Show(LTFALSE);
	}


	m_Server.SetColors(textCol,textCol,textCol);

	CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr();
	if (!pCIMgr) return;

	CLIENT_INFO* pCI = pCIMgr->GetFirstClient();
	int nTotal = 0;
	int count[kNumTeams] = {0,0};
	char szTmp[64] = "";
	uint16 nHeight[kNumTeams];
	nHeight[0] = m_Server.GetBaseHeight() + m_Header[0].GetBaseHeight() + m_Team[0].GetBaseHeight() + 24;
	nHeight[1] = m_Team[1].GetBaseHeight() + m_Header[1].GetBaseHeight() + 16;
	uint32 nLocalID = 0;
	g_pLTClient->GetLocalClientID (&nLocalID);


	while (pCI && (nTotal < kMaxPlayers))
	{
		uint8 nTeam = 0;
		
		if (IsTeamGameType())
		{
			nTeam = pCI->nTeamID;
		}


		int ndx = count[nTeam];


		
		if (nTeam < kNumTeams)
		{
			sprintf( szTmp, "%s%s",pCI->sName.c_str( ), pCI->bIsAdmin ? "[*]" : "" );
			m_Columns[nTeam][ndx].GetPolyString(0)->SetText( szTmp );
			sprintf(szTmp,"%d",pCI->sScore.GetScore());
			m_Columns[nTeam][ndx].GetPolyString(1)->SetText(szTmp);

			sprintf(szTmp,"%d",pCI->sScore.GetFrags());
			m_Columns[nTeam][ndx].GetPolyString(2)->SetText(szTmp);

			sprintf(szTmp,"%d",pCI->sScore.GetTags());
			m_Columns[nTeam][ndx].GetPolyString(3)->SetText(szTmp);

			sprintf(szTmp,"%d",pCI->nPing);
			m_Columns[nTeam][ndx].GetPolyString(4)->SetText(szTmp);

			if (nLocalID == pCI->nID)
			{
				m_Columns[nTeam][ndx].SetColors(playerTextCol,playerTextCol,playerTextCol);
			}
			else
			{
				m_Columns[nTeam][ndx].SetColors(textCol,textCol,textCol);
			}
			
			m_Columns[nTeam][ndx].Show(LTTRUE);

			nHeight[nTeam] += m_Columns[nTeam][ndx].GetBaseHeight();
		}

		pCI = pCI->pNext;
		++count[nTeam];
	}


	
	for (int team = 0; team < kNumTeams; team++)
	{

		m_Team[team].SetColors(textCol,textCol,textCol);
		m_Rounds[team].SetColors(textCol,textCol,textCol);
		m_Header[team].SetColors(textCol,textCol,textCol);

		nHeight[team] += 16;
		m_Frame[team].SetSize(m_nFrameWidth,nHeight[team]);

		while (count[team] < kMaxPlayers)
		{
			m_Columns[team][count[team]].Show(LTFALSE);
			++count[team];
		}

		LTIntPt pos = m_BasePos;
		if (IsTeamGameType() && team > 0)
		{
			pos.y += nHeight[team-1] + 8;
			UpdateTeamPos(team,pos);
		}

	}
	m_SingleFrame.SetSize(m_nFrameWidth,nHeight[0]+8);


	
}
void CHL2MPRules::Think( void )
{

#ifndef CLIENT_DLL
	
	CGameRules::Think();

	if ( g_fGameOver )   // someone else quit the game already
	{
		// check to see if we should change levels now
		if ( m_flIntermissionEndTime < gpGlobals->curtime )
		{
			ChangeLevel(); // intermission is over
		}

		return;
	}

//	float flTimeLimit = mp_timelimit.GetFloat() * 60;
	float flFragLimit = fraglimit.GetFloat();
	
	if ( GetMapRemainingTime() < 0 )
	{
		GoToIntermission();
		return;
	}

	if ( flFragLimit )
	{
		if( IsTeamplay() == true )
		{
			CTeam *pCombine = g_Teams[TEAM_COMBINE];
			CTeam *pRebels = g_Teams[TEAM_REBELS];

			if ( pCombine->GetRoundScore() >= flFragLimit || pRebels->GetRoundScore() >= flFragLimit )
			{
				GoToIntermission();
				return;
			}
		}
		else
		{
			// check if any player is over the frag limit
			for ( int i = 1; i <= gpGlobals->maxClients; i++ )
			{
				CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );

				if ( pPlayer && pPlayer->FragCount() >= flFragLimit )
				{
					GoToIntermission();
					return;
				}
			}
		}
	}

	if ( gpGlobals->curtime > m_tmNextPeriodicThink )
	{		
		CheckAllPlayersReady();
		CheckRestartGame();
		m_tmNextPeriodicThink = gpGlobals->curtime + 1.0;
	}

	if ( m_flRestartGameTime > 0.0f && m_flRestartGameTime <= gpGlobals->curtime )
	{
		RestartGame();
	}

	if( m_bAwaitingReadyRestart && m_bHeardAllPlayersReady )
	{
		UTIL_ClientPrintAll( HUD_PRINTCENTER, "All players ready. Game will restart in 5 seconds" );
		UTIL_ClientPrintAll( HUD_PRINTCONSOLE, "All players ready. Game will restart in 5 seconds" );

		m_flRestartGameTime = gpGlobals->curtime + 5;
		m_bAwaitingReadyRestart = false;
	}

	ManageObjectRelocation();

#endif
}
Ejemplo n.º 3
0
void CHUDScores::Update()
{
    if( !m_bInitialized )
        return;

    if( !m_bDraw )
        return;

//	uint32 textCol = (m_bScreen ? m_cScreenTextColor : m_cTextColor);
//	uint32 playerTextCol = (m_bScreen ? m_cScreenPlayerTextColor : m_cPlayerTextColor);

    //for the screen mode scoreboard, don't update the text once we've drawn it
    if (m_bScreen && !m_bFirstScreenUpdate)
        return;

    m_bFirstScreenUpdate = false;

    if (GameModeMgr::Instance( ).m_grbUseTeams)
    {
        for( uint8 nTeamNum = 0; nTeamNum < kNumTeams; ++nTeamNum )
        {
            uint8 team;
            if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(nTeamNum))
                team = 0;
            else
                team = 1;

            CTeam* pTeam = CTeamMgr::Instance().GetTeam(nTeamNum);
            if (!pTeam) continue;

            wchar_t wszTmp[128];
            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d",pTeam->GetName(),pTeam->GetScore());
            m_Team[team].SetString(wszTmp);

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d", LoadString("IDS_ROUNDS"), pTeam->GetRoundScore( ));
            m_Rounds[team].SetString(wszTmp);

            m_Header[team].Show(true);
        }

    }
    else
    {
        m_Team[0].SetString(L"");
        m_Rounds[0].SetString(L"");
        m_Header[1].Show(false);
    }


    m_Server.SetColor(m_cTextColor);

    if ( !GameModeMgr::Instance( ).m_grwsSessionName.GetValue().empty())
    {
        std::wstring wstr = GameModeMgr::Instance( ).m_grwsSessionName;
        if ( g_pClientConnectionMgr->IsConnectedToRemoteServer( ))
        {
            wstr += L" : ";
            wstr += MPA2W(g_pClientConnectionMgr->GetStartGameRequest( ).m_TCPAddress).c_str();
        }

        m_Server.SetString(wstr.c_str());
    }
    else
    {
        m_Server.SetString(L"");
    }

    // Update the round counter.
    m_RoundInfo.SetColor(m_cTextColor);
    wchar_t wszRound[32];
    uint8 nCurrentRound = g_pClientConnectionMgr ? g_pClientConnectionMgr->GetCurrentRound() : 0;
    uint8 nNumRounds = GameModeMgr::Instance( ).m_grnNumRounds;
    FormatString( "HUD_SCORES_ROUNDINFO", wszRound, LTARRAYSIZE( wszRound ), nCurrentRound + 1, nNumRounds );
    m_RoundInfo.SetString( wszRound );

    CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr();
    if (!pCIMgr) return;

    CLIENT_INFO* pCI = pCIMgr->GetFirstClient();
    int nTotal = 0;
    int count[kNumTeams] = {0,0};
    wchar_t wszTmp[64] = L"";
    uint32 nHeight[kNumTeams];
    nHeight[0] = m_Server.GetBaseHeight() + m_Header[0].GetBaseHeight() + m_Team[0].GetBaseHeight() + 24;
    nHeight[1] = m_Team[1].GetBaseHeight() + m_Header[1].GetBaseHeight() + 16;
    uint32 nLocalID = 0;
    g_pLTClient->GetLocalClientID (&nLocalID);


    while (pCI && (nTotal < kMaxPlayers))
    {
        uint8 nTeam = 0;
        CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromClientID(pCI->nID);

        if (GameModeMgr::Instance( ).m_grbUseTeams)
        {
            if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(pCI->nTeamID))
                nTeam = 0;
            else
                nTeam = 1;
        }


        int ndx = count[nTeam];



        if (nTeam < kNumTeams)
        {
            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s%s",pCI->sName.c_str( ), pCI->bIsAdmin ? L"[*]" : L"" );
            m_Columns[nTeam][ndx].SetString( eColumnName, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetScore());
            m_Columns[nTeam][ndx].SetString( eColumnScore, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eKill));
            m_Columns[nTeam][ndx].SetString( eColumnKill, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eDeath));
            m_Columns[nTeam][ndx].SetString( eColumnDeath, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eObjective));
            m_Columns[nTeam][ndx].SetString( eColumnObjective, wszTmp );

            if (GameModeMgr::Instance( ).m_grbUseTeams)
            {
                LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eTeamKill));
                m_Columns[nTeam][ndx].SetString( eColumnTK, wszTmp );
                m_Columns[nTeam][ndx].ShowColumn(eColumnTK, true);
            }
            else
            {
                m_Columns[nTeam][ndx].ShowColumn(eColumnTK, false);
            }


            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eSuicide));
            m_Columns[nTeam][ndx].SetString( eColumnSuicide, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->nPing);
            m_Columns[nTeam][ndx].SetString( eColumnPing, wszTmp );

            if (nLocalID == pCI->nID)
            {
                if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating )
                    m_Columns[nTeam][ndx].SetColor(m_cPlayerDeadColor);
                else
                    m_Columns[nTeam][ndx].SetColor(m_cPlayerTextColor);
            }
            else
            {
                if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating )
                    m_Columns[nTeam][ndx].SetColor(m_cDeadColor);
                else
                    m_Columns[nTeam][ndx].SetColor(m_cTextColor);
            }

            m_Columns[nTeam][ndx].Show(true);

            nHeight[nTeam] += m_Columns[nTeam][ndx].GetBaseHeight();
        }

        pCI = pCI->pNext;
        ++count[nTeam];
    }



    for (uint8 team = 0; team < kNumTeams; team++)
    {

        m_Team[team].SetColor(m_cTextColor);
        m_Rounds[team].SetColor(m_cTextColor);
        m_Header[team].SetColor(m_cTextColor);

        nHeight[team] += 16;
        m_Frame[team].SetSize(LTVector2n(m_nFrameWidth,nHeight[team]));

        while (count[team] < kMaxPlayers)
        {
            m_Columns[team][count[team]].Show(false);
            ++count[team];
        }

        LTVector2n pos = m_vBasePos;
        g_pInterfaceResMgr->ScaleScreenPos(pos);
        if (GameModeMgr::Instance( ).m_grbUseTeams && team > 0)
        {
            pos.y += nHeight[team-1] + 8;
        }
        UpdateTeamPos(team,pos);

    }
    m_SingleFrame.SetSize(LTVector2n(m_nFrameWidth,nHeight[0]+8));
}