summaryrefslogtreecommitdiff
path: root/src/chat.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-04-23 23:17:33 +0200
committerparamat <mat.gregory@virginmedia.com>2016-05-08 02:51:23 +0100
commit2cdd9b4ab6cfc878dafb88aa8446b12cf2f94278 (patch)
treee4a23dcaa7198a7856e1197dff913bde397d057f /src/chat.cpp
parent0f6e4a0913ea3d96a34dd2da15b140a4b54b0983 (diff)
downloadminetest-2cdd9b4ab6cfc878dafb88aa8446b12cf2f94278.tar.gz
minetest-2cdd9b4ab6cfc878dafb88aa8446b12cf2f94278.tar.bz2
minetest-2cdd9b4ab6cfc878dafb88aa8446b12cf2f94278.zip
Chat: Keep scroll position constant in ChatBuffer::deleteOldest()
Diffstat (limited to 'src/chat.cpp')
-rw-r--r--src/chat.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/chat.cpp b/src/chat.cpp
index ab945444f..cebe31225 100644
--- a/src/chat.cpp
+++ b/src/chat.cpp
@@ -97,6 +97,8 @@ void ChatBuffer::step(f32 dtime)
void ChatBuffer::deleteOldest(u32 count)
{
+ bool at_bottom = (m_scroll == getBottomScrollPos());
+
u32 del_unformatted = 0;
u32 del_formatted = 0;
@@ -120,6 +122,11 @@ void ChatBuffer::deleteOldest(u32 count)
m_unformatted.erase(m_unformatted.begin(), m_unformatted.begin() + del_unformatted);
m_formatted.erase(m_formatted.begin(), m_formatted.begin() + del_formatted);
+
+ if (at_bottom)
+ m_scroll = getBottomScrollPos();
+ else
+ scrollAbsolute(m_scroll - del_formatted);
}
void ChatBuffer::deleteByAge(f32 maxAge)