Add score board time, need to add in server send time for players if someone enter

This commit is contained in:
btd 2010-11-04 19:39:04 +03:00
parent 5efc7d0d9b
commit 418875b5e5
4 changed files with 46 additions and 24 deletions

View file

@ -143,6 +143,9 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
pTitle = Localize("Score board");
}
float Offset = 80.0f;
float DataOffset = 130;
float tw = TextRender()->TextWidth(0, 48, pTitle, -1);
if(Team == -1)
@ -157,9 +160,6 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
{
char aBuf[128];
int Score = Team ? m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue : m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed;
str_format(aBuf, sizeof(aBuf), "%d", Score);
tw = TextRender()->TextWidth(0, 48, aBuf, -1);
TextRender()->Text(0, x+w-tw-30, y, 48, aBuf, -1);
}
}
@ -190,19 +190,20 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
{
for(int i = 0; i < NumPlayers-k-1; i++)
{
if(paPlayers[i]->m_Score < paPlayers[i+1]->m_Score)
{
const CNetObj_PlayerInfo *pTmp = paPlayers[i];
paPlayers[i] = paPlayers[i+1];
paPlayers[i+1] = pTmp;
}
if(m_pClient->m_aClients[paPlayers[i]->m_ClientId].m_Score == 0 || (m_pClient->m_aClients[paPlayers[i]->m_ClientId].m_Score > m_pClient->m_aClients[paPlayers[i+1]->m_ClientId].m_Score && m_pClient->m_aClients[paPlayers[i+1]->m_ClientId].m_Score != 0))
{
const CNetObj_PlayerInfo *pTmp = paPlayers[i];
paPlayers[i] = paPlayers[i+1];
paPlayers[i+1] = pTmp;
}
}
}
// render headlines
TextRender()->Text(0, x+10, y, 24.0f, Localize("Score"), -1);
TextRender()->Text(0, x+125, y, 24.0f, Localize("Name"), -1);
TextRender()->Text(0, x+w-70, y, 24.0f, Localize("Ping"), -1);
TextRender()->Text(0, x+125+Offset, y, 24.0f, Localize("Name"), -1);
TextRender()->Text(0, x+w-75, y, 24.0f, Localize("Ping"), -1);
y += 29.0f;
float FontSize = 35.0f;
@ -240,21 +241,35 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
float Width;
const float ScoreWidth = 60.0f;
const float PingWidth = 60.0f;
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -9999, 9999));
while((Width = TextRender()->TextWidth(0, FontSizeResize, aBuf, -1)) > ScoreWidth)
--FontSizeResize;
TextRender()->Text(0, x+ScoreWidth-Width, y+(FontSize-FontSizeResize)/2, FontSizeResize, aBuf, -1);
// reset time
if(pInfo->m_Score == -9999)
m_pClient->m_aClients[pInfo->m_ClientId].m_Score = 0;
int Time = m_pClient->m_aClients[pInfo->m_ClientId].m_Score;
if(Time > 0)
{
str_format(aBuf, sizeof(aBuf), "%02d:%02d.%02d", Time/6000, Time/100-(Time/6000*60), Time % 100);
while((Width = TextRender()->TextWidth(0, FontSizeResize, aBuf, -1)) > ScoreWidth)
--FontSizeResize;
TextRender()->Text(0, x+ScoreWidth-Width, y+(FontSize-FontSizeResize * 2.5)/2, FontSizeResize * 2.5, aBuf, -1);
}
FontSizeResize = FontSize;
while(TextRender()->TextWidth(0, FontSizeResize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1) > w-163.0f-PingWidth)
FontSizeResize = FontSize;
while(TextRender()->TextWidth(0, FontSizeResize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1) > w-163.0f-Offset-PingWidth)
--FontSizeResize;
char aId[64] = "";
if (g_Config.m_ClShowIds)
if (g_Config.m_ClShowIds) {
char aId[64] = "";
str_format(aId, sizeof(aId),"%d:", pInfo->m_ClientId);
str_append(aId, m_pClient->m_aClients[pInfo->m_ClientId].m_aName,sizeof(aId));
TextRender()->Text(0, x+128.0f, y+(FontSize-FontSizeResize)/2, FontSizeResize, aId, -1);
str_append(aId, m_pClient->m_aClients[pInfo->m_ClientId].m_aName,sizeof(aId));
}
TextRender()->Text(0, x+128.0f+Offset, y+(FontSize-FontSizeResize)/2, FontSizeResize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1);
FontSizeResize = FontSize;
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, -9999, 9999));
while((Width = TextRender()->TextWidth(0, FontSizeResize, aBuf, -1)) > PingWidth)
--FontSizeResize;
@ -272,14 +287,14 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
float size = 64.0f;
IGraphics::CQuadItem QuadItem(x+55, y-15, size/2, size);
IGraphics::CQuadItem QuadItem(x+55+DataOffset, y-15, size/2, size);
Graphics()->QuadsDrawTL(&QuadItem, 1);
Graphics()->QuadsEnd();
}
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientId].m_RenderInfo;
TeeInfo.m_Size *= TeeSizeMod;
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28+TeeOffset));
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1,0), vec2(x+50+DataOffset, y+28+TeeOffset));
y += LineHeight;
@ -341,7 +356,7 @@ void CScoreboard::OnRender()
Graphics()->MapScreen(0, 0, Width, Height);
float w = 650.0f;
float w = 750.0f;
if(m_pClient->m_Snap.m_pGameobj && !(m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS))
{

View file

@ -20,6 +20,7 @@ public:
virtual void OnRender();
virtual void OnRelease();
bool Active();
};

View file

@ -603,7 +603,11 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
{
dbg_msg1("Teams", "Team = %d", m_Teams.Team(i));
}
} else if(MsgId == NETMSGTYPE_SV_PLAYERTIME) {
CNetMsg_Sv_PlayerTime *pMsg = (CNetMsg_Sv_PlayerTime *)pRawMsg;
m_aClients[pMsg->m_Cid].m_Score = pMsg->m_Time;
}
}
void CGameClient::OnStateChange(int NewState, int OldState)

View file

@ -154,6 +154,8 @@ public:
int m_EmoticonStart;
CCharacterCore m_Predicted;
int m_Score;
CTeeRenderInfo m_SkinInfo; // this is what the server reports
CTeeRenderInfo m_RenderInfo; // this is what we use