From 411db8b88517bc5cf81289bdbcc1ed71326c6f87 Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 11 Oct 2010 02:29:30 +0200 Subject: fixed that chat message gets out of the window. Closes #102 --- src/engine/client/text.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/engine/client/text.cpp') 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; -- cgit 1.4.1