Changeset 292 for trunk/UGameSystem.pas


Ignore:
Timestamp:
Mar 28, 2019, 5:34:35 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Load game systems from files in Systems subdirectory on application start. Do not initialize game systems statically from code.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGameSystem.pas

    r289 r292  
    77uses
    88  Classes, SysUtils, fgl, UUnit, DOM, XMLRead, XMLWrite, UXMLUtils, XMLConf,
    9   FileUtil, UMapType, UNation, UBuilding;
     9  FileUtil, LazFileUtils, UMapType, UNation, UBuilding;
    1010
    1111type
     
    4242    function AddNew(Name: string): TGameSystem;
    4343    function SearchByName(Name: string): TGameSystem;
     44    procedure LoadFromDir(Dir: string);
    4445  end;
    4546
     
    7374  if I < Count then Result := Items[I]
    7475    else Result := nil;
     76end;
     77
     78procedure TGameSystems.LoadFromDir(Dir: string);
     79var
     80  Files: TStringList;
     81  I: Integer;
     82  NewItem: TGameSystem;
     83begin
     84  Files := TStringList.Create;
     85  FindAllFiles(Files, Dir, '*' + GameSystemExt, True, faAnyFile);
     86  for I := 0 to Files.Count - 1 do begin
     87    NewItem := TGameSystem.Create;
     88    NewItem.LoadFromFile(Files[I]);
     89    Add(NewItem);
     90  end;
     91  Files.Free;
    7592end;
    7693
Note: See TracChangeset for help on using the changeset viewer.