about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/game/client/components/chat.cpp6
-rw-r--r--src/game/client/components/scoreboard.cpp219
2 files changed, 127 insertions, 98 deletions
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp
index e90e8579..308493bb 100644
--- a/src/game/client/components/chat.cpp
+++ b/src/game/client/components/chat.cpp
@@ -262,7 +262,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
 void CChat::OnRender()
 {
 	Graphics()->MapScreen(0,0,300*Graphics()->ScreenAspect(),300);
-	float x = 10.0f;
+	float x = 5.0f;
 	float y = 300.0f-20.0f;
 	if(m_Mode != MODE_NONE)
 	{
@@ -316,8 +316,8 @@ void CChat::OnRender()
 	y -= 8.0f;
 
 	int64 Now = time_get();
-	float LineWidth = m_pClient->m_pScoreboard->Active() ? 95.0f : 200.0f;
-	float HeightLimit = m_pClient->m_pScoreboard->Active() ? 220.0f : m_Show ? 50.0f : 200.0f;
+	float LineWidth = m_pClient->m_pScoreboard->Active() ? 90.0f : 200.0f;
+	float HeightLimit = m_pClient->m_pScoreboard->Active() ? 230.0f : m_Show ? 50.0f : 200.0f;
 	float Begin = x;
 	float FontSize = 6.0f;
 	CTextCursor Cursor;
diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp
index c208cddc..a5e21c94 100644
--- a/src/game/client/components/scoreboard.cpp
+++ b/src/game/client/components/scoreboard.cpp
@@ -4,13 +4,17 @@
 #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/generated/protocol.h>
+
+#include <game/localization.h>
 #include <game/client/animstate.h>
+#include <game/client/gameclient.h>
 #include <game/client/render.h>
+#include <game/client/components/countryflags.h>
 #include <game/client/components/motd.h>
-#include <game/localization.h>
+
 #include "scoreboard.h"
 
 
@@ -47,10 +51,11 @@ void CScoreboard::RenderGoals(float x, float y, float w)
 	Graphics()->TextureSet(-1);
 	Graphics()->QuadsBegin();
 	Graphics()->SetColor(0,0,0,0.5f);
-	RenderTools()->DrawRoundRect(x-10.f, y-10.f, w, h, 10.0f);
+	RenderTools()->DrawRoundRect(x-10.f, y, w, h, 10.0f);
 	Graphics()->QuadsEnd();
 
 	// render goals
+	y += 10.0f;
 	if(m_pClient->m_Snap.m_pGameInfoObj)
 	{
 		if(m_pClient->m_Snap.m_pGameInfoObj->m_ScoreLimit)
@@ -77,38 +82,41 @@ void CScoreboard::RenderGoals(float x, float y, float w)
 
 void CScoreboard::RenderSpectators(float x, float y, float w)
 {
-	char aBuffer[1024*4];
-	int Count = 0;
-	float h = 120.0f;
-	
-	str_format(aBuffer, sizeof(aBuffer), "%s: ", Localize("Spectators"));
+	float h = 140.0f;	
 
+	// background
 	Graphics()->BlendNormal();
 	Graphics()->TextureSet(-1);
 	Graphics()->QuadsBegin();
 	Graphics()->SetColor(0,0,0,0.5f);
-	RenderTools()->DrawRoundRect(x-10.f, y-10.f, w, h, 10.0f);
+	RenderTools()->DrawRoundRect(x-10.f, y, w, h, 10.0f);
 	Graphics()->QuadsEnd();
-	
-	for(int i = 0; i < Client()->SnapNumItems(IClient::SNAP_CURRENT); i++)
+
+	// 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)
 	{
-		IClient::CSnapItem Item;
-		const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item);
+		const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paPlayerInfos[i];
+		if(!pInfo || pInfo->m_Team != TEAM_SPECTATORS)
+			continue;
 
-		if(Item.m_Type == NETOBJTYPE_PLAYERINFO)
-		{
-			const CNetObj_PlayerInfo *pInfo = (const CNetObj_PlayerInfo *)pData;
-			if(pInfo->m_Team == TEAM_SPECTATORS)
-			{
-				if(Count)
-					str_append(aBuffer, ", ", sizeof(aBuffer));
-				str_append(aBuffer, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, sizeof(aBuffer));
-				Count++;
-			}
-		}
+		if(Multiple)
+			str_append(aBuffer, ", ", sizeof(aBuffer));
+		str_append(aBuffer, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, sizeof(aBuffer));
+		Multiple = true;
 	}
-	
-	TextRender()->Text(0, x+10, y, 32, aBuffer, (int)w-20);
+	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);
 }
 
 void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const char *pTitle)
@@ -116,17 +124,18 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
 	if(Team == TEAM_SPECTATORS)
 		return;
 
-	//float ystart = y;
-	float h = 740.0f;
+	float h = 760.0f;
 
+	// background
 	Graphics()->BlendNormal();
 	Graphics()->TextureSet(-1);
 	Graphics()->QuadsBegin();
-	Graphics()->SetColor(0,0,0,0.5f);
-	RenderTools()->DrawRoundRect(x-10.f, y, w, h, 17.0f);
+	Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.5f);
+	RenderTools()->DrawRoundRect(x, y, w, h, 17.0f);
 	Graphics()->QuadsEnd();
 
 	// render title
+	float TitleFontsize = 40.0f;
 	if(!pTitle)
 	{
 		if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
@@ -134,96 +143,92 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
 		else
 			pTitle = Localize("Score board");
 	}
+	TextRender()->Text(0, x+30, y, TitleFontsize, pTitle, -1);
 
-	float tw = TextRender()->TextWidth(0, 48, pTitle, -1);
-	TextRender()->Text(0, x+10, y, 48, pTitle, -1);
-
+	char aBuf[128] = {0};
 	if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS)
 	{
 		if(m_pClient->m_Snap.m_pGameDataObj)
 		{
-			char aBuf[128];
 			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);
-			tw = TextRender()->TextWidth(0, 48, aBuf, -1);
-			TextRender()->Text(0, x+w-tw-30, y, 48, aBuf, -1);
 		}
 	}
 	else
 	{
 		if(m_pClient->m_Snap.m_pLocalInfo)
 		{
-			char aBuf[128];
 			int Score = m_pClient->m_Snap.m_pLocalInfo->m_Score;
 			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);
 		}
 	}
+	float tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1);
+	TextRender()->Text(0, x+w-tw-30, y, TitleFontsize, aBuf, -1);
 
-	y += 54.0f;
-
-	// 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);
-	y += 29.0f;
-
-	float FontSize = 35.0f;
-	float LineHeight = 50.0f;
+	// calculate measurements
+	x += 10.0f;
+	float LineHeight = 60.0f;
 	float TeeSizeMod = 1.0f;
-	float TeeOffset = 0.0f;
-	
-	if(m_pClient->m_Snap.m_aTeamSize[Team] > 13)
+	float Spacing = 10.0f;
+	if(m_pClient->m_Snap.m_aTeamSize[Team] > 12)
 	{
-		FontSize = 30.0f;
 		LineHeight = 40.0f;
 		TeeSizeMod = 0.8f;
-		TeeOffset = -5.0f;
+		Spacing = 0.0f;
+	}
+	else if(m_pClient->m_Snap.m_aTeamSize[Team] > 8)
+	{
+		LineHeight = 50.0f;
+		TeeSizeMod = 0.9f;
+		Spacing = 5.0f;
 	}
+
+	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;
 	
-	// render player scores
 	for(int i = 0; i < MAX_CLIENTS; i++)
 	{
+		// make sure that we render the correct team
 		const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paInfoByScore[i];
 		if(!pInfo || pInfo->m_Team != Team)
 			continue;
 
-		// make sure that we render the correct team
-
-		char aBuf[128];
+		// background so it's easy to find the local player
 		if(pInfo->m_Local)
 		{
-			// background so it's easy to find the local player
 			Graphics()->TextureSet(-1);
 			Graphics()->QuadsBegin();
-			Graphics()->SetColor(1,1,1,0.25f);
-			RenderTools()->DrawRoundRect(x, y, w-20, LineHeight*0.95f, 17.0f);
+			Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
+			RenderTools()->DrawRoundRect(x, y, w-20.0f, LineHeight, 15.0f);
 			Graphics()->QuadsEnd();
 		}
 
-		float FontSizeResize = FontSize;
-		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);
-		
-		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;
-		TextRender()->Text(0, x+w-35.0f-Width, y+(FontSize-FontSizeResize)/2, FontSizeResize, aBuf, -1);
-
-		// render flag
-		if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS &&
+		// 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 &&
 			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))
 		{
@@ -233,19 +238,43 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
 
 			RenderTools()->SelectSprite(pInfo->m_Team==TEAM_RED ? SPRITE_FLAG_BLUE : SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X);
 			
-			float size = 64.0f;
-			IGraphics::CQuadItem QuadItem(x+55, y-15, size/2, size);
+			float Size = LineHeight;
+			IGraphics::CQuadItem QuadItem(TeeOffset+0.0f, y-5.0f-Spacing/2.0f, Size/2.0f, Size);
 			Graphics()->QuadsDrawTL(&QuadItem, 1);
 			Graphics()->QuadsEnd();
 		}
 		
-		// render avatar
+		// avatar
 		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.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();
 		
-		y += LineHeight;
+		// 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;
 	}
 }
 
@@ -290,7 +319,7 @@ void CScoreboard::OnRender()
 	
 	Graphics()->MapScreen(0, 0, Width, Height);
 
-	float w = 650.0f;
+	float w = 700.0f;
 
 	if(m_pClient->m_Snap.m_pGameInfoObj)
 	{
@@ -311,13 +340,13 @@ void CScoreboard::OnRender()
 				TextRender()->Text(0, Width/2-w/2, 39, 86.0f, pText, -1);
 			}
 		
-			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"));
+			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"));
 		}
 	}
 
-	RenderGoals(Width/2-w/2, 150+750+25, w);
-	RenderSpectators(Width/2-w/2, 150+750+25+50+25, w);
+	RenderGoals(Width/2-w/2, 150+760+10, w);
+	RenderSpectators(Width/2-w/2, 150+760+10+50+10, w);
 	RenderRecordingNotification((Width/7)*4);
 }