mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
tweaked auto scrolling in the chat window a bit
This commit is contained in:
parent
411db8b885
commit
eb4a56edeb
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue