Revert "Ellipsis at end in scoreboard and hud"

This reverts commit f278399bd1.
This commit is contained in:
def 2022-05-22 23:04:32 +02:00
parent 590eb2c5d1
commit 0c8bf5c3aa
4 changed files with 11 additions and 39 deletions

View file

@ -1058,10 +1058,6 @@ public:
const char *pCurrent = (char *)pText;
const char *pEnd = pCurrent + Length;
const char *pEllipsis = "";
SFontSizeChar *pEllipsisChr = nullptr;
if(pCursor->m_Flags & TEXTFLAG_ELLIPSIS_AT_END)
pEllipsisChr = GetChar(TextContainer.m_pFont, pSizeData, 0x2026); // …
int RenderFlags = TextContainer.m_RenderFlags;
@ -1168,7 +1164,7 @@ public:
pCursor->m_CursorCharacter = -1;
}
while(pCurrent != pEllipsis && pCurrent < pEnd && (pCursor->m_MaxLines < 1 || LineCount <= pCursor->m_MaxLines))
while(pCurrent < pEnd && (pCursor->m_MaxLines < 1 || LineCount <= pCursor->m_MaxLines))
{
int NewLine = 0;
const char *pBatchEnd = pEnd;
@ -1217,11 +1213,11 @@ public:
const char *pTmp = pCurrent;
int NextCharacter = str_utf8_decode(&pTmp);
while(pCurrent < pBatchEnd && pCurrent != pEllipsis)
while(pCurrent < pBatchEnd)
{
pCursor->m_CharCount += pTmp - pCurrent;
pCurrent = pTmp;
int Character = NextCharacter;
pCurrent = pTmp;
NextCharacter = str_utf8_decode(&pTmp);
if(Character == '\n')
@ -1247,32 +1243,7 @@ public:
CharKerning = Kerning(TextContainer.m_pFont, LastCharGlyphIndex, pChr->m_GlyphIndex) * Scale * Size;
LastCharGlyphIndex = pChr->m_GlyphIndex;
if(pCursor->m_Flags & TEXTFLAG_ELLIPSIS_AT_END && pCurrent < pBatchEnd && pCurrent != pEllipsis)
{
if(pEllipsisChr)
{
float AdvanceEllipsis = ((((RenderFlags & TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH) != 0) ? (pEllipsisChr->m_Width) : (pEllipsisChr->m_AdvanceX + ((!ApplyBearingX) ? (-pEllipsisChr->m_OffsetX) : 0.f)))) * Scale * Size;
float CharKerningEllipsis = 0.f;
if((RenderFlags & TEXT_RENDER_FLAG_KERNING) != 0)
CharKerningEllipsis = Kerning(TextContainer.m_pFont, pChr->m_GlyphIndex, pEllipsisChr->m_GlyphIndex) * Scale * Size;
if(DrawX + CharKerning + Advance + CharKerningEllipsis + AdvanceEllipsis - pCursor->m_StartX > pCursor->m_LineWidth)
{
// we hit the end, only render ellipsis and finish
pTmp = pEllipsis;
NextCharacter = 0x2026;
continue;
}
}
else
{
// no ellipsis char in font, just stop
pCurrent = pEnd;
break;
}
}
if(pCursor->m_Flags & TEXTFLAG_STOP_AT_END && DrawX + CharKerning + Advance - pCursor->m_StartX > pCursor->m_LineWidth)
if(pCursor->m_Flags & TEXTFLAG_STOP_AT_END && (DrawX + CharKerning) + Advance - pCursor->m_StartX > pCursor->m_LineWidth)
{
// we hit the end of the line, no more to render or count
pCurrent = pEnd;

View file

@ -12,8 +12,7 @@ enum
{
TEXTFLAG_RENDER = 1,
TEXTFLAG_ALLOW_NEWLINE = 2,
TEXTFLAG_STOP_AT_END = 4,
TEXTFLAG_ELLIPSIS_AT_END = 8,
TEXTFLAG_STOP_AT_END = 4
};
enum ETextAlignment

View file

@ -441,9 +441,11 @@ void CHud::RenderScoreHud()
if(m_aScoreInfo[t].m_OptionalNameTextContainerIndex != -1)
TextRender()->DeleteTextContainer(m_aScoreInfo[t].m_OptionalNameTextContainerIndex);
float w = TextRender()->TextWidth(0, 8.0f, pName, -1, -1.0f);
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, m_Width - ScoreWidthMax - ImageSize - 2 * Split - PosSize, StartY + (t + 1) * 20.0f - 2.0f, 8.0f, TEXTFLAG_RENDER | TEXTFLAG_ELLIPSIS_AT_END);
Cursor.m_LineWidth = m_Width - Cursor.m_X - Split;
TextRender()->SetCursor(&Cursor, minimum(m_Width - w - 1.0f, m_Width - ScoreWidthMax - ImageSize - 2 * Split - PosSize), StartY + (t + 1) * 20.0f - 2.0f, 8.0f, TEXTFLAG_RENDER);
Cursor.m_LineWidth = -1;
m_aScoreInfo[t].m_OptionalNameTextContainerIndex = TextRender()->CreateTextContainer(&Cursor, pName);
}

View file

@ -470,7 +470,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos);
// name
TextRender()->SetCursor(&Cursor, NameOffset, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_ELLIPSIS_AT_END);
TextRender()->SetCursor(&Cursor, NameOffset, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
if(m_pClient->m_aClients[pInfo->m_ClientID].m_AuthLevel)
{
ColorRGBA Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClAuthedPlayerColor));
@ -508,7 +508,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
tw = minimum(TextRender()->TextWidth(nullptr, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1, -1.0f), ClanLength);
TextRender()->SetCursor(&Cursor, ClanOffset + (ClanLength - tw) / 2, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_ELLIPSIS_AT_END);
TextRender()->SetCursor(&Cursor, ClanOffset + (ClanLength - tw) / 2, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
Cursor.m_LineWidth = ClanLength;
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);