mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix text color change
This commit is contained in:
parent
8a818439b0
commit
a9631bf9cd
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue