about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-10-11 12:31:45 +0200
committeroy <Tom_Adams@web.de>2010-10-11 12:31:45 +0200
commiteb4a56edebd1d5bb6cf708bbb34cd4c7e1967eed (patch)
tree8cd7950b9bfee0a11c82908e870606877f11fe31 /src/game/client
parent411db8b88517bc5cf81289bdbcc1ed71326c6f87 (diff)
downloadzcatch-eb4a56edebd1d5bb6cf708bbb34cd4c7e1967eed.tar.gz
zcatch-eb4a56edebd1d5bb6cf708bbb34cd4c7e1967eed.zip
tweaked auto scrolling in the chat window a bit
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/components/chat.cpp15
-rw-r--r--src/game/client/components/chat.h1
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);