Fix chat lines bleeding below screen for large font
authorWuzzy <Wuzzy2@mail.ru>
Mon, 06 Jul 2020 00:25:13 +0200
changeset 15684 c7fe94d56d6e
parent 15683 0d0f48f098f4
child 15685 78e383fff605
Fix chat lines bleeding below screen for large font
hedgewars/uChat.pas
--- a/hedgewars/uChat.pas	Sun Jul 05 23:36:08 2020 +0200
+++ b/hedgewars/uChat.pas	Mon Jul 06 00:25:13 2020 +0200
@@ -38,7 +38,8 @@
 uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore, uLocale
      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec{$ENDIF};
 
-const MaxStrIndex = 27;
+const MaxStrIndex = 27; // Max. possible string index
+      MaxStrPartial = 7; // Max. displayed strings in normal mode
       MaxInputStrLen = 200;
 
 type TChatLine = record
@@ -389,13 +390,18 @@
     visibleCount:= 0;
 
 // draw chat lines with some distance from screen border
+left:= 4 - cScreenWidth div 2;
 {$IFDEF USE_TOUCH_INTERFACE}
-left:= 4 - cScreenWidth div 2;
-top := 55 + visibleCount * ClHeight; // we start with input line (if any)
+i:= 55;
 {$ELSE}
-left:= 4 - cScreenWidth div 2;
-top := 10 + visibleCount * ClHeight; // we start with input line (if any)
+i:= 10;
 {$ENDIF}
+top := i + visibleCount * ClHeight; // we start with input line (if any)
+if top > cScreenHeight - ClHeight - 60 then
+    begin
+    top:= cScreenHeight - ClHeight - 60;
+    top:= i + top - (top mod ClHeight);
+    end;
 
 // draw chat input line first and under all other lines
 if isInChatMode and (InputStr.Tex <> nil) then
@@ -484,7 +490,7 @@
     t  := 1; // # of current line processed
 
     // draw lines in reverse order
-    while (((t < 7) and (Strs[i].Time > RealTicks)) or ((t <= MaxStrIndex + 1) and showAll))
+    while (((t < MaxStrPartial) and (Strs[i].Time > RealTicks)) or ((t <= MaxStrIndex + 1) and showAll))
     and (Strs[i].Tex <> nil) do
         begin
         top:= top - ClHeight;