This commit is contained in:
GreYFoXGTi 2010-11-04 21:18:55 +02:00
commit 9feef5638e
7 changed files with 72 additions and 25 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

View file

@ -76,6 +76,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_BroadCast = true;
m_EyeEmote = true;
m_Fly = true;
m_TimerReseted = false;
m_TeamBeforeSuper = 0;
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
m_Core.Init(&GameServer()->m_World.m_Core, GameServer()->Collision(), &Controller->m_Teams.m_Core);
@ -753,6 +754,16 @@ void CCharacter::Tick()
char aBuftime[128];
m_Time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID());
if(!m_TimerReseted && m_DDRaceState == DDRACE_CHEAT) {
m_TimerReseted = true;
CNetMsg_Sv_DDRaceTime Msg;
Msg.m_Time = 0;
Msg.m_Check = 0;
Msg.m_Finish = 0;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
}
if(Server()->Tick() - m_RefreshTime >= Server()->TickSpeed())
{

View file

@ -131,7 +131,7 @@ public:
CEntity *m_apHitObjects[10];
int m_NumObjectsHit;
bool m_TimerReseted;
int m_QueuedWeapon;

View file

@ -994,8 +994,22 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
Msg.m_Time = TimeToSend;
Msg.m_Cid = i;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
//also send its time to others
}
}
//also send its time to others
if(Score()->PlayerData(ClientId)->m_CurrentTime > 0) {
//TODO: make function for this fucking steps
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%.0f", Score()->PlayerData(ClientId)->m_CurrentTime*100.0f); // damn ugly but the only way i know to do it
int TimeToSend;
sscanf(aBuf, "%d", &TimeToSend);
CNetMsg_Sv_PlayerTime Msg;
Msg.m_Time = TimeToSend;
Msg.m_Cid = ClientId;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
}
}
else if(MsgId == NETMSGTYPE_CL_CHANGEINFO || MsgId == NETMSGTYPE_CL_STARTINFO)
{