- Timestamp:
- Sep 20, 2018, 3:33:04 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormClient.pas
r235 r236 169 169 R: TRect; 170 170 StartP: TPoint; 171 VS: TPoint;172 171 CountP: TPoint; 173 172 X, Y: Integer; … … 193 192 194 193 if Game.CyclicMap then begin 195 VS := View.CellToCanvasPos(Game.Map.Size);196 194 TempView := TView.Create; 197 195 TempView.Game := Game; … … 493 491 OldCell: TPlayerCell; 494 492 CellPos: TPoint; 493 P: TPoint; 494 R: TRect; 495 495 begin 496 496 if Assigned(Client) then begin 497 P := TPoint.Create(X, Y); 497 498 if MoveActive then 498 499 if (Abs(StartMousePoint.X - X) > Trunc(Screen.PixelsPerInch * MouseMinDiff)) or 499 500 (Abs(StartMousePoint.Y - Y) > Trunc(Screen.PixelsPerInch * MouseMinDiff)) then 500 501 with Client do begin 501 View.SourceRect := TRect.CreateBounds(TPoint.Create(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom), 502 View.SourceRect := TRect.CreateBounds(TPoint.Create( 503 Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom), 502 504 Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom)), 503 505 View.SourceRect.Size); … … 507 509 OldCell := Client.View.FocusedCell; 508 510 with Core.Game do 509 if Assigned(Client.ControlPlayer) then 510 Cell := Client.ControlPlayer.PlayerMap.PosToCell(Client.View.CanvasToCellPos(TPoint.Create(X, Y))); 511 //else Cell := Client.Game.Map.PosToCell(Client.View.CanvasToCellPos(TPoint.Create(X, Y)), Client.View); 511 if Assigned(Client.ControlPlayer) then begin 512 if Map.Cyclic then begin 513 R := Client.View.CellToCanvasRect(Map.PixelRect); 514 CellPos := TPoint.Create( 515 ModNeg(P.X - R.P1.X, R.Size.X) + R.P1.X, 516 ModNeg(P.Y - R.P1.Y, R.Size.Y) + R.P1.Y 517 ); 518 Cell := Client.ControlPlayer.PlayerMap.PosToCell( 519 Client.View.CanvasToCellPos(CellPos)); 520 end else begin 521 Cell := Client.ControlPlayer.PlayerMap.PosToCell( 522 Client.View.CanvasToCellPos(P)); 523 end; 524 end; 512 525 if Assigned(Cell) then begin 513 526 Client.View.FocusedCell := Cell; … … 530 543 (Abs(StartMousePoint.Y - Y) < Trunc(Screen.PixelsPerInch * MouseMinDiff)) then begin 531 544 if Core.Game.Running and (Core.Game.CurrentPlayer.Mode = pmHuman) and 532 545 (Core.Game.CurrentPlayer = Client.ControlPlayer) then begin 533 546 Client.View.SelectCell(TPoint.Create(X, Y), Client.ControlPlayer, Shift); 534 547 Redraw; -
trunk/UClientGUI.pas
r234 r236 383 383 UnitMove: TUnitMove; 384 384 I: Integer; 385 begin 386 NewSelectedCell := Player.PlayerMap.PosToCell(CanvasToCellPos(Pos)); 385 CellPos: TPoint; 386 R: TRect; 387 begin 388 if TGame(Game).Map.Cyclic then begin 389 R := CellToCanvasRect(TGame(Game).Map.PixelRect); 390 CellPos := TPoint.Create( 391 ModNeg(Pos.X - R.P1.X, R.Size.X) + R.P1.X, 392 ModNeg(Pos.Y - R.P1.Y, R.Size.Y) + R.P1.Y 393 ); 394 NewSelectedCell := Player.PlayerMap.PosToCell( 395 CanvasToCellPos(CellPos)); 396 end else begin 397 NewSelectedCell := Player.PlayerMap.PosToCell( 398 CanvasToCellPos(Pos)); 399 end; 387 400 if Assigned(NewSelectedCell) then begin 388 401 if Assigned(SelectedCell) and TGame(Game).Map.IsCellsNeighbor(NewSelectedCell.MapCell, SelectedCell.MapCell) then begin -
trunk/UGeometry.pas
r235 r236 25 25 class operator Multiply(const A, B: TGPoint<T>): TGPoint<T>; 26 26 //class operator Divide(const A, B: TGPoint<T>): TGPoint<T>; 27 //class operator Modulus(A: TGPoint<T>; B: TGPoint<T>): TGPoint<T>; 27 28 function Min(const A, B: TGPoint<T>): TGPoint<T>; 28 29 function Max(const A, B: TGPoint<T>): TGPoint<T>; … … 120 121 TPolygonF = TGPolygon<TPointF>; 121 122 123 function TypedMod(Numerator, Denominator: Integer): Integer; overload; 124 function TypedMod(Numerator, Denominator: Single): Single; overload; 122 125 function TypedDivide(Divident, Divisor: Integer): Integer; overload; 123 126 function TypedDivide(Divident, Divisor: Single): Single; overload; … … 126 129 function StdPointToPoint(Value: Classes.TPoint): TPoint; 127 130 function PointToStdPoint(Value: TPoint): Classes.TPoint; 131 function ModNeg(A, B: Integer): Integer; 128 132 129 133 130 134 implementation 135 136 function ModNeg(A, B: Integer): Integer; 137 begin 138 if A < 0 then A := A + Ceil(-A / B) * B; 139 Result := A mod B; 140 end; 141 142 function TypedMod(Numerator, Denominator: Integer): Integer; overload; 143 begin 144 Result := Numerator mod Denominator; 145 end; 146 147 function TypedMod(Numerator, Denominator: Single): Single; overload; 148 begin 149 //Result := FMod(Numerator, Denominator); 150 end; 131 151 132 152 function TypedDivide(Divident, Divisor: Integer): Integer; … … 443 463 Result.Y := TypedDivide(A.Y, B.Y); 444 464 end; 465 466 class operator TGPoint<T>.Modulus(A: TGPoint<T>; B: TGPoint<T>): TGPoint<T>; 467 begin 468 Result.X := TypedMod(A.X, B.X); 469 Result.Y := TypedMod(A.Y, B.Y); 470 end; 445 471 } 446 472
Note:
See TracChangeset
for help on using the changeset viewer.