| 1458 | } |
| 1459 | |
| 1460 | bool CreateTextContainer(STextContainerIndex &TextContainerIndex, CTextCursor *pCursor, const char *pText, int Length = -1) override |
| 1461 | { |
| 1462 | dbg_assert(!TextContainerIndex.Valid(), "Text container index was not cleared."); |
| 1463 | |
| 1464 | TextContainerIndex.Reset(); |
| 1465 | TextContainerIndex.m_Index = GetFreeTextContainerIndex(); |
| 1466 | |
| 1467 | float ScreenX0, ScreenY0, ScreenX1, ScreenY1; |
| 1468 | Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); |
| 1469 | |
| 1470 | STextContainer &TextContainer = GetTextContainer(TextContainerIndex); |
| 1471 | TextContainer.m_SingleTimeUse = (m_RenderFlags & TEXT_RENDER_FLAG_ONE_TIME_USE) != 0; |
| 1472 | const vec2 FakeToScreen = vec2(Graphics()->ScreenWidth() / (ScreenX1 - ScreenX0), Graphics()->ScreenHeight() / (ScreenY1 - ScreenY0)); |
| 1473 | TextContainer.m_AlignedStartX = round_to_int(pCursor->m_X * FakeToScreen.x) / FakeToScreen.x; |
| 1474 | TextContainer.m_AlignedStartY = round_to_int(pCursor->m_Y * FakeToScreen.y) / FakeToScreen.y; |
| 1475 | TextContainer.m_X = pCursor->m_X; |
| 1476 | TextContainer.m_Y = pCursor->m_Y; |
| 1477 | TextContainer.m_Flags = pCursor->m_Flags; |
| 1478 | |
| 1479 | if(pCursor->m_LineWidth <= 0.0f) |
| 1480 | TextContainer.m_RenderFlags = m_RenderFlags | ETextRenderFlags::TEXT_RENDER_FLAG_NO_FIRST_CHARACTER_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_LAST_CHARACTER_ADVANCE; |
| 1481 | else |
| 1482 | TextContainer.m_RenderFlags = m_RenderFlags; |
| 1483 | |
| 1484 | AppendTextContainer(TextContainerIndex, pCursor, pText, Length); |
| 1485 | |
| 1486 | const bool IsRendered = (pCursor->m_Flags & TEXTFLAG_RENDER) != 0; |
| 1487 | |
| 1488 | if(TextContainer.m_StringInfo.m_vCharacterQuads.empty() && TextContainer.m_StringInfo.m_SelectionQuadContainerIndex == -1 && IsRendered) |
| 1489 | { |
| 1490 | FreeTextContainer(TextContainerIndex); |
| 1491 | return false; |
| 1492 | } |
| 1493 | else |
| 1494 | { |
| 1495 | if(Graphics()->IsTextBufferingEnabled() && IsRendered && !TextContainer.m_StringInfo.m_vCharacterQuads.empty()) |
| 1496 | { |
| 1497 | if((TextContainer.m_RenderFlags & TEXT_RENDER_FLAG_NO_AUTOMATIC_QUAD_UPLOAD) == 0) |
| 1498 | { |
| 1499 | UploadTextContainer(TextContainerIndex); |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | TextContainer.m_LineCount = pCursor->m_LineCount; |
| 1504 | TextContainer.m_GlyphCount = pCursor->m_GlyphCount; |
| 1505 | TextContainer.m_CharCount = pCursor->m_CharCount; |
| 1506 | TextContainer.m_MaxLines = pCursor->m_MaxLines; |
| 1507 | TextContainer.m_LineWidth = pCursor->m_LineWidth; |
| 1508 | return true; |
| 1509 | } |
| 1510 | } |
| 1511 | |
| 1512 | void AppendTextContainer(STextContainerIndex TextContainerIndex, CTextCursor *pCursor, const char *pText, int Length = -1) override |
| 1513 | { |
no test coverage detected