From 949eea08df858f8579045e0220b23c3a85f24eb7 Mon Sep 17 00:00:00 2001 From: Corantin H Date: Thu, 21 Dec 2023 00:22:12 +0100 Subject: [PATCH] Do not adjust console selection when keeping scroll offset Also decrease `m_NewLineCounter` by the entry line count. --- src/game/client/components/console.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index a0009c835..0721ebe50 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -1111,7 +1111,8 @@ void CGameConsole::OnRender() float LocalOffsetY = OffsetY + pEntry->m_YOffset / (float)pEntry->m_LineCount; OffsetY += pEntry->m_YOffset; - if((pConsole->m_HasSelection || pConsole->m_MouseIsPress) && pConsole->m_NewLineCounter > 0) + // Only apply offset if we do not keep scroll position (m_BacklogCurLine == 0) + if((pConsole->m_HasSelection || pConsole->m_MouseIsPress) && pConsole->m_NewLineCounter > 0 && pConsole->m_BacklogCurLine == 0) { float MouseExtraOff = pEntry->m_YOffset; pConsole->m_MousePress.y -= MouseExtraOff; @@ -1176,14 +1177,13 @@ void CGameConsole::OnRender() pConsole->m_HasSelection = true; } + if(pConsole->m_NewLineCounter > 0) // Decrease by the entry line count since we can have multiline entries + pConsole->m_NewLineCounter -= pEntry->m_LineCount; + pEntry = pConsole->m_Backlog.Prev(pEntry); // reset color TextRender()->TextColor(TextRender()->DefaultTextColor()); - if(pConsole->m_NewLineCounter > 0) - { - --pConsole->m_NewLineCounter; - } First = false; if(!pEntry)