Changeset 247


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

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.pas

    r243 r247  
    566566    CityEnabled := CheckBoxCity.Checked;
    567567    CityPercentage := SpinEditCityPercent.Value;
     568    Map.Cyclic := CyclicMap;
    568569    Map.Size := TPoint.Create(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value);
    569570    GrowAmount := TGrowAmount(RadioGroupGrowAmount.ItemIndex);
  • trunk/UMap.pas

    r244 r247  
    134134  TMap = class
    135135  private
    136     FSize: TPoint;
    137136    function GetPixelRect: TRect;
    138137    function GetSize: TPoint; virtual;
    139138    function SearchDifferentCellArea(List: TCells; SourceArea,
    140139      DestArea: TMapArea): TCell;
    141     procedure SetSize(AValue: TPoint); virtual;
    142140  protected
     141    FSize: TPoint;
    143142    FPixelRect: TRect;
    144143    FNewCellId: Integer;
    145144    function GetNewCellId: Integer; virtual;
    146145    procedure SortNeighborsByAngle;
     146    procedure SetSize(AValue: TPoint); virtual;
    147147  public
    148148    Game: TObject; //TGame;
     
    563563  // Do not assign Game field
    564564  MaxPower := Source.MaxPower;
     565  Cyclic := Source.Cyclic;
    565566  Size := Source.Size;
    566567  DefaultCellSize := Source.DefaultCellSize;
    567568  Shape := Source.Shape;
    568569  Image.Picture.Bitmap.Assign(Source.Image.Picture.Bitmap);
    569   Cyclic := Source.Cyclic;
    570570
    571571  // TODO: How to copy cells
  • 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.