Fix inconsistent chat line spacing

Chat lines with different text heights were being positioned incorrectly
because each line's position was calculated using its own height rather
than the cumulative height of all previous lines.

This caused overlapping text and inconsistent vertical spacing when
messages had varying font sizes or line counts.

Now properly track cumulative height as we iterate through lines to
ensure each message appears at the correct vertical position regardless
of individual line heights.
This commit is contained in:
Atrik 2026-02-20 11:19:04 +01:00 committed by Ralph Sennhauser
parent 975d1cb5fa
commit adb435b405

View file

@ -31,6 +31,8 @@ class ChatOverlay
displayChatMessages()
{
let currentTop = 0;
for (let i = 0; i < this.chatLinesNumber; ++i)
{
const chatMessage = this.chatMessages[i];
@ -40,11 +42,13 @@ class ChatOverlay
const newSize = this.chatLines[i].getPreferredTextSize();
this.chatLines[i].size = {
"top": i * newSize.height,
"bottom": (i + 1) * newSize.height,
"top": currentTop,
"bottom": currentTop + newSize.height,
"right": newSize.width
};
currentTop += newSize.height;
if (chatMessage.callback)
this.chatLines[i].onPress = chatMessage.callback;