Append rect width

This commit is contained in:
LordSk 2018-11-23 19:03:40 +01:00
parent b285a3d96d
commit c19c60012c
6 changed files with 11 additions and 5 deletions

View file

@ -715,6 +715,7 @@ void CChat::OnRender()
// FIXME: sometimes an empty line will pop here when the cursor reaches the end of line
Line.m_Size[OffsetType].y = Cursor.m_LineCount * Cursor.m_FontSize;
Line.m_Size[OffsetType].x = Cursor.m_LineCount == 1 ? Cursor.m_X - Cursor.m_StartX : LineWidth;
Line.m_Size[OffsetType].x += RenderTools()->GetClientIdRectSize(Cursor.m_FontSize);
}
}

View file

@ -210,7 +210,7 @@ void CHud::RenderScoreHud()
int ID = FlagCarrier[t]%MAX_CLIENTS;
char aName[64];
str_format(aName, sizeof(aName), "%s", g_Config.m_ClShowsocial ? m_pClient->m_aClients[ID].m_aName : "");
float w = TextRender()->TextWidth(0, 8.0f, aName, -1);
float w = TextRender()->TextWidth(0, 8.0f, aName, -1) + RenderTools()->GetClientIdRectSize(8.0f);
CTextCursor Cursor;
float x = min(Whole-w-1.0f, Whole-ScoreWidthMax-ImageSize-2*Split);

View file

@ -59,8 +59,8 @@ void CKillMessages::OnRender()
continue;
float FontSize = 36.0f;
float KillerNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aKillerName, -1);
float VictimNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aVictimName, -1);
float KillerNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aKillerName, -1) + RenderTools()->GetClientIdRectSize(FontSize);
float VictimNameW = TextRender()->TextWidth(0, FontSize, m_aKillmsgs[r].m_aVictimName, -1) + RenderTools()->GetClientIdRectSize(FontSize);
float x = StartX;

View file

@ -33,9 +33,9 @@ void CNamePlates::RenderNameplate(
char aName[64];
str_format(aName, sizeof(aName), "%s", g_Config.m_ClShowsocial ? m_pClient->m_aClients[ClientID].m_aName: "");
float tw = TextRender()->TextWidth(0, FontSize, aName, -1);
CTextCursor Cursor;
float tw = TextRender()->TextWidth(0, FontSize, aName, -1) + RenderTools()->GetClientIdRectSize(FontSize);
TextRender()->SetCursor(&Cursor, Position.x-tw/2.0f, Position.y-FontSize-38.0f, FontSize, TEXTFLAG_RENDER);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.5f*a);

View file

@ -624,3 +624,8 @@ void CRenderTools::DrawClientID(ITextRender* pTextRender, CTextCursor* pCursor,
pCursor->m_X = PrevX + Rect.w + 0.2f * FontSize;
}
float CRenderTools::GetClientIdRectSize(float FontSize)
{
return 1.4f * FontSize + 0.2f * FontSize;
}

View file

@ -92,7 +92,7 @@ public:
void DrawClientID(ITextRender* pTextRender, CTextCursor* pCursor, int ID,
const vec4& BgColor = vec4(1, 1, 1, 0.5f), const vec4& TextColor = vec4(0.1f, 0.1f, 0.1f, 1.0f));
float GetClientIdRectSize(float FontSize);
};
#endif