since fonts can be loaded in late, update cursor position before first chat display
authorsheepluva
Sun, 01 Mar 2015 17:12:02 +0100
changeset 10842 a039464cbb4a
parent 10841 6b0a839f399e
child 10843 5c2ef0507971
since fonts can be loaded in late, update cursor position before first chat display
hedgewars/uChat.pas
--- a/hedgewars/uChat.pas	Sun Mar 01 16:45:24 2015 +0100
+++ b/hedgewars/uChat.pas	Sun Mar 01 17:12:02 2015 +0100
@@ -62,6 +62,7 @@
     showAll: boolean;
     liveLua: boolean;
     ChatHidden: boolean;
+    firstDraw: boolean;
     InputLinePrefix: shortstring;
     // cursor
     cursorPos, cursorX, selectedPos, selectionDx: LongInt;
@@ -118,7 +119,7 @@
     // get render size of text
     TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), @coff, nil);
 
-    cursorX:= 3 + coff;
+    cursorX:= 2 + coff;
 
     // calculate selection width on screen
     if selectedPos >= 0 then
@@ -263,6 +264,12 @@
 // draw chat input line first and under all other lines
 if (GameState = gsChat) and (InputStr.Tex <> nil) then
     begin
+    if firstDraw then
+        begin
+        UpdateCursorCoords();
+        firstDraw:= false;
+        end;
+
     DrawTexture(left, top, InputStr.Tex);
     if selectedPos < 0 then
         begin
@@ -852,6 +859,7 @@
     missedCount:= 0;
     liveLua:= false;
     ChatHidden:= false;
+    firstDraw:= true;
 
     InputLinePrefix:= UserNick + '> ';
     inputStr.s:= '';