tweaked auto scrolling in the chat window a bit

This commit is contained in:
oy 2010-10-11 12:31:45 +02:00
parent 411db8b885
commit eb4a56edeb
2 changed files with 14 additions and 2 deletions

View file

@ -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);

View file

@ -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);