Пример #1
0
void CInterfaceTimer::Draw(HSURFACE hScreen)
{
	if (!hScreen) return;

	// Get the screen size

    uint32 nWidth = 0;
    uint32 nHeight = 0;
    g_pLTClient->GetSurfaceDims(hScreen, &nWidth, &nHeight);

	// Update/Draw the timer if there is anytime left...

	if (m_fTime > 0.0f)
	{
		int x = nWidth/2;
		int y = 40;

		// Draw the string to the surface...

		int nMinutes = int(m_fTime) / 60;
		int nSeconds = m_fTime > 60.0 ? int(m_fTime) % 60 : int(m_fTime);

		char aBuffer[50];
		char aMinutes[20];
		char aSeconds[20];
		BuildTimeString(aMinutes, nMinutes);
		BuildTimeString(aSeconds, nSeconds);

		sprintf(aBuffer, "%s:%s", aMinutes, aSeconds);
        HSTRING hStr = g_pLTClient->CreateString(aBuffer);

		CLTGUIFont* pFont = g_pInterfaceResMgr->GetTitleFont();
        LTIntPt size = pFont->GetTextExtents(hStr);
		pFont->Draw(hStr, hScreen, x - (size.x/2)+2, y - (size.y/2)+2, LTF_JUSTIFY_LEFT,kBlack);
		pFont->Draw(hStr, hScreen, x - (size.x/2), y - (size.y/2), LTF_JUSTIFY_LEFT,kWhite);

        g_pLTClient->FreeString(hStr);
	}

	if (!m_bPause)
		m_fTime -= g_pGameClientShell->GetFrameTime();
}
void CClientInfoMgr::Draw (LTBOOL bDrawSingleFragCount, LTBOOL bDrawAllFragCounts, HSURFACE hDestSurf)
{
	if (!m_pClients || (!bDrawSingleFragCount && !bDrawAllFragCounts)) return;

	// make sure we're in a network game
	if (g_pGameClientShell->GetGameType() == SINGLE) return;

	HSURFACE hScreen = hDestSurf;
	if (!hScreen)
		hScreen = g_pLTClient->GetScreenSurface();
	if (!hScreen)
		return;

    uint32 nScreenWidth = 0;
    uint32 nScreenHeight = 0;
	g_pLTClient->GetSurfaceDims (hScreen, &nScreenWidth, &nScreenHeight);

	CLTGUIFont *pFont = g_pInterfaceResMgr->GetMsgForeFont();

	// should we draw our frag count?
	if (bDrawSingleFragCount)
	{
		
		if (m_hTeamScore)
		{
			pFont->Draw(m_hTeamScore,hScreen,nScreenWidth-m_TeamPos.x+1,m_TeamPos.y+1,LTF_JUSTIFY_LEFT);	
			pFont->Draw(m_hTeamScore,hScreen,nScreenWidth-m_TeamPos.x,m_TeamPos.y,LTF_JUSTIFY_LEFT,m_hTeamColor);	
		}
		if (m_hOppScore)
		{
			pFont->Draw(m_hOppScore,hScreen,nScreenWidth-m_OppPos.x+1,m_OppPos.y+1,LTF_JUSTIFY_LEFT);	
			pFont->Draw(m_hOppScore,hScreen,nScreenWidth-m_OppPos.x,m_OppPos.y,LTF_JUSTIFY_LEFT,m_hOppColor);	
		}
		if (m_hFragString)
		{
			pFont->Draw(m_hFragString,hScreen,nScreenWidth-m_FragPos.x+1,m_FragPos.y+1,LTF_JUSTIFY_LEFT);	
			pFont->Draw(m_hFragString,hScreen,nScreenWidth-m_FragPos.x,m_FragPos.y,LTF_JUSTIFY_LEFT,m_hTeamColor);	
		}
	}

	// should we draw all the frag counts?

	if (bDrawAllFragCounts)
	{
		int nHeight[2] = {0,0};
		int nClients = 0;
		int nTeams[2] = {0,0};
		int nLineHeight = pFont->GetHeight() + VERT_SPACING;

		int nMaxHeight = nScreenHeight - 16;

		CLIENT_INFO* pClient = m_pClients;
		while (pClient)
		{
			if (pClient->team == 2)
			{
				nHeight[1] += nLineHeight;
				nTeams[1]++;
			}
			else
			{
				nHeight[0] += nLineHeight;
				nTeams[0]++;
			}
			++nClients;
			pClient = pClient->pNext;
		}

		int nTotalHeight = Max(nHeight[0],nHeight[1]);
		if (nTotalHeight > nMaxHeight)
			nTotalHeight = nMaxHeight;

		int nY = ((int)nScreenHeight - nTotalHeight) / 2;
		if (nY < 0) nY = 0;
		int nY2 = nY;

		int nX  = 64;
		int nX2 = 32 + (int)nScreenWidth / 2;
		int nTab = ((int)nScreenWidth / 2) - 32;
		int nTab2 = (int)nScreenWidth - 64;

		
		if (g_pGameClientShell->GetGameType() == COOPERATIVE_ASSAULT)
		{
			LTRect rcBanner(nX-8,nY-8,nTab+8,nY+nTotalHeight);
			if (m_Teams[0].hBanner)
				g_pLTClient->ScaleSurfaceToSurface(hScreen, m_Teams[0].hBanner, &rcBanner, LTNULL);

			rcBanner = LTRect(nX2-8,nY-8,nTab2+8,nY+nTotalHeight);
			if (m_Teams[1].hBanner)
				g_pLTClient->ScaleSurfaceToSurface(hScreen, m_Teams[1].hBanner, &rcBanner, LTNULL);
		}

        LTBOOL filled[2] = {LTFALSE, LTFALSE};
		
		pClient = m_pClients;
		while (pClient)
		{
			char str[64];
			sprintf(str,"%d (%d)",pClient->nFrags,(uint32)pClient->m_Ping);
			LTBOOL bIsLocal = (pClient->nID == m_nLocalID);
			HLTCOLOR hColor = kWhite;
			if (bIsLocal)
			{
				hColor = SETRGB(255,255,0);
			}
			
			if (pClient->team == 2)
			{
				if (!filled[1])
				{
					// Ok.. draw.
					pFont->Draw(pClient->hstrName,hScreen,nX2+1,nY2+1,LTF_JUSTIFY_LEFT);	
					pFont->Draw(pClient->hstrName,hScreen,nX2,nY2,LTF_JUSTIFY_LEFT,hColor);
					pFont->Draw(str,hScreen,nTab2+1,nY2+1,LTF_JUSTIFY_RIGHT);	
					pFont->Draw(str,hScreen,nTab2,nY2,LTF_JUSTIFY_RIGHT,hColor);


					nY2 += nLineHeight;
					if (nY2 + nLineHeight > (int)nMaxHeight)
					{
                        filled[1] = LTTRUE;
					}

				}
			}
			else if (!filled[0])
			{
				// Ok.. draw.
				pFont->Draw(pClient->hstrName,hScreen,nX+1,nY+1,LTF_JUSTIFY_LEFT);	
				pFont->Draw(str,hScreen,nTab+1,nY+1,LTF_JUSTIFY_RIGHT);	
				pFont->Draw(pClient->hstrName,hScreen,nX,nY,LTF_JUSTIFY_LEFT,hColor);
				pFont->Draw(str,hScreen,nTab,nY,LTF_JUSTIFY_RIGHT,hColor);

				nY += nLineHeight;
				if (nY + nLineHeight > (int)nMaxHeight)
				{
                    filled[0] = LTTRUE;
				}

			}

			pClient = pClient->pNext;

		}
	}
}