diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/client/components/chat.cpp | 15 | ||||
| -rw-r--r-- | src/game/client/components/chat.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 1fcdc0cb..0c741008 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -104,6 +104,7 @@ bool CChat::OnInput(IInput::CEvent e) } else { + m_OldChatStringLength = m_Input.GetLength(); m_Input.ProcessInput(e); m_InputUpdate = true; } @@ -222,17 +223,27 @@ void CChat::OnRender() // check if the visible text has to be moved if(m_InputUpdate) { + if(m_ChatStringOffset > 0 && m_Input.GetLength() < m_OldChatStringLength) + m_ChatStringOffset = max(0, m_ChatStringOffset-(m_OldChatStringLength-m_Input.GetLength())); + if(m_ChatStringOffset > m_Input.GetCursorOffset()) - --m_ChatStringOffset; + m_ChatStringOffset -= m_ChatStringOffset-m_Input.GetCursorOffset(); 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) + while(Temp.m_LineCount > 2) + { ++m_ChatStringOffset; + Temp = Cursor; + Temp.m_Flags = 0; + TextRender()->TextEx(&Temp, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset); + TextRender()->TextEx(&Temp, "|", -1); + } } + m_InputUpdate = false; } TextRender()->TextEx(&Cursor, m_Input.GetString()+m_ChatStringOffset, m_Input.GetCursorOffset()-m_ChatStringOffset); diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 85aca296..81ea273e 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -37,6 +37,7 @@ class CChat : public CComponent bool m_Show; bool m_InputUpdate; int m_ChatStringOffset; + int m_OldChatStringLength; static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSayTeam(IConsole::IResult *pResult, void *pUserData); |