479 SDL_GetMouseState(0, @CursorPoint.X, @CursorPoint.Y); |
478 SDL_GetMouseState(0, @CursorPoint.X, @CursorPoint.Y); |
480 {$ELSE} |
479 {$ELSE} |
481 SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
480 SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
482 {$ENDIF} |
481 {$ENDIF} |
483 CursorPoint.X:= CursorPoint.X - cScreenWidth div 2; |
482 CursorPoint.X:= CursorPoint.X - cScreenWidth div 2; |
484 // CursorPoint.X:= round((CursorPoint.X - cScreenWidth / 2) * 2 / cScaleFactor); |
483 CursorPoint.Y:= cScreenHeight - CursorPoint.Y; |
485 // CursorPoint.Y:= round(CursorPoint.Y * 2 / cScaleFactor); |
|
486 end; |
484 end; |
487 |
485 |
488 if (FollowGear <> nil) and (not isCursorVisible) then |
486 if (FollowGear <> nil) and (not isCursorVisible) then |
489 if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
487 if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
490 begin |
488 begin |
491 FollowGear:= nil; |
489 FollowGear:= nil; |
492 prevPoint.X:= CursorPoint.X; |
490 prevPoint:= CursorPoint; |
493 prevPoint.Y:= CursorPoint.Y; |
|
494 exit |
491 exit |
495 end |
492 end |
496 else begin |
493 else begin |
497 //CursorPoint.x:= (prevPoint.x * 7 + (hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100) + WorldDx) div 8; |
494 CursorPoint.x:= (hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100 + WorldDx); |
498 //CursorPoint.y:= (prevPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8 |
495 //addcaption(inttostr(CursorPoint.X), $AFAFAF, capgrpGameState); |
499 CursorPoint.x:= (hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100) + WorldDx; |
496 CursorPoint.y:= (prevPoint.y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8; |
500 end; |
497 end; |
501 |
498 |
502 if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit; |
499 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit; |
503 |
500 |
504 if AMxShift < 210 then |
501 if AMxShift < 210 then |
505 begin |
502 begin |
506 if CursorPoint.X < cScreenWidth div 2 + AMxShift - 175 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 175; |
503 if CursorPoint.X < cScreenWidth div 2 + AMxShift - 175 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 175; |
507 if CursorPoint.X > cScreenWidth div 2 + AMxShift - 10 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 10; |
504 if CursorPoint.X > cScreenWidth div 2 + AMxShift - 10 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 10; |
508 if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33; |
505 if CursorPoint.Y > 75 + SlotsNum * 33 then CursorPoint.Y:= 75 + SlotsNum * 33; |
509 if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76; |
506 if CursorPoint.Y < 76 then CursorPoint.Y:= 76; |
510 prevPoint:= CursorPoint; |
507 prevPoint:= CursorPoint; |
511 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, CursorPoint.Y); |
508 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y); |
512 exit |
509 exit |
513 end; |
510 end; |
514 |
511 |
515 if isCursorVisible then |
512 if isCursorVisible then |
516 begin |
513 begin |
517 if (not CurrentTeam^.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
514 if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
518 begin |
515 begin |
519 SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy); |
516 SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy); |
520 PrevSentPointTime:= GameTicks |
517 PrevSentPointTime:= GameTicks |
521 end; |
518 end; |
522 end; |
519 end; |
523 |
520 |
524 if isCursorVisible or (FollowGear <> nil) then |
521 if isCursorVisible or (FollowGear <> nil) then |
525 begin |
522 begin |
526 if isCursorVisible then EdgesDist:= cCursorEdgesDist |
523 if isCursorVisible then EdgesDist:= cCursorEdgesDist |
527 else EdgesDist:= cGearScrEdgesDist; |
524 else EdgesDist:= cGearScrEdgesDist; |
528 if CursorPoint.X < - cw + EdgesDist then |
525 if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then |
529 begin |
526 begin |
530 WorldDx:= WorldDx - CursorPoint.X - cw + EdgesDist; |
527 WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist; |
531 CursorPoint.X:= EdgesDist |
528 CursorPoint.X:= - cScreenWidth div 2 + EdgesDist |
532 end else |
529 end else |
533 if CursorPoint.X > cw - EdgesDist then |
530 if CursorPoint.X > cScreenWidth div 2 - EdgesDist then |
534 begin |
531 begin |
535 WorldDx:= WorldDx - CursorPoint.X + cw - EdgesDist; |
532 WorldDx:= WorldDx - CursorPoint.X + cScreenWidth div 2 - EdgesDist; |
536 CursorPoint.X:= cScreenWidth - EdgesDist |
533 CursorPoint.X:= cScreenWidth + cScreenWidth div 2 - EdgesDist |
537 end; |
534 end; |
538 if CursorPoint.Y < EdgesDist then |
535 if CursorPoint.Y < EdgesDist then |
539 begin |
536 begin |
540 WorldDy:= WorldDy - CursorPoint.Y + EdgesDist; |
537 WorldDy:= WorldDy + CursorPoint.Y - EdgesDist; |
541 CursorPoint.Y:= EdgesDist |
538 CursorPoint.Y:= EdgesDist |
542 end else |
539 end else |
543 if CursorPoint.Y > cScreenHeight - EdgesDist then |
540 if CursorPoint.Y > cScreenHeight - EdgesDist then |
544 begin |
541 begin |
545 WorldDy:= WorldDy - CursorPoint.Y + round(cScreenHeight * 2 / cScaleFactor) - EdgesDist; |
542 WorldDy:= WorldDy + CursorPoint.Y - cScreenHeight + EdgesDist; |
546 CursorPoint.Y:= cScreenHeight - EdgesDist |
543 CursorPoint.Y:= cScreenHeight - EdgesDist |
547 end; |
544 end; |
548 end else |
545 end else |
549 if cHasFocus then |
546 if cHasFocus then |
550 begin |
547 begin |
551 WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; |
548 WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; |
552 WorldDy:= WorldDy - CursorPoint.Y + prevPoint.Y; |
549 WorldDy:= WorldDy + CursorPoint.Y - prevPoint.Y; |
553 CursorPoint.X:= 0; |
550 CursorPoint.X:= 0; |
554 CursorPoint.Y:= cScreenHeight div 2; |
551 CursorPoint.Y:= cScreenHeight div 2; |
555 end; |
552 end; |
556 |
553 |
557 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, CursorPoint.Y); |
|
558 prevPoint:= CursorPoint; |
554 prevPoint:= CursorPoint; |
|
555 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y); |
559 if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater; |
556 if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater; |
560 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; |
557 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; |
561 if WorldDx < -round(LAND_WIDTH * 2 / cScaleFactor) then WorldDx:= -round(LAND_WIDTH * 2 / cScaleFactor); |
558 if WorldDx < -round(LAND_WIDTH * 2 / cScaleFactor) then WorldDx:= -round(LAND_WIDTH * 2 / cScaleFactor); |
562 if WorldDx > cw then WorldDx:= cw; |
559 if WorldDx > cw then WorldDx:= cw; |
563 end; |
560 end; |