MCPcopy Create free account
hub / github.com/ddnet/ddnet / AppendTextContainer

Method AppendTextContainer

src/engine/client/text.cpp:1512–2058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1510 }
1511
1512 void AppendTextContainer(STextContainerIndex TextContainerIndex, CTextCursor *pCursor, const char *pText, int Length = -1) override
1513 {
1514 STextContainer &TextContainer = GetTextContainer(TextContainerIndex);
1515 str_append(TextContainer.m_aDebugText, pText);
1516
1517 float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
1518 Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
1519
1520 const vec2 FakeToScreen = vec2(Graphics()->ScreenWidth() / (ScreenX1 - ScreenX0), Graphics()->ScreenHeight() / (ScreenY1 - ScreenY0));
1521 const float CursorX = round_to_int(pCursor->m_X * FakeToScreen.x) / FakeToScreen.x;
1522 const float CursorY = round_to_int(pCursor->m_Y * FakeToScreen.y) / FakeToScreen.y;
1523 const int ActualSize = round_truncate(pCursor->m_FontSize * FakeToScreen.y);
1524 pCursor->m_AlignedFontSize = ActualSize / FakeToScreen.y;
1525 pCursor->m_AlignedLineSpacing = round_truncate(pCursor->m_LineSpacing * FakeToScreen.y) / FakeToScreen.y;
1526
1527 // string length
1528 if(Length < 0)
1529 Length = str_length(pText);
1530 else
1531 Length = minimum(Length, str_length(pText));
1532
1533 const char *pCurrent = pText;
1534 const char *pEnd = pCurrent + Length;
1535 const char *pPrevBatchEnd = nullptr;
1536 const char *pEllipsis = "…";
1537 const SGlyph *pEllipsisGlyph = nullptr;
1538 if(pCursor->m_Flags & TEXTFLAG_ELLIPSIS_AT_END)
1539 {
1540 if(pCursor->m_LineWidth > 0.0f && pCursor->m_LineWidth < TextWidth(pCursor->m_FontSize, pText))
1541 {
1542 pEllipsisGlyph = m_pGlyphMap->GetGlyph(0x2026, ActualSize); // …
1543 if(pEllipsisGlyph == nullptr)
1544 {
1545 // no ellipsis char in font, just stop at end instead
1546 pCursor->m_Flags &= ~TEXTFLAG_ELLIPSIS_AT_END;
1547 pCursor->m_Flags |= TEXTFLAG_STOP_AT_END;
1548 }
1549 }
1550 }
1551
1552 const unsigned RenderFlags = TextContainer.m_RenderFlags;
1553
1554 float DrawX = 0.0f, DrawY = 0.0f;
1555 if((RenderFlags & TEXT_RENDER_FLAG_NO_PIXEL_ALIGNMENT) != 0)
1556 {
1557 DrawX = pCursor->m_X;
1558 DrawY = pCursor->m_Y;
1559 }
1560 else
1561 {
1562 DrawX = CursorX;
1563 DrawY = CursorY;
1564 }
1565
1566 int LineCount = pCursor->m_LineCount;
1567
1568 const bool IsRendered = (pCursor->m_Flags & TEXTFLAG_RENDER) != 0;
1569

Callers 1

RenderDDRaceEffectsMethod · 0.80

Calls 15

GraphicsFunction · 0.85
round_to_intFunction · 0.85
round_truncateFunction · 0.85
str_lengthFunction · 0.85
str_utf8_rewindFunction · 0.85
str_utf8_decodeFunction · 0.85
maximumFunction · 0.85
CQuadItemClass · 0.85
GetScreenMethod · 0.80
ScreenWidthMethod · 0.80
ScreenHeightMethod · 0.80
GetGlyphMethod · 0.80

Tested by

no test coverage detected