- Timestamp:
- Mar 3, 2014, 12:03:16 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r23 r24 625 625 if (CX >= 0) and (CY >= 0) and (CY < Size.Y) and (CX < Size.X) then 626 626 if Cells[CY, CX].Terrain = ttNormal then begin 627 Points := GetHexagonPolygon(Point(Trunc(X * CellSize.X - Frac(SourceRect.Left / CellSize.X) * CellSize.X),628 Trunc(Y * CellSize.Y - Frac(SourceRect.Top / CellSize.Y) * CellSize.Y)),627 Points := GetHexagonPolygon(Point(Trunc(X * CellSize.X), 628 Trunc(Y * CellSize.Y)), 629 629 Point(Trunc(HexSize.X), Trunc(HexSize.Y))); 630 630 if PtInPoly(Points, Pos) then begin … … 645 645 begin 646 646 with View do begin 647 CellSize := FloatPoint(DefaultCellSize.X / CellMulX * View.Zoom, DefaultCellSize.Y / CellMulY * View.Zoom);648 HexSize := FloatPoint(DefaultCellSize.X * View.Zoom, DefaultCellSize.Y * View.Zoom);649 X := Cell.Pos.X - Trunc(SourceRect.Left / CellSize.X);650 Y := Cell.Pos.Y - Trunc(SourceRect.Top / CellSize.Y);647 CellSize := FloatPoint(DefaultCellSize.X / CellMulX, DefaultCellSize.Y / CellMulY); 648 HexSize := FloatPoint(DefaultCellSize.X, DefaultCellSize.Y); 649 X := Cell.Pos.X; 650 Y := Cell.Pos.Y; 651 651 if (Cell.Pos.Y and 1) = 1 then begin 652 652 X := X + 0.5; … … 654 654 end; 655 655 656 Result.X := Trunc(X * CellSize.X - Frac(SourceRect.Left / CellSize.X) * CellSize.X); 657 Result.Y := Trunc(Y * CellSize.Y - Frac(SourceRect.Top / CellSize.Y) * CellSize.Y); 658 end; 659 end; 660 656 Result.X := Trunc(X * CellSize.X); 657 Result.Y := Trunc(Y * CellSize.Y); 658 end; 659 end; 661 660 662 661 procedure THexMap.Paint(Canvas: TCanvas; View: TView; SelectedCell: TCell; FocusedCell: TCell); … … 672 671 PosFrom, PosTo: TPoint; 673 672 674 procedure PaintHexagon( X, Y: Double; Text: string);673 procedure PaintHexagon(Pos: TPoint; Text: string); 675 674 var 676 675 Points: array of TPoint; … … 684 683 Pen.Style := psClear; 685 684 end; 686 Points := GetHexagonPolygon(Point(Trunc( X), Trunc(Y)), Point(Trunc(HexSize.X), Trunc(HexSize.Y)));685 Points := GetHexagonPolygon(Point(Trunc(Pos.X), Trunc(Pos.Y)), Point(Trunc(HexSize.X), Trunc(HexSize.Y))); 687 686 Polygon(Points); 688 687 Pen.Style := psSolid; 689 688 Font.Color := clWhite; 690 689 Font.Size := Trunc(12 * View.Zoom); 691 TextOut(Round( X) - TextWidth(Text) div 2, Round(Y) - TextHeight(Text) div 2, Text);690 TextOut(Round(Pos.X) - TextWidth(Text) div 2, Round(Pos.Y) - TextHeight(Text) div 2, Text); 692 691 end; 693 692 end; … … 709 708 for CY := Trunc(SourceRect.Top / CellSize.Y) to Trunc(SourceRect.Bottom / CellSize.Y) + 1 do 710 709 for CX := Trunc(SourceRect.Left / CellSize.X) to Trunc(SourceRect.Right / CellSize.X) + 1 do begin 711 X := CX - Trunc(SourceRect.Left / CellSize.X);712 Y := CY - Trunc(SourceRect.Top / CellSize.Y);710 X := CX; 711 Y := CY; 713 712 if (CY and 1) = 1 then begin 714 713 X := X + 0.5; … … 722 721 else Brush.Color := Cell.GetColor; 723 722 Pen.Color := clBlack; 724 PaintHexagon(X * CellSizeZoomed.X - Frac(SourceRect.Left / CellSize.X) * CellSizeZoomed.X, 725 Y * CellSizeZoomed.Y - Frac(SourceRect.Top / CellSize.Y) * CellSizeZoomed.Y, IntToStr(Cell.GetAvialPower)); 723 PaintHexagon(View.CellToCanvasPos(Point(Trunc(X * CellSize.X), 724 Trunc(Y * CellSize.Y))), 725 IntToStr(Cell.GetAvialPower)); 726 726 // Draw arrows 727 727 Pen.Color := clCream; … … 729 729 PosFrom := CellToPos(Cell, View); 730 730 PosTo := CellToPos(TMove(Cell.MovesFrom[I]).CellTo, View); 731 Line( Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 4),732 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 4) ,733 Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2),734 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2)) ;731 Line(View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 4), 732 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 4))), 733 View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2), 734 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2)))); 735 735 end; 736 736 end;
Note:
See TracChangeset
for help on using the changeset viewer.