1 (* |
1 (* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2009 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
416 procedure MoveCamera; |
416 procedure MoveCamera; |
417 const PrevSentPointTime: LongWord = 0; |
417 const PrevSentPointTime: LongWord = 0; |
418 var EdgesDist: LongInt; |
418 var EdgesDist: LongInt; |
419 begin |
419 begin |
420 if (not (CurrentTeam^.ExtDriven and isCursorVisible)) |
420 if (not (CurrentTeam^.ExtDriven and isCursorVisible)) |
421 and cHasFocus then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
421 and cHasFocus then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
422 |
422 |
423 if (FollowGear <> nil) and (not isCursorVisible) then |
423 if (FollowGear <> nil) and (not isCursorVisible) then |
424 if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
424 if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
425 begin |
425 begin |
426 FollowGear:= nil; |
426 FollowGear:= nil; |
427 exit |
427 prevPoint.X:= CursorPoint.X; |
428 end |
428 prevPoint.Y:= CursorPoint.Y; |
429 else begin |
429 exit |
430 CursorPoint.x:= (prevPoint.x * 7 + (hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100) + WorldDx) div 8; |
430 end |
431 CursorPoint.y:= (prevPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8 |
431 else begin |
432 end; |
432 CursorPoint.x:= (prevPoint.x * 7 + (hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100) + WorldDx) div 8; |
|
433 CursorPoint.y:= (prevPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8 |
|
434 end; |
433 |
435 |
434 if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit; |
436 if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit; |
435 |
437 |
436 if AMxShift < 210 then |
438 if AMxShift < 210 then |
437 begin |
439 begin |
438 if CursorPoint.X < cScreenWidth + AMxShift - 175 then CursorPoint.X:= cScreenWidth + AMxShift - 175; |
440 if CursorPoint.X < cScreenWidth + AMxShift - 175 then CursorPoint.X:= cScreenWidth + AMxShift - 175; |
439 if CursorPoint.X > cScreenWidth + AMxShift - 10 then CursorPoint.X:= cScreenWidth + AMxShift - 10; |
441 if CursorPoint.X > cScreenWidth + AMxShift - 10 then CursorPoint.X:= cScreenWidth + AMxShift - 10; |
440 if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33; |
442 if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33; |
441 if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76; |
443 if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76; |
442 prevPoint:= CursorPoint; |
444 prevPoint:= CursorPoint; |
443 if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
445 if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
444 exit |
446 exit |
445 end; |
447 end; |
446 |
448 |
447 if isCursorVisible then |
449 if isCursorVisible then |
448 begin |
450 begin |
449 if (not CurrentTeam^.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
451 if (not CurrentTeam^.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
450 begin |
452 begin |
451 SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy); |
453 SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy); |
452 PrevSentPointTime:= GameTicks |
454 PrevSentPointTime:= GameTicks |
453 end; |
455 end; |
454 end; |
456 end; |
455 |
457 |
456 if isCursorVisible or (FollowGear <> nil) then |
458 if isCursorVisible or (FollowGear <> nil) then |
457 begin |
459 begin |
458 if isCursorVisible then EdgesDist:= cCursorEdgesDist |
460 if isCursorVisible then EdgesDist:= cCursorEdgesDist |
459 else EdgesDist:= cGearScrEdgesDist; |
461 else EdgesDist:= cGearScrEdgesDist; |