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

Method DoLabelStreamed

src/game/client/ui.cpp:840–894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838}
839
840void CUi::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps, int StrLen, const CTextCursor *pReadCursor) const
841{
842 const int ReadCursorGlyphCount = pReadCursor == nullptr ? -1 : pReadCursor->m_GlyphCount;
843 bool NeedsRecreate = false;
844 bool ColorChanged = RectEl.m_TextColor != TextRender()->GetTextColor() || RectEl.m_TextOutlineColor != TextRender()->GetTextOutlineColor();
845 if((!RectEl.m_UITextContainer.Valid() && pText[0] != '\0' && StrLen != 0) || RectEl.m_Width != pRect->w || RectEl.m_Height != pRect->h || ColorChanged || RectEl.m_ReadCursorGlyphCount != ReadCursorGlyphCount)
846 {
847 NeedsRecreate = true;
848 }
849 else
850 {
851 if(StrLen <= -1)
852 {
853 if(str_comp(RectEl.m_Text.c_str(), pText) != 0)
854 NeedsRecreate = true;
855 }
856 else
857 {
858 if(StrLen != (int)RectEl.m_Text.size() || str_comp_num(RectEl.m_Text.c_str(), pText, StrLen) != 0)
859 NeedsRecreate = true;
860 }
861 }
862 RectEl.m_X = pRect->x;
863 RectEl.m_Y = pRect->y;
864 if(NeedsRecreate)
865 {
866 TextRender()->DeleteTextContainer(RectEl.m_UITextContainer);
867
868 RectEl.m_Width = pRect->w;
869 RectEl.m_Height = pRect->h;
870
871 if(StrLen > 0)
872 RectEl.m_Text = std::string(pText, StrLen);
873 else if(StrLen < 0)
874 RectEl.m_Text = pText;
875 else
876 RectEl.m_Text.clear();
877
878 RectEl.m_ReadCursorGlyphCount = ReadCursorGlyphCount;
879
880 CUIRect TmpRect;
881 TmpRect.x = 0;
882 TmpRect.y = 0;
883 TmpRect.w = pRect->w;
884 TmpRect.h = pRect->h;
885
886 DoLabel(RectEl, &TmpRect, pText, Size, TEXTALIGN_TL, LabelProps, StrLen, pReadCursor);
887 }
888
889 if(RectEl.m_UITextContainer.Valid())
890 {
891 const vec2 CursorPos = CalcAlignedCursorPos(pRect, vec2(RectEl.m_Cursor.m_LongestLineWidth, RectEl.m_Cursor.Height()), Align);
892 TextRender()->RenderTextContainer(RectEl.m_UITextContainer, RectEl.m_TextColor, RectEl.m_TextOutlineColor, CursorPos.x, CursorPos.y);
893 }
894}
895
896CLabelResult CUi::DoLabel_AutoLineSize(const char *pText, float FontSize, int Align, CUIRect *pRect, float LineSize, const SLabelProperties &LabelProps) const
897{

Callers 1

Calls 9

TextRenderFunction · 0.85
str_compFunction · 0.85
str_comp_numFunction · 0.85
GetTextColorMethod · 0.80
GetTextOutlineColorMethod · 0.80
DeleteTextContainerMethod · 0.80
HeightMethod · 0.80
RenderTextContainerMethod · 0.80
ValidMethod · 0.45

Tested by

no test coverage detected