about summary refs log tree commit diff
path: root/src/engine/client/text.cpp
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-10-11 02:29:30 +0200
committeroy <Tom_Adams@web.de>2010-10-11 02:29:30 +0200
commit411db8b88517bc5cf81289bdbcc1ed71326c6f87 (patch)
treeb938b6f72969300c540440e99533550c507803be /src/engine/client/text.cpp
parentde7504282c372a391bca19bb664b9ccf22fad47b (diff)
downloadzcatch-411db8b88517bc5cf81289bdbcc1ed71326c6f87.tar.gz
zcatch-411db8b88517bc5cf81289bdbcc1ed71326c6f87.zip
fixed that chat message gets out of the window. Closes #102
Diffstat (limited to 'src/engine/client/text.cpp')
-rw-r--r--src/engine/client/text.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp
index 0fb6b043..79f95b30 100644
--- a/src/engine/client/text.cpp
+++ b/src/engine/client/text.cpp
@@ -541,6 +541,7 @@ public:
 		int i;
 		int GotNewLine = 0;
 		float DrawX, DrawY;
+		int LineCount;
 		float CursorX, CursorY;
 		const char *pEnd;
 
@@ -590,6 +591,7 @@ public:
 			const char *pEnd = pCurrent+Length;
 			DrawX = CursorX;
 			DrawY = CursorY;
+			LineCount = pCursor->m_LineCount;
 
 			if(pCursor->m_Flags&TEXTFLAG_RENDER)
 			{
@@ -607,7 +609,7 @@ public:
 					Graphics()->SetColor(m_TextR, m_TextG, m_TextB, m_TextA);
 			}
 
-			while(pCurrent < pEnd)
+			while(pCurrent < pEnd && (pCursor->m_MaxLines < 1 || LineCount <= pCursor->m_MaxLines))
 			{
 				int NewLine = 0;
 				const char *pBatchEnd = pEnd;
@@ -666,7 +668,9 @@ public:
 						DrawY += Size;
 						DrawX = (int)(DrawX * FakeToScreenX) / FakeToScreenX; // realign
 						DrawY = (int)(DrawY * FakeToScreenY) / FakeToScreenY;
-						++pCursor->m_LineCount;
+						++LineCount;
+						if(pCursor->m_MaxLines > 0 && LineCount > pCursor->m_MaxLines)
+							break;
 						continue;
 					}
 
@@ -702,7 +706,7 @@ public:
 					GotNewLine = 1;
 					DrawX = (int)(DrawX * FakeToScreenX) / FakeToScreenX; // realign
 					DrawY = (int)(DrawY * FakeToScreenY) / FakeToScreenY;				
-					++pCursor->m_LineCount;
+					++LineCount;
 				}
 			}
 
@@ -711,6 +715,7 @@ public:
 		}
 
 		pCursor->m_X = DrawX;
+		pCursor->m_LineCount = LineCount;
 		
 		if(GotNewLine)
 			pCursor->m_Y = DrawY;