Fix text color change

This commit is contained in:
Jupeyy 2020-11-08 19:41:16 +01:00
parent 8a818439b0
commit a9631bf9cd
4 changed files with 18 additions and 1 deletions

View file

@ -840,6 +840,9 @@ public:
}
virtual void TextOutlineColor(ColorRGBA rgb) { m_OutlineColor = rgb; };
virtual ColorRGBA GetTextColor() { return m_Color; }
virtual ColorRGBA GetTextOutlineColor() { return m_OutlineColor; }
virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length)
{
dbg_assert(pText != NULL, "null text pointer");

View file

@ -77,6 +77,11 @@ struct STextRenderColor
m_A = a;
}
bool operator!=(const STextRenderColor &Other)
{
return m_R != Other.m_R || m_G != Other.m_G || m_B != Other.m_B || m_A != Other.m_A;
}
float m_R, m_G, m_B, m_A;
};
@ -129,6 +134,9 @@ public:
virtual float TextWidth(void *pFontSetV, float Size, const char *pText, int StrLength, float LineWidth, float *pAlignedHeight = NULL, float *pMaxCharacterHeightInLine = NULL) = 0;
virtual int TextLineCount(void *pFontSetV, float Size, const char *pText, float LineWidth) = 0;
virtual ColorRGBA GetTextColor() = 0;
virtual ColorRGBA GetTextOutlineColor() = 0;
virtual void OnWindowResize() = 0;
virtual float GetGlyphOffsetX(int FontSize, char TextCharacter) = 0;

View file

@ -511,12 +511,15 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
RectEl.m_UITextContainer = TextRender()->CreateTextContainer(&Cursor, pText, StrLen);
RectEl.m_Cursor = Cursor;
RectEl.m_TextColor = TextRender()->GetTextColor();
RectEl.m_TextOutlineColor = TextRender()->GetTextOutlineColor();
}
void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth, int AlignVertically, bool StopAtEnd, int StrLen, CTextCursor *pReadCursor)
{
bool NeedsRecreate = false;
if(RectEl.m_UITextContainer == -1 || RectEl.m_X != pRect->x || RectEl.m_Y != pRect->y || RectEl.m_Width != pRect->w || RectEl.m_Height != pRect->h)
bool ColorChanged = RectEl.m_TextColor != TextRender()->GetTextColor() || RectEl.m_TextOutlineColor != TextRender()->GetTextOutlineColor();
if(RectEl.m_UITextContainer == -1 || RectEl.m_X != pRect->x || RectEl.m_Y != pRect->y || RectEl.m_Width != pRect->w || RectEl.m_Height != pRect->h || ColorChanged)
{
NeedsRecreate = true;
}

View file

@ -126,6 +126,9 @@ public:
CTextCursor m_Cursor;
STextRenderColor m_TextColor;
STextRenderColor m_TextOutlineColor;
SUIElementRect() :
m_UIRectQuadContainer(-1), m_UITextContainer(-1), m_X(-1), m_Y(-1), m_Width(-1), m_Height(-1)
{