diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 02bc58ed5f..14aeec400c 100755 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -864,7 +864,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string, } void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor, - const CPos &pos, const float &z) + const CPos &pos, const float &z, const CRect &clipping) { // TODO Gee: All these really necessary? Some // are defaults and if you changed them @@ -879,6 +879,23 @@ void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor, glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + if (clipping != CRect()) + { + double eq[4][4] = + { + { 0.0, 1.0, 0.0, -clipping.top }, + { 1.0, 0.0, 0.0, -clipping.left }, + { 0.0, -1.0, 0.0, clipping.bottom }, + { -1.0, 0.0, 0.0, clipping.right } + }; + + for (int i=0; i<4; ++i) + { + glClipPlane(GL_CLIP_PLANE0+i, eq[i]); + glEnable(GL_CLIP_PLANE0+i); + } + } + CFont* font = NULL; CStr LastFontName; @@ -924,6 +941,8 @@ void CGUI::DrawText(SGUIText &Text, const CColor &DefaultColor, // TODO To whom it may concern: Thing were not reset, so // I added this line, modify if incorrect -- + for (int i=0; i<4; ++i) + glDisable(GL_CLIP_PLANE0+i); glDisable(GL_TEXTURE_2D); // -- GL } diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h index 41861de61b..342589775c 100755 --- a/source/gui/CGUI.h +++ b/source/gui/CGUI.h @@ -133,7 +133,7 @@ public: * @param z z value. */ void DrawText(SGUIText &Text, const CColor &DefaultColor, - const CPos &pos, const float &z); + const CPos &pos, const float &z, const CRect &clipping); /** * Clean up, call this to clean up all memory allocated diff --git a/source/gui/CList.cpp b/source/gui/CList.cpp index 3b72e08087..1d40d8699b 100644 --- a/source/gui/CList.cpp +++ b/source/gui/CList.cpp @@ -380,7 +380,8 @@ void CList::DrawList(const int &selected, m_ItemsYPositions[i] - scroll > rect.GetHeight()) continue; - IGUITextOwner::Draw(i, color, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]), bz+0.1f); + IGUITextOwner::Draw(i, color, rect.TopLeft() - CPos(0.f, scroll - m_ItemsYPositions[i]), bz+0.1f, + GetListRect()); } } } diff --git a/source/gui/IGUITextOwner.cpp b/source/gui/IGUITextOwner.cpp index 93ab45bb0b..c338e33fef 100755 --- a/source/gui/IGUITextOwner.cpp +++ b/source/gui/IGUITextOwner.cpp @@ -60,7 +60,7 @@ void IGUITextOwner::HandleMessage(const SGUIMessage &Message) } void IGUITextOwner::Draw(const int &index, const CColor &color, const CPos &pos, - const float &z, const CRect &UNUSEDPARAM(clipping)) + const float &z, const CRect &clipping) { if (index < 0 || index >= (int)m_GeneratedTexts.size()) { @@ -70,7 +70,7 @@ void IGUITextOwner::Draw(const int &index, const CColor &color, const CPos &pos, if (GetGUI()) { - GetGUI()->DrawText(*m_GeneratedTexts[index], color, pos, z); + GetGUI()->DrawText(*m_GeneratedTexts[index], color, pos, z, clipping); } }