Merge pull request #7688 from archimede67/fix-console-selection-2

Fix console selection being moved when keeping scroll offset
This commit is contained in:
Dennis Felsing 2023-12-21 07:54:08 +00:00 committed by GitHub
commit 69b141b71a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)