Changeset 346
- Timestamp:
- Dec 25, 2024, 11:04:56 AM (16 hours ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/FormItem.pas
r344 r346 80 80 J: Integer; 81 81 Control: TControl; 82 ReferenceList: TItemList<TItem>;82 ReferenceList: IList<TItem>; 83 83 ReferenceItem: TItem; 84 84 begin … … 106 106 try 107 107 TComboBox(Control).Items.Clear; 108 ReferenceList := TItemList<TItem>(Item.GetReferenceList(Index));108 ReferenceList := Item.GetReferenceList(Index); 109 109 if Assigned(ReferenceList) then 110 110 for J := 0 to ReferenceList.Count - 1 do -
trunk/Forms/FormList.lfm
r320 r346 1 1 object FormList: TFormList 2 2 Left = 1040 3 Height = 3 603 Height = 312 4 4 Top = 540 5 Width = 4 805 Width = 417 6 6 Caption = 'List' 7 ClientHeight = 3 608 ClientWidth = 4 809 DesignTimePPI = 1 447 ClientHeight = 312 8 ClientWidth = 417 9 DesignTimePPI = 125 10 10 OnCreate = FormCreate 11 OnDestroy = FormDestroy 11 12 OnShow = FormShow 12 LCLVersion = '3. 4.0.0'13 LCLVersion = '3.6.0.0' 13 14 object ListView1: TListView 14 15 Left = 0 15 Height = 32216 Height = 279 16 17 Top = 0 17 Width = 4 8018 Width = 417 18 19 Align = alClient 19 20 Columns = < 20 21 item 21 22 Caption = 'Name' 22 Width = 4 6623 Width = 405 23 24 end> 24 25 MultiSelect = True … … 39 40 object ToolBar1: TToolBar 40 41 Left = 0 41 Height = 3 842 Top = 32243 Width = 4 8042 Height = 33 43 Top = 279 44 Width = 417 44 45 Align = alBottom 45 46 Images = Core.ImageListSmall … … 54 55 end 55 56 object ToolButton2: TToolButton 56 Left = 3 657 Left = 31 57 58 Top = 2 58 59 Action = AModify 59 60 end 60 61 object ToolButton3: TToolButton 61 Left = 7162 Left = 61 62 63 Top = 2 63 64 Action = ARemove 64 65 end 65 66 object ToolButton4: TToolButton 66 Left = 10667 Left = 91 67 68 Top = 2 68 69 Action = AClone … … 71 72 object ActionList1: TActionList 72 73 Images = Core.ImageListSmall 73 Left = 20874 Top = 1 6374 Left = 181 75 Top = 141 75 76 object AAdd: TAction 76 77 Caption = 'Add' … … 101 102 object PopupMenu1: TPopupMenu 102 103 Images = Core.ImageListSmall 103 Left = 3 52104 Top = 1 60104 Left = 306 105 Top = 139 105 106 object MenuItem1: TMenuItem 106 107 Action = AAdd -
trunk/Forms/FormList.pas
r344 r346 35 35 procedure ASelectAllExecute(Sender: TObject); 36 36 procedure FormCreate(Sender: TObject); 37 procedure FormDestroy(Sender: TObject); 37 38 procedure FormShow(Sender: TObject); 38 39 procedure ListView1CustomDrawSubItem(Sender: TCustomListView; … … 182 183 end; 183 184 185 procedure TFormList.FormDestroy(Sender: TObject); 186 begin 187 List := nil; 188 end; 189 184 190 procedure TFormList.FormShow(Sender: TObject); 185 191 begin … … 254 260 if FList = AValue then Exit; 255 261 FList := AValue; 262 UpdateInterface; 263 UpdateList; 256 264 end; 257 265 -
trunk/ItemList.pas
r345 r346 184 184 while Count < Source.Count do AddItem(''); 185 185 for I := 0 to Count - 1 do 186 TItem(Items[I]).Assign(Source.Items[I]);186 Items[I].Assign(Source.Items[I]); 187 187 end; 188 188 … … 201 201 function TItemList<T>.AddItem(Name: string): T; 202 202 begin 203 Result := T.Create; 204 Result.Name := Name; 203 Result := CreateItem(Name); 205 204 Result.Id := GetNewId; 206 205 Add(Result); … … 253 252 end; 254 253 255 function TItemList<T>.QueryInterface( constrefiid: tguid; out obj): LongInt;256 stdcall;254 function TItemList<T>.QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF} iid: tguid; out obj): LongInt; 255 {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF}; 257 256 begin 258 257 Result := 0; 259 258 end; 260 259 261 function TItemList<T>._AddRef: LongInt; stdcall;260 function TItemList<T>._AddRef: LongInt; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF}; 262 261 begin 263 262 Result := 0; 264 263 end; 265 264 266 function TItemList<T>._Release: LongInt; stdcall;265 function TItemList<T>._Release: LongInt; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF}; 267 266 begin 268 267 Result := 0; -
trunk/Player.pas
r344 r346 137 137 public 138 138 Game: TObject; //TGame; 139 procedure Assign(Source: TItemList<TPlayer>); override; 139 140 procedure New(Name: string; Color: TColor; Mode: TPlayerMode); 140 141 function CreateItem(Name: string = ''): TPlayer; override; … … 160 161 CountOnce: Integer; 161 162 CountRepeat: Integer; 163 procedure Assign(Source: TUnitMove); 162 164 procedure LoadFromNode(Node: TDOMNode); 163 165 procedure SaveToNode(Node: TDOMNode); … … 173 175 Game: TObject; //TGame; 174 176 Player: TPlayer; 177 procedure Assign(Source: TUnitMoves); 175 178 function SearchByFromTo(CellFrom, CellTo: TPlayerCell): TUnitMove; 176 179 procedure LoadFromNode(Node: TDOMNode); … … 416 419 begin 417 420 for I := 0 to Cells.Count - 1 do 418 with TPlayerCell(Cells[I])do begin421 with Cells[I] do begin 419 422 for J := Neighbors.Count - 1 downto 0 do 420 423 DisconnectFrom(Neighbors[J]); … … 440 443 with TPlayerCell(Cells[I]) do begin 441 444 for J := 0 to MapCell.Neighbors.Count - 1 do 442 ConnectTo(TPlayerCell( TCell(MapCell.Neighbors[J]).PlayerCell));445 ConnectTo(TPlayerCell(MapCell.Neighbors[J].PlayerCell)); 443 446 end; 444 447 end; … … 499 502 end; 500 503 504 procedure TPlayers.Assign(Source: TItemList<TPlayer>); 505 var 506 I: Integer; 507 begin 508 inherited; 509 for I := 0 to Count - 1 do 510 Items[I].Game := Game; 511 end; 512 501 513 procedure TPlayers.New(Name: string; Color: TColor; Mode: TPlayerMode); 502 begin 503 AddItem(Name); 504 Last.Color := Color; 505 Last.Mode := Mode; 514 var 515 NewPlayer: TPlayer; 516 begin 517 NewPlayer := AddItem(Name); 518 NewPlayer.Color := Color; 519 NewPlayer.Mode := Mode; 506 520 if Mode = pmComputer then 507 Last.Agressivity := caMedium;521 NewPlayer.Agressivity := caMedium; 508 522 end; 509 523 … … 583 597 { TUnitMoves } 584 598 599 procedure TUnitMoves.Assign(Source: TUnitMoves); 600 var 601 I: Integer; 602 begin 603 while Count > Source.Count do 604 Delete(Count - 1); 605 while Count < Source.Count do 606 Add(TUnitMove.Create); 607 for I := 0 to Count - 1 do begin 608 Items[I].Assign(Source.Items[I]); 609 end; 610 end; 611 585 612 function TUnitMoves.SearchByFromTo(CellFrom, CellTo: TPlayerCell): TUnitMove; 586 613 var … … 663 690 else raise Exception.Create('Unit move already exists'); 664 691 end else 692 end; 693 694 procedure TUnitMove.Assign(Source: TUnitMove); 695 begin 696 CountOnce := Source.CountOnce; 697 CountRepeat := Source.CountRepeat; 698 CellFrom.MapCell.Id := Source.CellFrom.MapCell.Id; 699 CellTo.MapCell.Id := Source.CellTo.MapCell.Id; 665 700 end; 666 701 … … 801 836 begin 802 837 inherited; 803 //Game := TPlayer(Source).Game;804 838 TotalCells := TPlayer(Source).TotalCells; 805 839 TotalUnits := TPlayer(Source).TotalUnits; … … 809 843 StartCell := TPlayer(Source).StartCell; 810 844 Color := TPlayer(Source).Color; 811 //Units.Assign(TPlayer(Source).Units); 845 Units.Assign(TPlayer(Source).Units); 846 Moves.Assign(TPlayer(Source).Moves); 812 847 Nation := TPlayer(Source).Nation; 813 848 end; -
trunk/ServerList.pas
r317 r346 23 23 end; 24 24 25 { TServerInfos } 26 25 27 TServerInfos = class(TObjectList<TServerInfo>) 28 procedure Assign(Source: TServerInfos); 26 29 end; 27 30 … … 64 67 end; 65 68 69 { TServerInfos } 70 71 procedure TServerInfos.Assign(Source: TServerInfos); 72 var 73 I: Integer; 74 begin 75 while Count > Source.Count do 76 Delete(Count - 1); 77 while Count < Source.Count do 78 Add(TServerInfo.Create); 79 for I := 0 to Count - 1 do begin 80 Items[I].Assign(Source.Items[I]); 81 end; 82 end; 83 66 84 { TServerList } 67 85 68 86 procedure TServerList.Assign(Source: TServerList); 69 var70 I: Integer;71 87 begin 72 while Items.Count > Source.Items.Count do 73 Items.Delete(Items.Count - 1); 74 while Items.Count < Source.Items.Count do 75 Items.Add(TServerInfo.Create); 76 for I := 0 to Items.Count - 1 do begin 77 Items[I].Assign(Source.Items[I]); 78 end; 88 Name := Source.Name; 89 Address := Source.Address; 90 Items.Assign(Source.Items); 79 91 end; 80 92 -
trunk/Units.pas
r344 r346 138 138 for I := 0 to Count - 1 do begin 139 139 Items[I].Assign(Source[I]); 140 Items[I].Game := Game; 140 141 end; 141 142 NewId := Source.NewId;
Note:
See TracChangeset
for help on using the changeset viewer.