hedgewars/uCursor.pas
changeset 8346 3443e0de2c9d
parent 8225 186229af4fc1
child 8444 75db7bb8dce8
equal deleted inserted replaced
8344:3d18f7f71d65 8346:3443e0de2c9d
     3 interface
     3 interface
     4 
     4 
     5 procedure init;
     5 procedure init;
     6 procedure resetPosition;
     6 procedure resetPosition;
     7 procedure updatePosition;
     7 procedure updatePosition;
       
     8 procedure handlePositionUpdate(x, y: LongInt);
     8 
     9 
     9 implementation
    10 implementation
    10 
    11 
    11 uses SDLh, uVariables;
    12 uses SDLh, uVariables;
    12 
    13 
    22 
    23 
    23 procedure updatePosition;
    24 procedure updatePosition;
    24 var x, y: LongInt;
    25 var x, y: LongInt;
    25 begin
    26 begin
    26     SDL_GetMouseState(@x, @y);
    27     SDL_GetMouseState(@x, @y);
    27 
    28     
    28     if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
    29     if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
    29         begin
    30     begin
    30         CursorPoint.X:= CursorPoint.X + x - cScreenWidth div 2;
    31         handlePositionUpdate(x - cScreenWidth div 2, y - cScreenHeight div 2);
    31         CursorPoint.Y:= CursorPoint.Y - y + cScreenHeight div 2;
       
    32 
    32 
    33         if cHasFocus then
    33         if cHasFocus then
    34             SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    34             SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    35         end
    35     end
       
    36 end;
       
    37 
       
    38 procedure handlePositionUpdate(x, y: LongInt);
       
    39 begin
       
    40     CursorPoint.X:= CursorPoint.X + x;
       
    41     CursorPoint.Y:= CursorPoint.Y - y;
    36 end;
    42 end;
    37 
    43 
    38 end.
    44 end.