From: Kahrl Date: Tue, 23 Apr 2013 21:17:33 +0000 (+0200) Subject: Chat: Keep scroll position constant in ChatBuffer::deleteOldest() X-Git-Tag: 0.4.14~32 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2cdd9b4ab6cfc878dafb88aa8446b12cf2f94278;p=oweals%2Fminetest.git Chat: Keep scroll position constant in ChatBuffer::deleteOldest() --- 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)