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>
|
2011-03-19 17:28:47 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/generated/client_data.h>
|
2011-03-19 17:28:47 +00:00
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
|
|
|
|
#include <game/localization.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/animstate.h>
|
2011-03-19 17:28:47 +00:00
|
|
|
#include <game/client/gameclient.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/render.h>
|
2011-03-19 17:28:47 +00:00
|
|
|
#include <game/client/components/countryflags.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/components/motd.h>
|
2011-03-19 17:28:47 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#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-05-29 07:25:38 +00:00
|
|
|
void CScoreboard::ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData)
|
2008-08-27 19:50:33 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
((CScoreboard *)pUserData)->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-05-29 07:25:38 +00:00
|
|
|
Console()->Register("+scoreboard", "", CFGFLAG_CLIENT, ConKeyScoreboard, this, "Show scoreboard");
|
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);
|
2011-03-19 17:28:47 +00:00
|
|
|
RenderTools()->DrawRoundRect(x-10.f, y, w, h, 10.0f);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render goals
|
2011-03-19 17:28:47 +00:00
|
|
|
y += 10.0f;
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj)
|
2008-09-07 15:07:08 +00:00
|
|
|
{
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_ScoreLimit)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
char aBuf[64];
|
2011-03-04 16:08:10 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Score limit"), m_pClient->m_Snap.m_pGameInfoObj->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
|
|
|
}
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
char aBuf[64];
|
2011-03-04 16:08:10 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), Localize("Time limit: %d min"), m_pClient->m_Snap.m_pGameInfoObj->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
|
|
|
}
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_RoundNum && m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
char aBuf[64];
|
2011-03-04 16:08:10 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%s %d/%d", Localize("Round"), m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent, m_pClient->m_Snap.m_pGameInfoObj->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
|
|
|
{
|
2011-03-19 17:28:47 +00:00
|
|
|
float h = 140.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
// background
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(0,0,0,0.5f);
|
2011-03-19 17:28:47 +00:00
|
|
|
RenderTools()->DrawRoundRect(x-10.f, y, w, h, 10.0f);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2011-03-19 17:28:47 +00:00
|
|
|
|
|
|
|
// Headline
|
|
|
|
y += 10.0f;
|
|
|
|
TextRender()->Text(0, x, y, 28.0f, Localize("Spectators"), w-20.0f);
|
|
|
|
|
|
|
|
// spectator names
|
|
|
|
y += 30.0f;
|
|
|
|
char aBuffer[1024*4];
|
|
|
|
aBuffer[0] = 0;
|
|
|
|
bool Multiple = false;
|
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-03-19 17:28:47 +00:00
|
|
|
const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paPlayerInfos[i];
|
|
|
|
if(!pInfo || pInfo->m_Team != TEAM_SPECTATORS)
|
|
|
|
continue;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
if(Multiple)
|
|
|
|
str_append(aBuffer, ", ", sizeof(aBuffer));
|
|
|
|
str_append(aBuffer, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, sizeof(aBuffer));
|
|
|
|
Multiple = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-03-19 17:28:47 +00:00
|
|
|
CTextCursor Cursor;
|
|
|
|
TextRender()->SetCursor(&Cursor, x, y, 22.0f, TEXTFLAG_RENDER);
|
|
|
|
Cursor.m_LineWidth = w-20.0f;
|
|
|
|
Cursor.m_MaxLines = 4;
|
|
|
|
TextRender()->TextEx(&Cursor, aBuffer, -1);
|
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;
|
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
float h = 760.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
// background
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
2011-03-19 17:28:47 +00:00
|
|
|
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.5f);
|
|
|
|
RenderTools()->DrawRoundRect(x, 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
|
2011-03-19 17:28:47 +00:00
|
|
|
float TitleFontsize = 40.0f;
|
2010-05-29 07:25:38 +00:00
|
|
|
if(!pTitle)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
|
2010-05-29 07:25:38 +00:00
|
|
|
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
|
|
|
}
|
2011-03-19 17:28:47 +00:00
|
|
|
TextRender()->Text(0, x+30, y, TitleFontsize, pTitle, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
char aBuf[128] = {0};
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS)
|
|
|
|
{
|
|
|
|
if(m_pClient->m_Snap.m_pGameDataObj)
|
|
|
|
{
|
|
|
|
int Score = Team == TEAM_RED ? m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed : m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue;
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", Score);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-03-12 17:07:57 +00:00
|
|
|
if(m_pClient->m_Snap.m_pLocalInfo)
|
|
|
|
{
|
|
|
|
int Score = m_pClient->m_Snap.m_pLocalInfo->m_Score;
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", Score);
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-03-19 17:28:47 +00:00
|
|
|
float tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1);
|
|
|
|
TextRender()->Text(0, x+w-tw-30, y, TitleFontsize, aBuf, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
// calculate measurements
|
|
|
|
x += 10.0f;
|
|
|
|
float LineHeight = 60.0f;
|
2010-05-29 07:25:38 +00:00
|
|
|
float TeeSizeMod = 1.0f;
|
2011-03-19 17:28:47 +00:00
|
|
|
float Spacing = 10.0f;
|
|
|
|
if(m_pClient->m_Snap.m_aTeamSize[Team] > 12)
|
2009-05-31 09:44:20 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
LineHeight = 40.0f;
|
|
|
|
TeeSizeMod = 0.8f;
|
2011-03-19 17:28:47 +00:00
|
|
|
Spacing = 0.0f;
|
|
|
|
}
|
|
|
|
else if(m_pClient->m_Snap.m_aTeamSize[Team] > 8)
|
|
|
|
{
|
|
|
|
LineHeight = 50.0f;
|
|
|
|
TeeSizeMod = 0.9f;
|
|
|
|
Spacing = 5.0f;
|
2009-05-31 09:44:20 +00:00
|
|
|
}
|
2011-03-19 17:28:47 +00:00
|
|
|
|
|
|
|
float ScoreOffset = x+10.0f, ScoreLength = 60.0f;
|
|
|
|
float TeeOffset = ScoreOffset+ScoreLength, TeeLength = 60*TeeSizeMod;
|
|
|
|
float NameOffset = TeeOffset+TeeLength, NameLength = 300.0f-TeeLength;
|
|
|
|
float PingOffset = x+600.0f, PingLength = 70.0f;
|
|
|
|
float CountryOffset = PingOffset-(LineHeight-Spacing-TeeSizeMod*5.0f)*96.0f/64.0f, CountryLength = (LineHeight-Spacing-TeeSizeMod*5.0f)*96.0f/64.0f;
|
|
|
|
float ClanOffset = x+370.0f, ClanLength = 230.0f-CountryLength;
|
|
|
|
|
|
|
|
// render headlines
|
|
|
|
y += 50.0f;
|
|
|
|
float HeadlineFontsize = 22.0f;
|
|
|
|
TextRender()->Text(0, ScoreOffset, y, HeadlineFontsize, Localize("Score"), -1);
|
|
|
|
TextRender()->Text(0, NameOffset+10.0f, y, HeadlineFontsize, Localize("Name"), -1);
|
|
|
|
TextRender()->Text(0, ClanOffset+10.0f, y, HeadlineFontsize, Localize("Clan"), -1);
|
|
|
|
TextRender()->Text(0, PingOffset+10.0f, y, HeadlineFontsize, Localize("Ping"), -1);
|
|
|
|
|
|
|
|
// render player entries
|
|
|
|
y += HeadlineFontsize*2.0f;
|
|
|
|
float FontSize = 24.0f;
|
|
|
|
CTextCursor Cursor;
|
2009-05-31 09:44:20 +00:00
|
|
|
|
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-03-19 17:28:47 +00:00
|
|
|
// make sure that we render the correct team
|
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
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
// background so it's easy to find the local player
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pInfo->m_Local)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
2011-03-19 17:28:47 +00:00
|
|
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
|
|
|
|
RenderTools()->DrawRoundRect(x, y, w-20.0f, LineHeight, 15.0f);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
// score
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -999, 999));
|
|
|
|
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
|
|
|
|
TextRender()->SetCursor(&Cursor, ScoreOffset+ScoreLength-tw, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
Cursor.m_LineWidth = ScoreLength;
|
|
|
|
TextRender()->TextEx(&Cursor, aBuf, -1);
|
|
|
|
|
|
|
|
// flag
|
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_FLAGS &&
|
2011-03-04 16:08:10 +00:00
|
|
|
m_pClient->m_Snap.m_pGameDataObj && (m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierRed == pInfo->m_ClientID ||
|
|
|
|
m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierBlue == 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-03-04 16:08:10 +00:00
|
|
|
RenderTools()->SelectSprite(pInfo->m_Team==TEAM_RED ? SPRITE_FLAG_BLUE : SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
float Size = LineHeight;
|
|
|
|
IGraphics::CQuadItem QuadItem(TeeOffset+0.0f, y-5.0f-Spacing/2.0f, Size/2.0f, 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
|
|
|
}
|
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
// avatar
|
2011-02-12 10:40:36 +00:00
|
|
|
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientID].m_RenderInfo;
|
2010-05-29 07:25:38 +00:00
|
|
|
TeeInfo.m_Size *= TeeSizeMod;
|
2011-03-19 17:28:47 +00:00
|
|
|
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(TeeOffset+TeeLength/2, y+LineHeight/2));
|
|
|
|
|
|
|
|
// name
|
|
|
|
TextRender()->SetCursor(&Cursor, NameOffset, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
Cursor.m_LineWidth = NameLength;
|
|
|
|
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1);
|
|
|
|
|
|
|
|
// clan
|
|
|
|
TextRender()->SetCursor(&Cursor, ClanOffset, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
Cursor.m_LineWidth = ClanLength;
|
|
|
|
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);
|
|
|
|
|
|
|
|
// country flag
|
|
|
|
Graphics()->TextureSet(m_pClient->m_pCountryFlags->Get(m_pClient->m_aClients[pInfo->m_ClientID].m_Country)->m_Texture);
|
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
IGraphics::CQuadItem QuadItem(CountryOffset, y+(Spacing+TeeSizeMod*5.0f)/2.0f, CountryLength, LineHeight-Spacing-TeeSizeMod*5.0f);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
|
|
|
Graphics()->QuadsEnd();
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
// ping
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, 0, 1000));
|
|
|
|
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1);
|
|
|
|
TextRender()->SetCursor(&Cursor, PingOffset+PingLength-tw, y+Spacing, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
|
|
|
Cursor.m_LineWidth = PingLength;
|
|
|
|
TextRender()->TextEx(&Cursor, aBuf, -1);
|
|
|
|
|
|
|
|
y += LineHeight+Spacing;
|
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);
|
2011-03-12 17:34:16 +00:00
|
|
|
RenderTools()->DrawRoundRectExt(x, 0.0f, 180.0f, 50.0f, 15.0f, CUI::CORNER_B);
|
2010-09-07 17:03:59 +00:00
|
|
|
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
|
2011-03-12 17:34:16 +00:00
|
|
|
char aBuf[64];
|
2011-03-13 09:41:10 +00:00
|
|
|
int Seconds = m_pClient->DemoRecorder()->Length();
|
2011-03-12 17:34:16 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), Localize("REC %3d:%02d"), Seconds/60, Seconds%60);
|
|
|
|
TextRender()->Text(0, x+50.0f, 10.0f, 20.0f, aBuf, -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-03-19 17:28:47 +00:00
|
|
|
float w = 700.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2011-03-04 16:08:10 +00:00
|
|
|
if(!(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS))
|
|
|
|
RenderScoreboard(Width/2-w/2, 150.0f, w, 0, 0);
|
|
|
|
else
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER && m_pClient->m_Snap.m_pGameDataObj)
|
|
|
|
{
|
|
|
|
const char *pText = Localize("Draw!");
|
|
|
|
if(m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed > m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue)
|
|
|
|
pText = Localize("Red team wins!");
|
|
|
|
else if(m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue > m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed)
|
|
|
|
pText = Localize("Blue team wins!");
|
|
|
|
|
|
|
|
float w = TextRender()->TextWidth(0, 86.0f, pText, -1);
|
|
|
|
TextRender()->Text(0, Width/2-w/2, 39, 86.0f, pText, -1);
|
|
|
|
}
|
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
RenderScoreboard(Width/2-w-5.0f, 150.0f, w, TEAM_RED, Localize("Red team"));
|
|
|
|
RenderScoreboard(Width/2+5.0f, 150.0f, w, TEAM_BLUE, Localize("Blue team"));
|
2011-03-04 16:08:10 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-19 17:28:47 +00:00
|
|
|
RenderGoals(Width/2-w/2, 150+760+10, w);
|
|
|
|
RenderSpectators(Width/2-w/2, 150+760+10+50+10, 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
|
2011-03-04 16:08:10 +00:00
|
|
|
if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
|
2011-01-17 12:42:40 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2010-08-18 01:57:35 +00:00
|
|
|
}
|