mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
removed the usage of std::string in scoreboard
This commit is contained in:
parent
0288655395
commit
dc8ec160e5
|
@ -1,7 +1,5 @@
|
|||
/* (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. */
|
||||
#include <base/tl/string.h>
|
||||
|
||||
#include <engine/demo.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/textrender.h>
|
||||
|
@ -15,6 +13,7 @@
|
|||
#include <game/localization.h>
|
||||
#include "scoreboard.h"
|
||||
|
||||
static const char GAMETYPES_RACE[] = "race";
|
||||
|
||||
CScoreboard::CScoreboard()
|
||||
{
|
||||
|
@ -25,6 +24,7 @@ void CScoreboard::ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData,
|
|||
{
|
||||
CScoreboard *pSelf = (CScoreboard *)pUserData;
|
||||
pSelf->Client()->GetServerInfo(&pSelf->m_pServerInfo);
|
||||
pSelf->m_GametypeRace = str_find_nocase(pSelf->m_pServerInfo.m_aGameType, GAMETYPES_RACE);
|
||||
pSelf->m_Active = pResult->GetInteger(0) != 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ void CScoreboard::RenderSpectators(float x, float y, float w)
|
|||
{
|
||||
if(Count)
|
||||
str_append(aBuffer, ", ", sizeof(aBuffer));
|
||||
if(m_GameType.find("Race") != std::string::npos)
|
||||
if(m_GametypeRace)
|
||||
if (g_Config.m_ClShowIds)
|
||||
{
|
||||
char aId[4];
|
||||
|
@ -151,7 +151,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
float tw = TextRender()->TextWidth(0, 48, pTitle, -1);
|
||||
TextRender()->Text(0, x+10, y, 48, pTitle, -1);
|
||||
|
||||
if(m_GameType.find("Race") == std::string::npos)
|
||||
if(!m_GametypeRace)
|
||||
if(m_pClient->m_Snap.m_pGameobj)
|
||||
{
|
||||
char aBuf[128];
|
||||
|
@ -165,7 +165,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
|
||||
// render headlines
|
||||
TextRender()->Text(0, x+10, y, 24.0f, Localize("Score"), -1);
|
||||
if(m_GameType.find("Race") != std::string::npos)
|
||||
if(m_GametypeRace)
|
||||
{
|
||||
TextRender()->Text(0, x+125+Offset, y, 24.0f, Localize("Name"), -1);
|
||||
TextRender()->Text(0, x+w-75, y, 24.0f, Localize("Ping"), -1);
|
||||
|
@ -212,7 +212,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
|
||||
float FontSizeResize = FontSize;
|
||||
float Width;
|
||||
if(m_GameType.find("Race") != std::string::npos)
|
||||
if(m_GametypeRace)
|
||||
{
|
||||
const float ScoreWidth = 150.0f;
|
||||
const float PingWidth = 60.0f;
|
||||
|
@ -284,7 +284,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
|
||||
float size = 64.0f;
|
||||
IGraphics::CQuadItem QuadItem;
|
||||
if(m_GameType.find("Race") != std::string::npos)
|
||||
if(m_GametypeRace)
|
||||
QuadItem = IGraphics::CQuadItem(x+55+DataOffset, y-15, size/2, size);
|
||||
else
|
||||
QuadItem = IGraphics::CQuadItem(x+55, y-15, size/2, size);
|
||||
|
@ -295,7 +295,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientId].m_RenderInfo;
|
||||
TeeInfo.m_Size *= TeeSizeMod;
|
||||
|
||||
if(m_GameType.find("Race") != std::string::npos)
|
||||
if(m_GametypeRace)
|
||||
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));
|
||||
|
@ -332,7 +332,7 @@ void CScoreboard::OnRender()
|
|||
{
|
||||
if(!Active())
|
||||
return;
|
||||
m_GameType = std::string(m_pServerInfo.m_aGameType);
|
||||
|
||||
// if the score board is active, then we should clear the motd message aswell
|
||||
if(m_pClient->m_pMotd->IsActive())
|
||||
m_pClient->m_pMotd->Clear();
|
||||
|
@ -344,7 +344,7 @@ void CScoreboard::OnRender()
|
|||
Graphics()->MapScreen(0, 0, Width, Height);
|
||||
|
||||
float w;
|
||||
if(m_GameType.find("Race") != std::string::npos)
|
||||
if(m_GametypeRace)
|
||||
w = 750.0f;
|
||||
else
|
||||
w = 650.0f;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#define GAME_CLIENT_COMPONENTS_SCOREBOARD_H
|
||||
#include <game/client/component.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
#include <string>
|
||||
|
||||
class CScoreboard : public CComponent
|
||||
{
|
||||
|
@ -17,7 +16,7 @@ class CScoreboard : public CComponent
|
|||
|
||||
bool m_Active;
|
||||
CServerInfo m_pServerInfo;
|
||||
std::string m_GameType;
|
||||
bool m_GametypeRace;
|
||||
|
||||
public:
|
||||
CScoreboard();
|
||||
|
|
Loading…
Reference in a new issue