- Timestamp:
- Aug 17, 2014, 1:22:26 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r50 r51 85 85 FSize: TPoint; 86 86 function GetSize: TPoint; virtual; 87 procedure PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView; 88 Cell: TCell); 87 89 procedure SetSize(AValue: TPoint); virtual; 88 90 public … … 468 470 PosFrom, PosTo: TPoint; 469 471 Angle: Double; 470 471 procedure PaintHexagon(Pos: TPoint; Text: string);472 var473 TextPos: TPoint;474 I: Integer;475 begin476 with Canvas do begin477 if Assigned(View.FocusedCell) and (View.FocusedCell = TCell(Cells[CY * FSize.X + CX])) then begin478 Pen.Color := clYellow;479 Pen.Style := psSolid;480 Pen.Width := 1;481 end else482 if TCell(Cells[CY * FSize.X + CX]).Terrain = ttCity then begin483 // Cannot set clear border as it will display shifted on gtk2484 //Pen.Style := psClear;485 Pen.Color := clBlack;486 Pen.Style := psSolid;487 Pen.Width := 3;488 end else begin489 // Cannot set clear border as it will display shifted on gtk2490 //Pen.Style := psClear;491 Pen.Color := Brush.Color;492 Pen.Style := psSolid;493 Pen.Width := 0;494 end;495 // Transform view496 SetLength(Points, Length(TCell(Cells[CY * FSize.X + CX]).Polygon));497 for I := 0 to Length(Points) - 1 do498 Points[I] := View.CellToCanvasPos(TCell(Cells[CY * FSize.X + CX]).Polygon[I]);499 500 Polygon(Points, False, 0, Length(Points));501 //Rectangle(Trunc(Pos.X), Trunc(Pos.Y), Trunc(Pos.X + HexSize.X), Trunc(Pos.Y + HexSize.Y));502 Pen.Style := psSolid;503 Font.Color := clWhite;504 Font.Size := Trunc(12 * View.Zoom);505 TextPos := View.CellToCanvasPos(Pos);506 TextOut(Round(TextPos.X) - TextWidth(Text) div 2, Round(TextPos.Y) - TextHeight(Text) div 2, Text);507 end;508 end;509 510 472 begin 511 473 CellSize := FloatPoint(DefaultCellSize.X * SquareCellMulX, DefaultCellSize.Y * SquareCellMulY); … … 525 487 else Brush.Color := Cell.GetColor; 526 488 Pen.Color := clBlack; 527 Paint Hexagon(Point(Trunc(X * CellSize.X),489 PaintCell(Canvas, Point(Trunc(X * CellSize.X), 528 490 Trunc(Y * CellSize.Y)), 529 IntToStr(Cell.GetAvialPower) );491 IntToStr(Cell.GetAvialPower), View, TCell(Cells[CY * FSize.X + CX])); 530 492 // Draw arrows 531 493 Pen.Color := clCream; … … 670 632 if Power > MaxPower then Power := MaxPower; 671 633 end; 634 end; 635 end; 636 637 procedure TMap.PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView; 638 Cell: TCell); 639 var 640 I: Integer; 641 TextPos: TPoint; 642 Points: array of TPoint; 643 begin 644 with Canvas do begin 645 if Assigned(View.FocusedCell) and (View.FocusedCell = Cell) then begin 646 Pen.Color := clYellow; 647 Pen.Style := psSolid; 648 Pen.Width := 1; 649 end else 650 if Cell.Terrain = ttCity then begin 651 // Cannot set clear border as it will display shifted on gtk2 652 //Pen.Style := psClear; 653 Pen.Color := clBlack; 654 Pen.Style := psSolid; 655 Pen.Width := 3; 656 end else begin 657 // Cannot set clear border as it will display shifted on gtk2 658 //Pen.Style := psClear; 659 Pen.Color := Brush.Color; 660 Pen.Style := psSolid; 661 Pen.Width := 0; 662 end; 663 // Transform view 664 SetLength(Points, Length(Cell.Polygon)); 665 for I := 0 to Length(Points) - 1 do 666 Points[I] := View.CellToCanvasPos(Cell.Polygon[I]); 667 668 Polygon(Points, False, 0, Length(Points)); 669 Pen.Style := psSolid; 670 Font.Color := clWhite; 671 Font.Size := Trunc(12 * View.Zoom); 672 TextPos := View.CellToCanvasPos(Pos); 673 TextOut(Round(TextPos.X) - TextWidth(Text) div 2, Round(TextPos.Y) - TextHeight(Text) div 2, Text); 672 674 end; 673 675 end; … … 1615 1617 Angle: Double; 1616 1618 ArrowCenter: TPoint; 1617 1618 procedure PaintHexagon(Pos: TPoint; Text: string; View: TView);1619 var1620 I: Integer;1621 TextPos: TPoint;1622 begin1623 with Canvas do begin1624 if Assigned(View.FocusedCell) and (View.FocusedCell = TCell(Cells[CY * FSize.X + CX])) then begin1625 Pen.Color := clYellow;1626 Pen.Style := psSolid;1627 Pen.Width := 1;1628 end else1629 if TCell(Cells[CY * FSize.X + CX]).Terrain = ttCity then begin1630 // Cannot set clear border as it will display shifted on gtk21631 //Pen.Style := psClear;1632 Pen.Color := clBlack;1633 Pen.Style := psSolid;1634 Pen.Width := 3;1635 end else begin1636 // Cannot set clear border as it will display shifted on gtk21637 //Pen.Style := psClear;1638 Pen.Color := Brush.Color;1639 Pen.Style := psSolid;1640 Pen.Width := 0;1641 end;1642 // Transform view1643 SetLength(Points, Length(TCell(Cells[CY * FSize.X + CX]).Polygon));1644 for I := 0 to Length(Points) - 1 do1645 Points[I] := View.CellToCanvasPos(TCell(Cells[CY * FSize.X + CX]).Polygon[I]);1646 1647 Polygon(Points, False, 0, Length(Points));1648 //Rectangle(Trunc(Pos.X), Trunc(Pos.Y), Trunc(Pos.X + HexSize.X), Trunc(Pos.Y + HexSize.Y));1649 Pen.Style := psSolid;1650 Font.Color := clWhite;1651 Font.Size := Trunc(12 * View.Zoom);1652 TextPos := View.CellToCanvasPos(Pos);1653 TextOut(Round(TextPos.X) - TextWidth(Text) div 2, Round(TextPos.Y) - TextHeight(Text) div 2, Text);1654 end;1655 end;1656 1657 1619 begin 1658 1620 CellSize := FloatPoint(DefaultCellSize.X / HexCellMulX, DefaultCellSize.Y / HexCellMulY); … … 1677 1639 else Brush.Color := Cell.GetColor; 1678 1640 Pen.Color := clBlack; 1679 Paint Hexagon(Point(Trunc(X * CellSize.X),1641 PaintCell(Canvas, Point(Trunc(X * CellSize.X), 1680 1642 Trunc(Y * CellSize.Y)), 1681 IntToStr(Cell.GetAvialPower), View );1643 IntToStr(Cell.GetAvialPower), View, TCell(Cells[CY * FSize.X + CX])); 1682 1644 // Draw arrows 1683 1645 Pen.Color := clCream;
Note:
See TracChangeset
for help on using the changeset viewer.