Changeset 247 for trunk/UMapType.pas


Ignore:
Timestamp:
Sep 22, 2018, 1:27:09 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Allow only meaningful sizes for cyclic maps.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMapType.pas

    r242 r247  
    2525    procedure GetCellPosNeighbors(CellPos: TPoint; Cell: TCell);
    2626    function GetHexagonPolygon(Pos: TPoint; Size: TPoint): TPolygon;
     27  protected
     28    procedure SetSize(AValue: TPoint); override;
    2729  public
    2830    function CalculatePixelRect: TRect; override;
     
    5355      CellMulY = 1.05;
    5456    function GetTrianglePolygon(Pos: TPoint; Size: TPoint; Reverse: Boolean): TPolygon;
     57  protected
     58    procedure SetSize(AValue: TPoint); override;
    5559  public
    5660    procedure Generate; override;
     
    7579      CellMulY = 3.35;
    7680    function GetTilePolygon(Pos: TPoint; Size: TPoint): TPolygon;
     81  protected
     82    procedure SetSize(AValue: TPoint); override;
    7783  public
    7884    procedure Generate; override;
     
    9298  Result.Points[2] := TPoint.Create(Pos.X, Trunc(Pos.Y + Size.Y / 3.5));
    9399  Result.Points[3] := TPoint.Create(Trunc(Pos.X - Size.X / 2), Pos.Y);
     100end;
     101
     102procedure TIsometricMap.SetSize(AValue: TPoint);
     103begin
     104  inherited;
     105  if Cyclic then
     106    FSize := TPoint.Create(FSize.X, FSize.Y + FSize.Y mod 2);
    94107end;
    95108
     
    181194  Result.Points[4] := TPoint.Create(Trunc(Pos.X - Shift.X * Size.X), Trunc(Pos.Y + Shift.Y * Size.Y));
    182195  Result.Points[5] := TPoint.Create(Trunc(Pos.X - Shift.X * Size.X), Trunc(Pos.Y - Shift.Y * Size.Y));
     196end;
     197
     198procedure THexMap.SetSize(AValue: TPoint);
     199begin
     200  inherited;
     201  if Cyclic then
     202    FSize := TPoint.Create(FSize.X, FSize.Y + FSize.Y mod 2);
    183203end;
    184204
     
    478498end;
    479499
     500procedure TTriangleMap.SetSize(AValue: TPoint);
     501begin
     502  inherited;
     503  if Cyclic then
     504    FSize := TPoint.Create(FSize.X + FSize.X mod 2, FSize.Y + FSize.Y mod 2);
     505end;
     506
    480507procedure TTriangleMap.Generate;
    481508var
Note: See TracChangeset for help on using the changeset viewer.