2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-09-07 17:03:59 +00:00
|
|
|
#include <engine/demo.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/graphics.h>
|
|
|
|
#include <engine/textrender.h>
|
|
|
|
#include <engine/shared/config.h>
|
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
#include <game/generated/client_data.h>
|
|
|
|
#include <game/client/gameclient.h>
|
|
|
|
#include <game/client/animstate.h>
|
|
|
|
#include <game/client/render.h>
|
|
|
|
#include <game/client/components/motd.h>
|
|
|
|
#include <game/localization.h>
|
|
|
|
#include "scoreboard.h"
|
|
|
|
|
|
|
|
|
|
|
|
CScoreboard::CScoreboard()
|
2008-08-27 19:50:33 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
OnReset();
|
2008-08-27 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
2010-08-25 20:30:21 +00:00
|
|
|
void CScoreboard::ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData, int ClientID)
|
2008-08-27 19:50:33 +00:00
|
|
|
{
|
2011-01-06 04:45:53 +00:00
|
|
|
CScoreboard *pSelf = (CScoreboard *)pUserData;
|
|
|
|
pSelf->Client()->GetServerInfo(&pSelf->m_pServerInfo);
|
|
|
|
pSelf->m_Active = pResult->GetInteger(0) != 0;
|
2008-08-27 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CScoreboard::OnReset()
|
2008-08-27 19:50:33 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Active = false;
|
2008-08-27 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
2010-09-12 10:43:03 +00:00
|
|
|
void CScoreboard::OnRelease()
|
|
|
|
{
|
|
|
|
m_Active = false;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CScoreboard::OnConsoleInit()
|
2008-08-27 19:50:33 +00:00
|
|
|
{
|
2010-08-25 20:30:21 +00:00
|
|
|
Console()->Register("+scoreboard", "", CFGFLAG_CLIENT, ConKeyScoreboard, this, "Show scoreboard", 0);
|
2008-08-27 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CScoreboard::RenderGoals(float x, float y, float w)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
float h = 50.0f;
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(0,0,0,0.5f);
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->DrawRoundRect(x-10.f, y-10.f, w, h, 10.0f);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render goals
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameobj)
|
2008-09-07 15:07:08 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameobj->m_ScoreLimit)
|
|
|
|
{
|
|
|
|
char aBuf[64];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Score limit"), m_pClient->m_Snap.m_pGameobj->m_ScoreLimit);
|
2011-01-17 15:31:24 +00:00
|
|
|
TextRender()->Text(0, x, y, 20.0f, aBuf, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
if(m_pClient->m_Snap.m_pGameobj->m_TimeLimit)
|
|
|
|
{
|
|
|
|
char aBuf[64];
|
2010-11-19 19:20:51 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), Localize("Time limit: %d min"), m_pClient->m_Snap.m_pGameobj->m_TimeLimit);
|
2011-01-17 15:31:24 +00:00
|
|
|
TextRender()->Text(0, x+220.0f, y, 20.0f, aBuf, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
if(m_pClient->m_Snap.m_pGameobj->m_RoundNum && m_pClient->m_Snap.m_pGameobj->m_RoundCurrent)
|
|
|
|
{
|
|
|
|
char aBuf[64];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s %d/%d", Localize("Round"), m_pClient->m_Snap.m_pGameobj->m_RoundCurrent, m_pClient->m_Snap.m_pGameobj->m_RoundNum);
|
2011-01-17 15:31:24 +00:00
|
|
|
float tw = TextRender()->TextWidth(0, 20.0f, aBuf, -1);
|
|
|
|
TextRender()->Text(0, x+w-tw-20.0f, y, 20.0f, aBuf, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CScoreboard::RenderSpectators(float x, float y, float w)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
char aBuffer[1024*4];
|
|
|
|
int Count = 0;
|
2008-08-27 15:48:50 +00:00
|
|
|
float h = 120.0f;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
str_format(aBuffer, sizeof(aBuffer), "%s: ", Localize("Spectators"));
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(0,0,0,0.5f);
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->DrawRoundRect(x-10.f, y-10.f, w, h, 10.0f);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int i = 0; i < Client()->SnapNumItems(IClient::SNAP_CURRENT); i++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
IClient::CSnapItem Item;
|
|
|
|
const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Item.m_Type == NETOBJTYPE_PLAYERINFO)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
const CNetObj_PlayerInfo *pInfo = (const CNetObj_PlayerInfo *)pData;
|
2011-01-03 11:50:38 +00:00
|
|
|
if(pInfo->m_Team == TEAM_SPECTATORS)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Count)
|
|
|
|
str_append(aBuffer, ", ", sizeof(aBuffer));
|
2011-01-06 04:45:53 +00:00
|
|
|
if(!str_comp_nocase(m_pServerInfo.m_aGameType, "DDRace"))
|
|
|
|
if (g_Config.m_ClShowIds)
|
|
|
|
{
|
|
|
|
char aId[4];
|
|
|
|
str_format(aId,sizeof(aId),"%d:",pInfo->m_ClientId);
|
|
|
|
str_append(aBuffer, aId, sizeof(aBuffer));
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
str_append(aBuffer, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, sizeof(aBuffer));
|
|
|
|
Count++;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->Text(0, x+10, y, 32, aBuffer, (int)w-20);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const char *pTitle)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-01-11 22:03:01 +00:00
|
|
|
if(Team == TEAM_SPECTATORS)
|
|
|
|
return;
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
//float ystart = y;
|
2011-01-17 12:55:14 +00:00
|
|
|
float h = 740.0f;
|
2010-09-27 19:41:41 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(0,0,0,0.5f);
|
2011-01-17 12:55:14 +00:00
|
|
|
RenderTools()->DrawRoundRect(x-10.f, y, w, h, 17.0f);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render title
|
2010-05-29 07:25:38 +00:00
|
|
|
if(!pTitle)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameobj->m_GameOver)
|
|
|
|
pTitle = Localize("Game over");
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
pTitle = Localize("Score board");
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-09-27 19:41:41 +00:00
|
|
|
|
2010-11-04 16:39:04 +00:00
|
|
|
float Offset = 80.0f;
|
|
|
|
float DataOffset = 130;
|
2010-05-29 07:25:38 +00:00
|
|
|
float tw = TextRender()->TextWidth(0, 48, pTitle, -1);
|
2011-01-11 22:03:01 +00:00
|
|
|
TextRender()->Text(0, x+10, y, 48, pTitle, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-01-12 09:08:17 +00:00
|
|
|
if(str_comp_nocase(m_pServerInfo.m_aGameType, "DDRace"))
|
|
|
|
if(m_pClient->m_Snap.m_pGameobj)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-01-12 09:08:17 +00:00
|
|
|
char aBuf[128];
|
|
|
|
int Score = Team == TEAM_RED ? m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed : m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue;
|
|
|
|
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);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
y += 54.0f;
|
|
|
|
|
|
|
|
// render headlines
|
2010-05-29 07:25:38 +00:00
|
|
|
TextRender()->Text(0, x+10, y, 24.0f, Localize("Score"), -1);
|
2011-01-06 04:45:53 +00:00
|
|
|
if(!str_comp_nocase(m_pServerInfo.m_aGameType, "DDRace"))
|
|
|
|
{
|
|
|
|
TextRender()->Text(0, x+125+Offset, y, 24.0f, Localize("Name"), -1);
|
|
|
|
TextRender()->Text(0, x+w-75, y, 24.0f, Localize("Ping"), -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TextRender()->Text(0, x+125, y, 24.0f, Localize("Name"), -1);
|
|
|
|
TextRender()->Text(0, x+w-70, y, 24.0f, Localize("Ping"), -1);
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
y += 29.0f;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float FontSize = 35.0f;
|
|
|
|
float LineHeight = 50.0f;
|
|
|
|
float TeeSizeMod = 1.0f;
|
|
|
|
float TeeOffset = 0.0f;
|
2010-09-27 19:41:41 +00:00
|
|
|
|
2011-01-11 22:03:01 +00:00
|
|
|
if(m_pClient->m_Snap.m_aTeamSize[Team] > 13)
|
2009-05-31 09:44:20 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
FontSize = 30.0f;
|
|
|
|
LineHeight = 40.0f;
|
|
|
|
TeeSizeMod = 0.8f;
|
|
|
|
TeeOffset = -5.0f;
|
2009-05-31 09:44:20 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// render player scores
|
2011-01-11 22:03:01 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-01-11 22:03:01 +00:00
|
|
|
const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paInfoByScore[i];
|
|
|
|
if(!pInfo || pInfo->m_Team != Team)
|
|
|
|
continue;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// make sure that we render the correct team
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
char aBuf[128];
|
|
|
|
if(pInfo->m_Local)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
// background so it's easy to find the local player
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(1,1,1,0.25f);
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->DrawRoundRect(x, y, w-20, LineHeight*0.95f, 17.0f);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-09-13 04:30:05 +00:00
|
|
|
|
2010-09-27 19:41:41 +00:00
|
|
|
float FontSizeResize = FontSize;
|
|
|
|
float Width;
|
2011-01-06 04:45:53 +00:00
|
|
|
if(!str_comp_nocase(m_pServerInfo.m_aGameType, "DDRace"))
|
2010-11-29 02:46:45 +00:00
|
|
|
{
|
2011-01-06 04:45:53 +00:00
|
|
|
const float ScoreWidth = 150.0f;
|
|
|
|
const float PingWidth = 60.0f;
|
|
|
|
|
|
|
|
// 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, FontSizeResize, aBuf, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FontSizeResize = FontSize;
|
|
|
|
|
|
|
|
|
|
|
|
while(TextRender()->TextWidth(0, FontSizeResize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1) > w-163.0f-Offset-PingWidth)
|
|
|
|
--FontSizeResize;
|
|
|
|
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+Offset, y+(FontSize-FontSizeResize)/2, FontSizeResize, aId, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
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;
|
2010-11-04 16:39:04 +00:00
|
|
|
}
|
2010-11-29 02:46:45 +00:00
|
|
|
else
|
2011-01-06 04:45:53 +00:00
|
|
|
{
|
|
|
|
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);
|
2010-09-27 19:41:41 +00:00
|
|
|
|
2011-01-06 04:45:53 +00:00
|
|
|
|
|
|
|
FontSizeResize = FontSize;
|
|
|
|
while(TextRender()->TextWidth(0, FontSizeResize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1) > w-163.0f-PingWidth)
|
|
|
|
--FontSizeResize;
|
|
|
|
TextRender()->Text(0, x+128.0f, 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;
|
|
|
|
}
|
2010-09-27 19:41:41 +00:00
|
|
|
TextRender()->Text(0, x+w-35.0f-Width, y+(FontSize-FontSizeResize)/2, FontSizeResize, aBuf, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render avatar
|
2010-05-29 07:25:38 +00:00
|
|
|
if((m_pClient->m_Snap.m_paFlags[0] && m_pClient->m_Snap.m_paFlags[0]->m_CarriedBy == pInfo->m_ClientId) ||
|
|
|
|
(m_pClient->m_Snap.m_paFlags[1] && m_pClient->m_Snap.m_paFlags[1]->m_CarriedBy == pInfo->m_ClientId))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsBegin();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-01-03 11:50:38 +00:00
|
|
|
if(pInfo->m_Team == TEAM_RED) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X);
|
2010-05-29 07:25:38 +00:00
|
|
|
else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
float size = 64.0f;
|
2011-01-06 04:45:53 +00:00
|
|
|
IGraphics::CQuadItem QuadItem;
|
|
|
|
if(!str_comp_nocase(m_pServerInfo.m_aGameType, "DDRace"))
|
|
|
|
QuadItem = IGraphics::CQuadItem(x+55+DataOffset, y-15, size/2, size);
|
|
|
|
else
|
|
|
|
QuadItem = IGraphics::CQuadItem(x+55, y-15, size/2, size);
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientId].m_RenderInfo;
|
|
|
|
TeeInfo.m_Size *= TeeSizeMod;
|
2011-01-06 04:45:53 +00:00
|
|
|
|
|
|
|
if(!str_comp_nocase(m_pServerInfo.m_aGameType, "DDRace"))
|
|
|
|
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1,0), vec2(x+50+DataOffset, y+28+TeeOffset));
|
|
|
|
else
|
|
|
|
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1,0), vec2(x+90, y+28+TeeOffset));
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
y += LineHeight;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-07 17:03:59 +00:00
|
|
|
void CScoreboard::RenderRecordingNotification(float x)
|
|
|
|
{
|
|
|
|
if(!m_pClient->DemoRecorder()->IsRecording())
|
|
|
|
return;
|
|
|
|
|
|
|
|
//draw the box
|
|
|
|
Graphics()->BlendNormal();
|
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.4f);
|
|
|
|
RenderTools()->DrawRoundRectExt(x, 0.0f, 120.0f, 50.0f, 15.0f, CUI::CORNER_B);
|
|
|
|
Graphics()->QuadsEnd();
|
|
|
|
|
|
|
|
//draw the red dot
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
RenderTools()->DrawRoundRect(x+20, 15.0f, 20.0f, 20.0f, 10.0f);
|
|
|
|
Graphics()->QuadsEnd();
|
|
|
|
|
|
|
|
//draw the text
|
2010-10-10 22:16:37 +00:00
|
|
|
TextRender()->Text(0, x+50.0f, 8.0f, 24.0f, Localize("REC"), -1);
|
2010-09-07 17:03:59 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CScoreboard::OnRender()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-01-17 12:42:40 +00:00
|
|
|
if(!Active())
|
2008-08-31 21:50:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// if the score board is active, then we should clear the motd message aswell
|
2010-08-15 13:48:56 +00:00
|
|
|
if(m_pClient->m_pMotd->IsActive())
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pClient->m_pMotd->Clear();
|
2008-08-31 21:50:14 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float Width = 400*3.0f*Graphics()->ScreenAspect();
|
|
|
|
float Height = 400*3.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->MapScreen(0, 0, Width, Height);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-01-06 04:45:53 +00:00
|
|
|
float w;
|
|
|
|
if(!str_comp_nocase(m_pServerInfo.m_aGameType, "DDRace"))
|
|
|
|
w = 750.0f;
|
|
|
|
else
|
|
|
|
w = 650.0f;
|
2010-09-27 19:41:41 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameobj && !(m_pClient->m_Snap.m_pGameobj->m_Flags&GAMEFLAG_TEAMS))
|
|
|
|
RenderScoreboard(Width/2-w/2, 150.0f, w, 0, 0);
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
const char *pText = Localize("Draw!");
|
|
|
|
if(m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed > m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue)
|
|
|
|
pText = Localize("Red team wins!");
|
|
|
|
else if(m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue > m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed)
|
|
|
|
pText = Localize("Blue team wins!");
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-01-12 00:10:40 +00:00
|
|
|
float w = TextRender()->TextWidth(0, 86.0f, pText, -1);
|
|
|
|
TextRender()->Text(0, Width/2-w/2, 39, 86.0f, pText, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 11:50:38 +00:00
|
|
|
RenderScoreboard(Width/2-w-20, 150.0f, w, TEAM_RED, Localize("Red team"));
|
|
|
|
RenderScoreboard(Width/2 + 20, 150.0f, w, TEAM_BLUE, Localize("Blue team"));
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderGoals(Width/2-w/2, 150+750+25, w);
|
|
|
|
RenderSpectators(Width/2-w/2, 150+750+25+50+25, w);
|
2010-09-07 17:03:59 +00:00
|
|
|
RenderRecordingNotification((Width/7)*4);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-08-18 01:57:35 +00:00
|
|
|
|
|
|
|
bool CScoreboard::Active()
|
|
|
|
{
|
2011-01-17 12:42:40 +00:00
|
|
|
// if we activly wanna look on the scoreboard
|
|
|
|
if(m_Active)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS)
|
|
|
|
{
|
|
|
|
// we are not a spectator, check if we are dead
|
2011-01-18 17:53:19 +00:00
|
|
|
if(!m_pClient->m_Snap.m_pLocalCharacter)
|
2011-01-17 12:42:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the game is over
|
|
|
|
if(m_pClient->m_Snap.m_pGameobj && m_pClient->m_Snap.m_pGameobj->m_GameOver)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2010-08-18 01:57:35 +00:00
|
|
|
}
|