make sure cursor drawing position does not get messed up by screen resize
authorsheepluva
Sun, 01 Mar 2015 16:32:14 +0100
changeset 10839 aa0ceb47da1d
parent 10838 2abe883c9c21
child 10840 6d1986411733
make sure cursor drawing position does not get messed up by screen resize
hedgewars/uChat.pas
--- a/hedgewars/uChat.pas	Sun Mar 01 15:56:00 2015 +0100
+++ b/hedgewars/uChat.pas	Sun Mar 01 16:32:14 2015 +0100
@@ -118,7 +118,7 @@
     // get render size of text
     TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), @coff, nil);
 
-    cursorX:= 7 - cScreenWidth div 2 + coff;
+    cursorX:= 3 + coff;
 
     // calculate selection width on screen
     if selectedPos >= 0 then
@@ -268,7 +268,7 @@
         begin
         // draw cursor
         if ((RealTicks - LastKeyPressTick) and 512) < 256 then
-            DrawLineOnScreen(cursorX, top + 2, cursorX, top + ClHeight - 2, 2.0, $00, $FF, $FF, $FF);
+            DrawLineOnScreen(left + cursorX, top + 2, left + cursorX, top + ClHeight - 2, 2.0, $00, $FF, $FF, $FF);
         end
     else // draw selection
         begin
@@ -276,12 +276,12 @@
         selRect.h:= clHeight - 4;
         if selectionDx < 0 then
             begin
-            selRect.x:= cursorX + selectionDx;
+            selRect.x:= left + cursorX + selectionDx;
             selRect.w:= -selectionDx;
             end
         else
             begin
-            selRect.x:= cursorX;
+            selRect.x:= left + cursorX;
             selRect.w:= selectionDx;
             end;
 
@@ -825,6 +825,7 @@
         SetLine(InputStr, '', true)
     else
         SetLine(InputStr, '/team ', true)
+        // TODO: update InputStrL accordingly!
 end;
 
 procedure initModule;