Ignore:
Timestamp:
Jan 8, 2025, 11:01:27 AM (2 days ago)
Author:
chronos
Message:

Merged revision(s) 403-408 from trunk:

  • Added: Cover image.
  • Fixed: Crash on cyclic map new move creation.
  • Modified: TView class moved into separate unit.
  • Added: French translation.
  • Fixed: Do not stop running game on Quit action.
  • Fixed: Cell cities were not correctly stored the saved game.
  • Fixed: ItemList references were loaded by item index instead of item id.
  • Fixed: Wrong default map image path initialization.
Location:
tags/1.4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/1.4.0

  • tags/1.4.0/Building.pas

    r344 r409  
    3939  public
    4040    Kind: TBuildingKind;
     41    Game: TObject; // TGame
     42    class function GetFields: TItemFields; override;
     43    procedure GetValue(Index: Integer; out Value); override;
     44    procedure SetValue(Index: Integer; var Value); override;
     45    function GetReferenceList(Index: Integer): TBaseItemList; override;
    4146    procedure Assign(Source: TItem); override;
    4247    property MapCell: TObject read FMapCell write SetMapCell; // TMapCell;
     
    4752  TBuildings = class(TItemList<TBuilding>)
    4853    Game: TObject; // TGame;
     54    function CreateItem(Name: string = ''): TBuilding; override;
     55    procedure Assign(Source: TItemList<TBuilding>); override;
    4956  end;
    5057
     
    6471
    6572uses
    66   Map;
     73  Map, Game;
    6774
    6875{ TBuilding }
     
    8087end;
    8188
     89class function TBuilding.GetFields: TItemFields;
     90var
     91  Field: TItemField;
     92begin
     93  Result := inherited;
     94  Field := Result.AddField(2, 'Kind', SBuildingKind, dtReference);
     95end;
     96
     97procedure TBuilding.GetValue(Index: Integer; out Value);
     98begin
     99  if Index = 1 then string(Value) := Name
     100  else if Index = 2 then TBuildingKind(Value) := Kind
     101  else inherited;
     102end;
     103
     104procedure TBuilding.SetValue(Index: Integer; var Value);
     105begin
     106  if Index = 1 then Name := string(Value)
     107  else if Index = 2 then Kind := TBuildingKind(Value)
     108  else inherited;
     109end;
     110
     111function TBuilding.GetReferenceList(Index: Integer): TBaseItemList;
     112begin
     113  if Index = 2 then Result := TGame(Game).GameSystem.BuildingKinds.BaseItemList
     114  else Result := nil;
     115end;
     116
    82117procedure TBuilding.Assign(Source: TItem);
    83118begin
    84119  inherited;
    85120  Kind := TBuilding(Source).Kind;
     121end;
     122
     123{ TBuildings }
     124
     125function TBuildings.CreateItem(Name: string): TBuilding;
     126begin
     127  Result := inherited;
     128  Result.Game := Game;
     129end;
     130
     131procedure TBuildings.Assign(Source: TItemList<TBuilding>);
     132var
     133  I: Integer;
     134begin
     135  inherited;
     136  for I := 0 to Count - 1 do
     137    Items[I].Game := Game;
    86138end;
    87139
Note: See TracChangeset for help on using the changeset viewer.