mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
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:
parent
975d1cb5fa
commit
adb435b405
1 changed files with 6 additions and 2 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue