- Timestamp:
- Sep 18, 2018, 6:11:18 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormNew.lfm
r221 r229 1 1 object FormNew: TFormNew 2 Left = 5542 Left = 365 3 3 Height = 748 4 Top = 1 494 Top = 167 5 5 Width = 1154 6 6 Caption = 'New game' … … 21 21 Top = 4 22 22 Width = 749 23 ActivePage = TabSheetM ode23 ActivePage = TabSheetMap 24 24 Align = alClient 25 25 BorderSpacing.Around = 4 26 TabIndex = 026 TabIndex = 2 27 27 TabOrder = 0 28 28 object TabSheetMode: TTabSheet … … 459 459 Caption = 'Max units per cell:' 460 460 ParentColor = False 461 end 462 object CheckBoxCyclicMap: TCheckBox 463 Left = 472 464 Height = 27 465 Top = 137 466 Width = 253 467 Anchors = [akTop, akLeft, akRight] 468 AutoSize = False 469 Caption = 'Cyclic map' 470 TabOrder = 16 461 471 end 462 472 end -
trunk/Forms/UFormNew.pas
r221 r229 35 35 CheckBoxCity: TCheckBox; 36 36 CheckBoxSymetricMap: TCheckBox; 37 CheckBoxCyclicMap: TCheckBox; 37 38 CheckBoxVoid: TCheckBox; 38 39 ComboBoxGridType: TComboBox; … … 510 511 with Core.GameSettings do begin 511 512 CheckBoxSymetricMap.Checked := SymetricMap; 513 CheckBoxCyclicMap.Checked := CyclicMap; 512 514 CheckBoxVoid.Checked := VoidEnabled; 513 515 SpinEditVoidPercent.Value := VoidPercentage; … … 554 556 with Core.GameSettings do begin 555 557 SymetricMap := CheckBoxSymetricMap.Checked; 558 CyclicMap := CheckBoxCyclicMap.Checked; 556 559 VoidEnabled := CheckBoxVoid.Checked; 557 560 VoidPercentage := SpinEditVoidPercent.Value; -
trunk/Forms/UFormPlayersStats.lfm
r208 r229 1 1 object FormPlayersStats: TFormPlayersStats 2 Left = 7092 Left = 468 3 3 Height = 300 4 Top = 6374 Top = 477 5 5 Width = 746 6 6 Caption = 'Players stats' -
trunk/Forms/UFormUnitMoves.lfm
r150 r229 7 7 ClientHeight = 418 8 8 ClientWidth = 802 9 DesignTimePPI = 120 9 10 OnClose = FormClose 10 11 OnShow = FormShow 11 LCLVersion = '1.8. 0.4'12 LCLVersion = '1.8.2.0' 12 13 object ListView1: TListView 13 14 Left = 0 -
trunk/Languages/xtactics.cs.po
r222 r229 407 407 msgid "Cities" 408 408 msgstr "Města" 409 410 #: tformnew.checkboxcyclicmap.caption 411 msgid "Cyclic map" 412 msgstr "" 409 413 410 414 #: tformnew.checkboxfogofwar.caption -
trunk/Languages/xtactics.po
r221 r229 393 393 msgctxt "tformnew.checkboxcity.caption" 394 394 msgid "Cities" 395 msgstr "" 396 397 #: tformnew.checkboxcyclicmap.caption 398 msgid "Cyclic map" 395 399 msgstr "" 396 400 -
trunk/UGame.pas
r224 r229 456 456 VoidPercentage: Integer; 457 457 SymetricMap: Boolean; 458 CyclicMap: Boolean; 458 459 GrowCells: TGrowCells; 459 460 GrowAmount: TGrowAmount; … … 1613 1614 function TMap.IsValidIndex(Index: TPoint): Boolean; 1614 1615 begin 1615 Result := False; 1616 Result := (Index.X >= 0) and (Index.X < Size.X) and 1617 (Index.Y >= 0) and (Index.Y < Size.Y); 1616 1618 end; 1617 1619 … … 2085 2087 procedure TCell.ConnectTo(Cell: TCell); 2086 2088 begin 2087 Cell.Neighbors.Add(Self); 2088 Neighbors.Add(Cell); 2089 // Connect only if already not connected 2090 if Neighbors.IndexOf(Cell) < 0 then begin 2091 Cell.Neighbors.Add(Self); 2092 Neighbors.Add(Cell); 2093 end; 2089 2094 end; 2090 2095 … … 3136 3141 VoidPercentage := Source.VoidPercentage; 3137 3142 SymetricMap := Source.SymetricMap; 3143 CyclicMap := Source.CyclicMap; 3138 3144 GrowCells := Source.GrowCells; 3139 3145 GrowAmount := Source.GrowAmount; … … 3157 3163 SetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName)); 3158 3164 SetValue(DOMString(Path + '/SymetricMap'), SymetricMap); 3165 SetValue(DOMString(Path + '/CyclicMap'), CyclicMap); 3159 3166 SetValue(DOMString(Path + '/FogOfWar'), FogOfWar); 3160 3167 SetValue(DOMString(Path + '/VoidEnabled'), VoidEnabled); … … 3185 3192 MapImageFileName := string(GetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName))); 3186 3193 SymetricMap := GetValue(DOMString(Path + '/SymetricMap'), False); 3194 CyclicMap := GetValue(DOMString(Path + '/CyclicMap'), False); 3187 3195 FogOfWar := GetValue(DOMString(Path + '/FogOfWar'), False); 3188 3196 VoidEnabled := GetValue(DOMString(Path + '/VoidEnabled'), True); … … 3225 3233 with RootNode do begin 3226 3234 SymetricMap := ReadBoolean(RootNode, 'SymetricMap', False); 3235 CyclicMap := ReadBoolean(RootNode, 'CyclicMap', False); 3227 3236 FogOfWar := ReadBoolean(RootNode, 'FogOfWar', False); 3228 3237 VoidEnabled := ReadBoolean(RootNode, 'VoidEnabled', False); … … 3276 3285 with RootNode do begin 3277 3286 WriteBoolean(RootNode, 'SymetricMap', SymetricMap); 3287 WriteBoolean(RootNode, 'CyclicMap', CyclicMap); 3278 3288 WriteBoolean(RootNode, 'FogOfWar', FogOfWar); 3279 3289 WriteBoolean(RootNode, 'VoidEnabled', VoidEnabled); … … 3478 3488 TurnCounter := 1; 3479 3489 3490 Map.Cyclic := CyclicMap; 3480 3491 Map.Generate; 3481 3492 Map.MaxPower := MaxPower; -
trunk/UMap.pas
r193 r229 23 23 CellMulY = 1.292; 24 24 function IsCellsPosNeighbor(CellPos1, CellPos2: TPoint): Boolean; 25 procedure GetCellPosNeighbors(CellPos: TPoint; Neighbours: TCells);25 procedure GetCellPosNeighbors(CellPos: TPoint; Cell: TCell); 26 26 function GetHexagonPolygon(Pos: TPoint; Size: TPoint): TPolygon; 27 27 public 28 28 procedure LoadFromFile(FileName: string); override; 29 29 procedure SaveToFile(FileName: string); override; 30 function IsValidIndex(Index: TPoint): Boolean; override;31 30 procedure Generate; override; 32 31 end; … … 38 37 function GetSquarePolygon(Pos: TPoint; Size: TPoint): TPolygon; 39 38 public 40 function IsValidIndex(Index: TPoint): Boolean; override;41 39 procedure Generate; override; 42 40 end; … … 48 46 function GetTrianglePolygon(Pos: TPoint; Size: TPoint; Reverse: Boolean): TPolygon; 49 47 public 50 function IsValidIndex(Index: TPoint): Boolean; override;51 48 procedure Generate; override; 52 49 end; … … 69 66 function GetTilePolygon(Pos: TPoint; Size: TPoint): TPolygon; 70 67 public 71 function IsValidIndex(Index: TPoint): Boolean; override;72 68 procedure Generate; override; 73 69 end; … … 85 81 Result.Points[2] := TPoint.Create(Pos.X, Trunc(Pos.Y + Size.Y / 3.5)); 86 82 Result.Points[3] := TPoint.Create(Trunc(Pos.X - Size.X / 2), Pos.Y); 87 end;88 89 function TIsometricMap.IsValidIndex(Index: TPoint): Boolean;90 begin91 Result := (Index.X >= 0) and (Index.X < Size.X) and92 (Index.Y >= 0) and (Index.Y < Size.Y);93 83 end; 94 84 … … 125 115 for X := 0 to Size.X - 1 do 126 116 with Cells[Y * Size.X + X] do begin 127 P := TPoint.Create(X + 0 + (Y mod 2), Y + 1); 128 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 129 P := TPoint.Create(X - 1 + (Y mod 2), Y + 1); 130 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 131 P := TPoint.Create(X + 0 + (Y mod 2), Y - 1); 132 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 133 P := TPoint.Create(X - 1 + (Y mod 2), Y - 1); 134 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 117 if Cyclic then begin 118 P := TPoint.Create(X + 0 + (Y mod 2), Y + 1); 119 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 120 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 121 P := TPoint.Create(X - 1 + (Y mod 2), Y + 1); 122 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 123 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 124 P := TPoint.Create(X + 0 + (Y mod 2), Y - 1); 125 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 126 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 127 P := TPoint.Create(X - 1 + (Y mod 2), Y - 1); 128 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 129 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 130 end else begin 131 P := TPoint.Create(X + 0 + (Y mod 2), Y + 1); 132 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 133 P := TPoint.Create(X - 1 + (Y mod 2), Y + 1); 134 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 135 P := TPoint.Create(X + 0 + (Y mod 2), Y - 1); 136 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 137 P := TPoint.Create(X - 1 + (Y mod 2), Y - 1); 138 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 139 end; 135 140 end; 136 141 … … 206 211 end; 207 212 208 function THexMap.IsValidIndex(Index: TPoint): Boolean; 209 begin 210 Result := (Index.X >= 0) and (Index.X < Size.X) and 211 (Index.Y >= 0) and (Index.Y < Size.Y); 212 end; 213 214 procedure THexMap.GetCellPosNeighbors(CellPos: TPoint; Neighbours: TCells); 213 procedure THexMap.GetCellPosNeighbors(CellPos: TPoint; Cell: TCell); 215 214 var 216 215 X, Y: Integer; 217 216 P: TPoint; 218 begin 219 Neighbours.Count := 0; 217 PMod: TPoint; 218 begin 220 219 for Y := -1 to 1 do 221 220 for X := -1 to 1 do begin 222 221 P := TPoint.Create(CellPos.X + X, CellPos.Y + Y); 223 if IsValidIndex(P) and IsCellsPosNeighbor(CellPos, P) then begin 224 Neighbours.Add(Cells[P.Y * Size.X + P.X]); 222 PMod := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 223 if Cyclic then begin 224 if IsValidIndex(PMod) and IsCellsPosNeighbor(CellPos, P) then begin 225 Cell.ConnectTo(Cells[PMod.Y * Size.X + PMod.X]); 226 end; 227 end else begin 228 if IsValidIndex(P) and IsCellsPosNeighbor(CellPos, P) then begin 229 Cell.ConnectTo(Cells[P.Y * Size.X + P.X]); 230 end; 225 231 end; 226 232 end; … … 258 264 for X := 0 to Size.X - 1 do 259 265 with Cells[Y * Size.X + X] do begin 260 GetCellPosNeighbors(TPoint.Create(X, Y), Neighbors);266 GetCellPosNeighbors(TPoint.Create(X, Y), Cells[Y * Size.X + X]); 261 267 end; 262 268 … … 292 298 for X := 0 to Size.X - 1 do 293 299 with Cells[Y * Size.X + X] do begin 294 P := TPoint.Create(X + 1, Y + 0); 295 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 296 P := TPoint.Create(X + 0, Y + 1); 297 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 298 P := TPoint.Create(X - 1, Y + 0); 299 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 300 P := TPoint.Create(X + 0, Y - 1); 301 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 300 if Cyclic then begin 301 P := TPoint.Create(X + 1, Y + 0); 302 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 303 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 304 P := TPoint.Create(X + 0, Y + 1); 305 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 306 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 307 P := TPoint.Create(X - 1, Y + 0); 308 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 309 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 310 P := TPoint.Create(X + 0, Y - 1); 311 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 312 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 313 end else begin 314 P := TPoint.Create(X + 1, Y + 0); 315 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 316 P := TPoint.Create(X + 0, Y + 1); 317 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 318 P := TPoint.Create(X - 1, Y + 0); 319 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 320 P := TPoint.Create(X + 0, Y - 1); 321 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 322 end; 302 323 end; 303 324 304 325 FPixelRect := CalculatePixelRect; 305 end;306 307 function TSquareMap.IsValidIndex(Index: TPoint): Boolean;308 begin309 Result := (Index.X >= 0) and (Index.X < Size.X) and310 (Index.Y >= 0) and (Index.Y < Size.Y);311 326 end; 312 327 … … 402 417 end; 403 418 404 function TTriangleMap.IsValidIndex(Index: TPoint): Boolean;405 begin406 Result := (Index.X >= 0) and (Index.X < Size.X) and407 (Index.Y >= 0) and (Index.Y < Size.Y);408 end;409 410 419 procedure TTriangleMap.Generate; 411 420 var … … 440 449 if Boolean(X mod 2) xor Boolean(Y mod 2) then Rev := -1 441 450 else Rev := 1; 442 P := TPoint.Create(X + 1, Y + 0); 443 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 444 P := TPoint.Create(X + 0, Y - 1 * Rev); 445 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 446 P := TPoint.Create(X - 1, Y + 0); 447 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 451 if Cyclic then begin 452 P := TPoint.Create(X + 1, Y + 0); 453 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 454 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 455 P := TPoint.Create(X + 0, Y - 1 * Rev); 456 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 457 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 458 P := TPoint.Create(X - 1, Y + 0); 459 P := TPoint.Create((P.X + Size.X) mod Size.X, (P.Y + Size.Y) mod Size.Y); 460 Neighbors.Add(Cells[P.Y * Size.X + P.X]); 461 end else begin 462 P := TPoint.Create(X + 1, Y + 0); 463 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 464 P := TPoint.Create(X + 0, Y - 1 * Rev); 465 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 466 P := TPoint.Create(X - 1, Y + 0); 467 if IsValidIndex(P) then Neighbors.Add(Cells[P.Y * Size.X + P.X]); 468 end; 448 469 end; 449 470
Note:
See TracChangeset
for help on using the changeset viewer.