diff --git a/src/Layers/xrRender/dxFontRender.cpp b/src/Layers/xrRender/dxFontRender.cpp index cfe0f0ad1d..3fd2cc3e2c 100644 --- a/src/Layers/xrRender/dxFontRender.cpp +++ b/src/Layers/xrRender/dxFontRender.cpp @@ -61,12 +61,8 @@ void dxFontRender::OnRender(CGameFont& owner) { u32 clr, clr2; clr2 = clr = str.c; - if(str.gradient) { - u32 _R = color_get_R(clr) / 2; - u32 _G = color_get_G(clr) / 2; - u32 _B = color_get_B(clr) / 2; - u32 _A = color_get_A(clr); - clr2 = color_rgba(_R, _G, _B, _A); + if(str.gradient) {; + clr2 = str.gradientColor; } X -= 0.5f; diff --git a/src/xrEngine/GameFont.cpp b/src/xrEngine/GameFont.cpp index 51a10a9b30..bd013027a9 100644 --- a/src/xrEngine/GameFont.cpp +++ b/src/xrEngine/GameFont.cpp @@ -392,6 +392,7 @@ void CGameFont::MasterOut( rs.x = (bUseCoords ? (bScaleCoords ? (DI2PX(_x)) : _x) : fCurrentX); rs.y = (bUseCoords ? (bScaleCoords ? (DI2PY(_y)) : _y) : fCurrentY); rs.c = dwCurrentColor; + rs.gradientColor = dwGradientColor; rs.height = fCurrentHeight; rs.align = eCurrentAlignment; rs.gradient = fGradientEnabled; diff --git a/src/xrEngine/GameFont.h b/src/xrEngine/GameFont.h index 07fe83a432..b3f4d03477 100644 --- a/src/xrEngine/GameFont.h +++ b/src/xrEngine/GameFont.h @@ -42,6 +42,7 @@ class ENGINE_API CGameFont EAligment align; bool gradient; EGradientMode gradientMode; + u32 gradientColor; }; struct BaseData @@ -63,6 +64,7 @@ class ENGINE_API CGameFont u32 uFlags; u32 dwCurrentColor; + u32 dwGradientColor; EAligment eCurrentAlignment; xr_vector strings; @@ -87,6 +89,7 @@ class ENGINE_API CGameFont void ReInit(); inline void SetColor(u32 C) { dwCurrentColor = C; }; + inline void SetGradientColor(u32 C) { dwGradientColor = C; }; //inline void SetHeightI(float S); inline void SetHeight(float S); diff --git a/src/xrUI/UIXmlInit.cpp b/src/xrUI/UIXmlInit.cpp index 92836a8302..07c8ddf5ae 100644 --- a/src/xrUI/UIXmlInit.cpp +++ b/src/xrUI/UIXmlInit.cpp @@ -384,6 +384,14 @@ bool CUIXmlInit::InitText(CUIXml& xml_doc, LPCSTR path, int index, CUILines* pLi else if (_stricmp(mode_str, "down") == 0) { mode = CGameFont::gm_down; } pLines->SetTextGradientMode(mode); + u32 color2; + u32 _R = color_get_R(color) / 2; + u32 _G = color_get_G(color) / 2; + u32 _B = color_get_B(color) / 2; + u32 _A = color_get_A(color); + color2 = GetGradientColor(xml_doc, path, index, color_rgba(_R, _G, _B, _A)); + pLines->SetTextGradientColor(color2); + shared_str text = xml_doc.Read(path, index, nullptr); if (text.size()) pLines->SetText(g_pStringTable->translate(text).c_str()); @@ -1320,6 +1328,18 @@ u32 CUIXmlInit::GetColor(CUIXml& xml_doc, LPCSTR path, int index, u32 def_clr) } +u32 CUIXmlInit::GetGradientColor(CUIXml& xml_doc, LPCSTR path, int index, u32 def_clr) +{ + LPCSTR clr_def = xml_doc.ReadAttrib(path, index, "gradient_color", nullptr); + if (clr_def) { + VERIFY(GetColorDefs()->find(clr_def) != GetColorDefs()->end()); + return (*m_pColorDefs)[clr_def]; + } + else { + return def_clr; + } +} + bool CUIXmlInit::InitHintWindow(CUIXml& xml_doc, LPCSTR path, int index, UIHintWindow* pWnd) { VERIFY( pWnd ); diff --git a/src/xrUI/UIXmlInit.h b/src/xrUI/UIXmlInit.h index 98534e2ac4..4c0e143546 100644 --- a/src/xrUI/UIXmlInit.h +++ b/src/xrUI/UIXmlInit.h @@ -70,6 +70,7 @@ class UI_API CUIXmlInit static bool InitHintWindow (CUIXml& xml_doc, LPCSTR path, int index, UIHintWindow* pWnd); static Frect GetFRect (CUIXml& xml_doc, LPCSTR path, int index); static u32 GetColor (CUIXml& xml_doc, LPCSTR path, int index, u32 def_clr); + static u32 GetGradientColor (CUIXml& xml_doc, LPCSTR path, int index, u32 def_clr); public: static bool InitAlignment(CUIXml &xml_doc, const char *path, diff --git a/src/xrUI/Widgets/UILines.cpp b/src/xrUI/Widgets/UILines.cpp index 82d6943356..d2d8bc592b 100644 --- a/src/xrUI/Widgets/UILines.cpp +++ b/src/xrUI/Widgets/UILines.cpp @@ -21,6 +21,7 @@ CUILines::CUILines() m_eTextAlign = CGameFont::alLeft; m_eVTextAlign = valTop; m_dwTextColor = 0xffffffff; + m_dwTextGradientColor = 0xff888888; m_TextOffset.set (0.0f,0.0f); m_text =""; uFlags.zero(); @@ -321,6 +322,14 @@ void CUILines::SetTextColor(u32 color) m_dwTextColor = color; } +void CUILines::SetTextGradientColor(u32 color) +{ + if (color == m_dwTextGradientColor) + return; + uFlags.set(flNeedReparse, true); + m_dwTextGradientColor = color; +} + void CUILines::SetFont(CGameFont* pFont) { if (pFont == m_pFont) @@ -384,6 +393,7 @@ void CUILines::Draw(float x, float y) R_ASSERT(m_pFont); m_pFont->SetColor(m_dwTextColor); + m_pFont->SetGradientColor(m_dwTextGradientColor); if (!uFlags.is(flComplexMode)) { diff --git a/src/xrUI/Widgets/UILines.h b/src/xrUI/Widgets/UILines.h index 86cf21ada8..9ff06ba0bd 100644 --- a/src/xrUI/Widgets/UILines.h +++ b/src/xrUI/Widgets/UILines.h @@ -18,6 +18,8 @@ class UI_API CUILines : //-- void SetTextColor(u32 color); u32 GetTextColor() {return m_dwTextColor;} + void SetTextGradientColor(u32 color); + u32 GetTextGradientColor() {return m_dwTextGradientColor;} void SetFont(CGameFont* pFont); void SetTextGradient(bool val); CGameFont* GetFont() {return m_pFont;} @@ -70,6 +72,7 @@ CGameFont::EGradientMode GetTextGradientMode() {return m_eTextGradientMode; ETextAlignment m_eTextAlign; EVTextAlignment m_eVTextAlign; u32 m_dwTextColor; + u32 m_dwTextGradientColor; CGameFont* m_pFont;