- Timestamp:
- Aug 17, 2014, 2:02:43 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormAbout.lfm
r43 r47 26 26 object Memo1: TMemo 27 27 Left = 8 28 Height = 1 6128 Height = 157 29 29 Top = 8 30 Width = 2 8130 Width = 277 31 31 Anchors = [akTop, akLeft, akRight, akBottom] 32 32 BorderStyle = bsNone -
trunk/Forms/UFormAbout.pas
r43 r47 7 7 uses 8 8 SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 9 Buttons, ExtCtrls , UApplicationInfo;9 Buttons, ExtCtrls; 10 10 11 11 type -
trunk/Forms/UFormNew.lfm
r42 r47 127 127 object CheckBoxVoid: TCheckBox 128 128 Left = 8 129 Height = 2 4129 Height = 27 130 130 Top = 101 131 Width = 1 75131 Width = 198 132 132 Caption = 'Inaccessible places' 133 133 OnChange = CheckBoxVoidChange … … 136 136 object Label1: TLabel 137 137 Left = 8 138 Height = 2 2138 Height = 25 139 139 Top = 9 140 Width = 88140 Width = 104 141 141 Caption = 'Map width:' 142 142 ParentColor = False … … 144 144 object SpinEditMapSizeX: TSpinEdit 145 145 Left = 128 146 Height = 3 2146 Height = 35 147 147 Top = 4 148 148 Width = 98 … … 154 154 object SpinEditMapSizeY: TSpinEdit 155 155 Left = 128 156 Height = 3 2156 Height = 35 157 157 Top = 55 158 158 Width = 98 … … 164 164 object SpinEditVoidPercent: TSpinEdit 165 165 Left = 216 166 Height = 3 2166 Height = 35 167 167 Top = 97 168 168 Width = 106 … … 173 173 object Label3: TLabel 174 174 Left = 331 175 Height = 2 2175 Height = 25 176 176 Top = 102 177 Width = 1 5177 Width = 17 178 178 Caption = '%' 179 179 ParentColor = False … … 181 181 object TrackBarSizeX: TTrackBar 182 182 Left = 240 183 Height = 4 3183 Height = 46 184 184 Top = 1 185 185 Width = 451 … … 194 194 object TrackBarSizeY: TTrackBar 195 195 Left = 240 196 Height = 4 3196 Height = 46 197 197 Top = 49 198 198 Width = 451 … … 207 207 object Label2: TLabel 208 208 Left = 8 209 Height = 2 2209 Height = 25 210 210 Top = 57 211 Width = 94211 Width = 110 212 212 Caption = 'Map height:' 213 213 ParentColor = False … … 215 215 object CheckBoxCity: TCheckBox 216 216 Left = 8 217 Height = 2 4217 Height = 27 218 218 Top = 141 219 Width = 68219 Width = 73 220 220 Caption = 'Cities' 221 221 OnChange = CheckBoxCityChange … … 224 224 object SpinEditCityPercent: TSpinEdit 225 225 Left = 216 226 Height = 3 2226 Height = 35 227 227 Top = 137 228 228 Width = 106 … … 233 233 object Label4: TLabel 234 234 Left = 331 235 Height = 2 2235 Height = 25 236 236 Top = 142 237 Width = 1 5237 Width = 17 238 238 Caption = '%' 239 239 ParentColor = False … … 253 253 ChildSizing.Layout = cclLeftToRightThenTopToBottom 254 254 ChildSizing.ControlsPerLine = 1 255 ClientHeight = 52255 ClientHeight = 49 256 256 ClientWidth = 237 257 257 Items.Strings = ( … … 275 275 ChildSizing.Layout = cclLeftToRightThenTopToBottom 276 276 ChildSizing.ControlsPerLine = 1 277 ClientHeight = 81277 ClientHeight = 78 278 278 ClientWidth = 181 279 279 Items.Strings = ( … … 286 286 object ComboBoxGridType: TComboBox 287 287 Left = 312 288 Height = 3 0288 Height = 37 289 289 Top = 201 290 290 Width = 208 … … 293 293 'Hexagonal' 294 294 'Square' 295 'Triangular' 295 296 ) 296 297 Style = csDropDownList … … 299 300 object Label5: TLabel 300 301 Left = 216 301 Height = 2 2302 Height = 25 302 303 Top = 201 303 Width = 79304 Width = 90 304 305 Caption = 'Grid type:' 305 306 ParentColor = False … … 307 308 object Label6: TLabel 308 309 Left = 8 309 Height = 2 2310 Height = 25 310 311 Top = 313 311 Width = 1 14312 Width = 129 312 313 Caption = 'Win objective:' 313 314 ParentColor = False … … 315 316 object ComboBoxWinObjective: TComboBox 316 317 Left = 160 317 Height = 3 0318 Height = 37 318 319 Top = 305 319 320 Width = 208 … … 330 331 object Label7: TLabel 331 332 Left = 8 332 Height = 2 2333 Height = 25 333 334 Top = 348 334 Width = 2 11335 Width = 245 335 336 Caption = 'Max random neutral units:' 336 337 ParentColor = False … … 338 339 object SpinEditNeutralUnits: TSpinEdit 339 340 Left = 272 340 Height = 3 2341 Height = 35 341 342 Top = 343 342 343 Width = 98 -
trunk/UGame.pas
r42 r47 41 41 MovesFrom: TObjectList; // TList<TMove> 42 42 MovesTo: TObjectList; // TList<TMove> 43 Neighbors: TObjectList; // TList<TCell> 43 44 function GetColor: TColor; 44 45 function GetAvialPower: Integer; … … 98 99 procedure Grow(APlayer: TPlayer); virtual; 99 100 procedure ComputePlayerStats; virtual; 101 procedure Generate; virtual; 100 102 constructor Create; virtual; 101 103 destructor Destroy; override; 102 function GetCellNeighbo urs(Cell: TCell): TCellArray; virtual;104 function GetCellNeighbors(Cell: TCell): TCellArray; virtual; 103 105 procedure Paint(Canvas: TCanvas; View: TView); virtual; 104 106 function GetPixelRect: TRect; virtual; … … 115 117 function GetSize: TPoint; override; 116 118 procedure SetSize(AValue: TPoint); override; 119 function IsCellsNeighbor2(Cell1, Cell2: TCell): Boolean; 120 function GetCellNeighbors2(Cell: TCell): TCellArray; 117 121 public 118 122 Cells: array of array of TCell; 119 function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; override; 120 procedure Assign(Source: TMap); virtual; 123 procedure Assign(Source: TMap); override; 121 124 procedure LoadFromFile(FileName: string); override; 122 125 procedure SaveToFile(FileName: string); override; 123 126 function IsValidIndex(Index: TPoint): Boolean; override; 124 function GetCellNeighbours(Cell: TCell): TCellArray; override;125 127 function PosToCell(Pos: TPoint; View: TView): TCell; override; 126 128 function CellToPos(Cell: TCell): TPoint; override; 127 129 function GetHexagonPolygon(Pos: TPoint; HexSize: TPoint): TPointArray; 128 130 procedure Paint(Canvas: TCanvas; View: TView); override; 131 procedure Generate; override; 129 132 constructor Create; override; 130 133 destructor Destroy; override; … … 140 143 function GetSize: TPoint; override; 141 144 procedure SetSize(AValue: TPoint); override; 145 function IsCellsNeighbor2(Cell1, Cell2: TCell): Boolean; 146 function GetCellNeighbours2(Cell: TCell): TCellArray; 142 147 public 143 148 Cells: array of array of TCell; 144 function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; override;145 149 function IsValidIndex(Index: TPoint): Boolean; override; 146 150 function PosToCell(Pos: TPoint; View: TView): TCell; override; 147 151 function CellToPos(Cell: TCell): TPoint; override; 148 function GetCellNeighbours(Cell: TCell): TCellArray; override;149 152 function GetAllCells: TCellArray; override; 150 153 function GetPixelRect: TRect; override; … … 359 362 end; 360 363 361 function TSquareMap.IsCellsNeighbor (Cell1, Cell2: TCell): Boolean;364 function TSquareMap.IsCellsNeighbor2(Cell1, Cell2: TCell): Boolean; 362 365 var 363 366 DX: Integer; … … 427 430 end; 428 431 429 function TSquareMap.GetCellNeighbours (Cell: TCell): TCellArray;432 function TSquareMap.GetCellNeighbours2(Cell: TCell): TCellArray; 430 433 var 431 434 X, Y: Integer; … … 435 438 for X := -1 to 1 do 436 439 if IsValidIndex(Point(Cell.Pos.X + X, Cell.Pos.Y + Y)) and 437 IsCellsNeighbor (Cell, Cells[Cell.Pos.Y + Y, Cell.Pos.X + X]) then begin440 IsCellsNeighbor2(Cell, Cells[Cell.Pos.Y + Y, Cell.Pos.X + X]) then begin 438 441 SetLength(Result, Length(Result) + 1); 439 442 Result[Length(Result) - 1] := Cells[Cell.Pos.Y + Y, Cell.Pos.X + X]; … … 608 611 function TMap.IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; 609 612 begin 610 Result := False;613 Result := Cell1.Neighbors.IndexOf(Cell2) <> -1; 611 614 end; 612 615 … … 683 686 end; 684 687 688 procedure TMap.Generate; 689 begin 690 end; 691 685 692 constructor TMap.Create; 686 693 begin … … 695 702 end; 696 703 697 function TMap.GetCellNeighbours(Cell: TCell): TCellArray; 698 begin 699 704 function TMap.GetCellNeighbors(Cell: TCell): TCellArray; 705 var 706 I: Integer; 707 begin 708 SetLength(Result, Cell.Neighbors.Count); 709 for I := 0 to Length(Result) - 1 do 710 Result[I] := TCell(Cell.Neighbors[I]); 700 711 end; 701 712 … … 729 740 function TMap.GetAllCells: TCellArray; 730 741 begin 731 742 SetLength(Result, 0); 732 743 end; 733 744 … … 861 872 begin 862 873 Player := nil; 874 Neighbors := TObjectList.Create; 875 Neighbors.OwnsObjects := False; 863 876 MovesFrom := TObjectList.Create; 864 877 MovesFrom.OwnsObjects := False; … … 877 890 TUnitMove(MovesTo[I]).Free; 878 891 FreeAndNil(MovesTo); 892 FreeAndNil(Neighbors); 879 893 inherited Destroy; 880 894 end; … … 940 954 // Attack to not owned cell yet 941 955 // Count own possible power 942 Cells := Game.Map.GetCellNeighbo urs(AllCells[C]);956 Cells := Game.Map.GetCellNeighbors(AllCells[C]); 943 957 TotalPower := 0; 944 958 for I := 0 to Length(Cells) - 1 do … … 964 978 // We need to move available power to borders to be available for attacks 965 979 // or defense 966 Cells := Game.Map.GetCellNeighbo urs(AllCells[C]);980 Cells := Game.Map.GetCellNeighbors(AllCells[C]); 967 981 CanAttack := 0; 968 982 for I := 0 to Length(Cells) - 1 do … … 1125 1139 mtHexagon: Map := THexMap.Create; 1126 1140 mtSquare: Map := TSquareMap.Create; 1141 else Map := TMap.Create; 1127 1142 end; 1128 1143 Map.Assign(OldMap); … … 1141 1156 begin 1142 1157 I := 0; 1158 Confirm := True; 1143 1159 while (I < Moves.Count) and ((TUnitMove(Moves[I]).CellFrom <> CellFrom) or 1144 1160 (TUnitMove(Moves[I]).CellTo <> CellTo)) do Inc(I); … … 1225 1241 1226 1242 procedure TGame.LoadConfig(Config: TXmlConfig; Path: string); 1243 var 1244 P: TPoint; 1227 1245 begin 1228 1246 with Config do begin … … 1439 1457 1440 1458 procedure THexMap.SetSize(AValue: TPoint); 1441 var1442 X, Y: Integer;1443 NewCell: TCell;1444 C: Integer;1445 1459 begin 1446 1460 if (FSize.X <> AValue.X) or (FSize.Y <> AValue.Y) then begin 1447 // Free previous1448 for Y := 0 to FSize.Y - 1 do1449 for X := 0 to FSize.X - 1 do begin1450 TCell(Cells[Y, X]).Destroy;1451 end;1452 1461 FSize := AValue; 1453 // Allocate and init new 1454 SetLength(Cells, FSize.Y, FSize.X); 1455 for Y := 0 to FSize.Y - 1 do 1456 for X := 0 to FSize.X - 1 do begin 1457 NewCell := TCell.Create; 1458 NewCell.Pos := Point(X, Y); 1459 Cells[Y, X] := NewCell; 1460 end; 1461 end; 1462 end; 1463 1464 function THexMap.IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; 1462 Generate; 1463 end; 1464 end; 1465 1466 function THexMap.IsCellsNeighbor2(Cell1, Cell2: TCell): Boolean; 1465 1467 var 1466 1468 DX: Integer; … … 1484 1486 procedure THexMap.Assign(Source: TMap); 1485 1487 begin 1488 inherited; 1486 1489 end; 1487 1490 … … 1522 1525 end; 1523 1526 1524 function THexMap.GetCellNeighbo urs(Cell: TCell): TCellArray;1527 function THexMap.GetCellNeighbors2(Cell: TCell): TCellArray; 1525 1528 var 1526 1529 X, Y: Integer; … … 1530 1533 for X := -1 to 1 do 1531 1534 if IsValidIndex(Point(Cell.Pos.X + X, Cell.Pos.Y + Y)) and 1532 IsCellsNeighbor (Cell, Cells[Cell.Pos.Y + Y, Cell.Pos.X + X]) then begin1535 IsCellsNeighbor2(Cell, Cells[Cell.Pos.Y + Y, Cell.Pos.X + X]) then begin 1533 1536 SetLength(Result, Length(Result) + 1); 1534 1537 Result[Length(Result) - 1] := Cells[Cell.Pos.Y + Y, Cell.Pos.X + X]; … … 1686 1689 end; 1687 1690 1691 procedure THexMap.Generate; 1692 var 1693 X, Y: Integer; 1694 I: Integer; 1695 NewCell: TCell; 1696 NeighCells: TCellArray; 1697 begin 1698 // Free previous 1699 for Y := 0 to Length(Cells) - 1 do 1700 for X := 0 to Length(Cells[Y]) - 1 do begin 1701 TCell(Cells[Y, X]).Destroy; 1702 end; 1703 // Allocate and init new 1704 SetLength(Cells, FSize.Y, FSize.X); 1705 for Y := 0 to FSize.Y - 1 do 1706 for X := 0 to FSize.X - 1 do begin 1707 NewCell := TCell.Create; 1708 NewCell.Pos := Point(X, Y); 1709 Cells[Y, X] := NewCell; 1710 end; 1711 // Generate neightbours 1712 for Y := 0 to FSize.Y - 1 do 1713 for X := 0 to FSize.X - 1 do begin 1714 NeighCells := GetCellNeighbors2(Cells[Y, X]); 1715 for I := 0 to Length(NeighCells) - 1 do 1716 Cells[Y, X].Neighbors.Add(NeighCells[I]); 1717 end; 1718 end; 1719 1688 1720 constructor THexMap.Create; 1689 1721 begin -
trunk/xtactics.lpi
r46 r47 163 163 <SyntaxOptions> 164 164 <SyntaxMode Value="Delphi"/> 165 <CStyleOperator Value="False"/> 165 166 <IncludeAssertionCode Value="True"/> 167 <AllowLabel Value="False"/> 168 <CPPInline Value="False"/> 166 169 </SyntaxOptions> 167 170 </Parsing> … … 173 176 <StackChecks Value="True"/> 174 177 </Checks> 178 <VerifyObjMethodCallValidity Value="True"/> 175 179 </CodeGeneration> 176 180 <Linking>
Note:
See TracChangeset
for help on using the changeset viewer.