diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine/client/text.cpp | 11 | ||||
| -rw-r--r-- | src/engine/textrender.h | 1 | ||||
| -rw-r--r-- | src/game/client/components/chat.cpp | 24 | ||||
| -rw-r--r-- | src/game/client/components/chat.h | 2 |
4 files changed, 34 insertions, 4 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; diff --git a/src/engine/textrender.h b/src/engine/textrender.h index 6e28b1d5..4fa1ac5b 100644 --- a/src/engine/textrender.h +++ b/src/engine/textrender.h @@ -17,6 +17,7 @@ public: int m_Flags; int m_LineCount; int m_CharCount; + int m_MaxLines; float m_StartX; float m_StartY; diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index d0b216a5..1fcdc0cb 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -31,6 +31,8 @@ void CChat::OnReset() } m_Show = false; + m_InputUpdate = false; + m_ChatStringOffset = 0; } void CChat::OnRelease() @@ -101,7 +103,10 @@ bool CChat::OnInput(IInput::CEvent e) m_pClient->OnRelease(); } else + { m_Input.ProcessInput(e); + m_InputUpdate = true; + } return true; } @@ -203,6 +208,7 @@ void CChat::OnRender() CTextCursor Cursor; TextRender()->SetCursor(&Cursor, x, y, 8.0f, TEXTFLAG_RENDER); Cursor.m_LineWidth = 200.0f; + Cursor.m_MaxLines = 2; if(m_Mode == MODE_ALL) TextRender()->TextEx(&Cursor, Localize("All"), -1); @@ -213,7 +219,23 @@ void CChat::OnRender() TextRender()->TextEx(&Cursor, ": ", -1); - TextRender()->TextEx(&Cursor, m_Input.GetString(), m_Input.GetCursorOffset()); + // check if the visible text has to be moved + if(m_InputUpdate) + { + if(m_ChatStringOffset > m_Input.GetCursorOffset()) + --m_ChatStringOffset; + else + { + CTextCursor Temp = Cursor; + Temp.m_Flags = 0; + TextRender()->TextEx(&Temp, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset); + TextRender()->TextEx(&Temp, "|", -1); + if(Temp.m_LineCount > 2) + ++m_ChatStringOffset; + } + } + + TextRender()->TextEx(&Cursor, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset); CTextCursor Marker = Cursor; TextRender()->TextEx(&Marker, "|", -1); TextRender()->TextEx(&Cursor, m_Input.GetString()+m_Input.GetCursorOffset(), -1); diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index c1867c00..85aca296 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -35,6 +35,8 @@ class CChat : public CComponent int m_Mode; bool m_Show; + bool m_InputUpdate; + int m_ChatStringOffset; static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSayTeam(IConsole::IResult *pResult, void *pUserData); |