2 |
2 |
3 interface |
3 interface |
4 |
4 |
5 procedure init; |
5 procedure init; |
6 procedure resetPosition; |
6 procedure resetPosition; |
7 procedure updatePosition; |
|
8 procedure handlePositionUpdate(x, y: LongInt); |
7 procedure handlePositionUpdate(x, y: LongInt); |
|
8 |
|
9 function updateMousePosition(cx, cy, x, y: LongInt): boolean; cdecl; export; |
9 |
10 |
10 implementation |
11 implementation |
11 |
12 |
12 uses SDLh, uVariables; |
13 uses SDLh, uVariables, uTypes; |
13 |
14 |
14 procedure init; |
15 procedure init; |
15 begin |
16 begin |
16 resetPosition(); |
17 //resetPosition(); |
17 end; |
18 end; |
18 |
19 |
19 procedure resetPosition; |
20 procedure resetPosition; |
20 begin |
21 begin |
21 // Move curser by 1px in case it's already centered. |
22 // Move curser by 1px in case it's already centered. |
22 // The game camera in the Alpha for 0.9.23 screwed up if |
23 // The game camera in the Alpha for 0.9.23 screwed up if |
23 // the game started with the mouse already being centered. |
24 // the game started with the mouse already being centered. |
24 // This fixes it, but we might have overlooked a related |
25 // This fixes it, but we might have overlooked a related |
25 // bug somewhere else. |
26 // bug somewhere else. |
26 // No big deal since this function is (so far) only called once. |
27 // No big deal since this function is (so far) only called once. |
27 SDL_WarpMouse((cScreenWidth div 2) + 1, cScreenHeight div 2); |
28 //SDL_WarpMouse((cScreenWidth div 2) + 1, cScreenHeight div 2); |
28 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
29 //SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
29 end; |
30 end; |
30 |
31 |
31 procedure updatePosition; |
32 function updateMousePosition(cx, cy, x, y: LongInt): boolean; cdecl; export; |
32 var x, y: LongInt; |
|
33 begin |
33 begin |
34 SDL_GetMouseState(@x, @y); |
34 if (GameState <> gsConfirm) |
|
35 and (GameState <> gsSuspend) |
|
36 and (GameState <> gsExit) |
|
37 and (GameState <> gsLandgen) |
|
38 and (GameState <> gsStart) |
|
39 and cHasFocus |
|
40 and (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) |
|
41 and ((x <> cx) or (y <> cy)) then |
|
42 begin |
|
43 handlePositionUpdate(x - cx, y - cy); |
35 |
44 |
36 if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then |
45 updateMousePosition:= true |
37 begin |
46 end else |
38 handlePositionUpdate(x - cScreenWidth div 2, y - cScreenHeight div 2); |
47 updateMousePosition:= false |
39 |
|
40 if cHasFocus then |
|
41 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
|
42 end |
|
43 end; |
48 end; |
44 |
49 |
45 procedure handlePositionUpdate(x, y: LongInt); |
50 procedure handlePositionUpdate(x, y: LongInt); |
46 begin |
51 begin |
47 CursorPoint.X:= CursorPoint.X + x; |
52 CursorPoint.X:= CursorPoint.X + x; |