forked from mirrors/0ad
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user