2014-06-30 14:37:42 +00:00
|
|
|
unit Game.List;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
System.Generics.Collections,
|
|
|
|
|
|
|
|
Game.Base;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TGameList = class(TList<TCustomGame>)
|
|
|
|
private
|
|
|
|
class var SInstance: TGameList;
|
|
|
|
protected
|
|
|
|
class procedure Finalize;
|
|
|
|
public
|
|
|
|
class function Instance: TGameList;
|
2014-06-30 16:07:40 +00:00
|
|
|
|
|
|
|
procedure AutoDetect;
|
2014-06-30 14:37:42 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
2014-06-30 16:07:40 +00:00
|
|
|
System.SysUtils,
|
|
|
|
|
|
|
|
Game.Registry;
|
2014-06-30 14:37:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
{ TGameList }
|
|
|
|
class procedure TGameList.Finalize;
|
|
|
|
begin
|
|
|
|
FreeAndNil(SInstance);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
class function TGameList.Instance: TGameList;
|
|
|
|
begin
|
|
|
|
if not Assigned(SInstance) then
|
|
|
|
SInstance := TGameList.Create;
|
|
|
|
|
|
|
|
Result := SInstance;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-06-30 16:07:40 +00:00
|
|
|
procedure TGameList.AutoDetect;
|
|
|
|
var
|
|
|
|
gameClass: TCustomGameClass;
|
|
|
|
game: TCustomGame;
|
|
|
|
|
|
|
|
begin
|
|
|
|
for gameClass in TGameRegistry.RegisteredGames do
|
|
|
|
begin
|
|
|
|
game := gameClass.AutoDetect;
|
|
|
|
if Assigned(game) then
|
|
|
|
Add(game);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-06-30 14:37:42 +00:00
|
|
|
initialization
|
|
|
|
finalization
|
|
|
|
TGameList.Finalize;
|
|
|
|
|
|
|
|
end.
|