mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Chat: Keep scroll position constant in ChatBuffer::deleteOldest()
This commit is contained in:
parent
0f6e4a0913
commit
2cdd9b4ab6
1 changed files with 7 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue