Changeset 196 for trunk/UCore.pas


Ignore:
Timestamp:
May 16, 2018, 9:56:24 AM (6 years ago)
Author:
chronos
Message:
  • Added: Allow to manage list of servers where to connect as client.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r195 r196  
    99  UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator,
    1010  URegistry, ULastOpenedList, Registry, Menus, UGeometry, UFormClient,
    11   UGameServer, UGameClient, fgl;
     11  UGameServer, UGameClient, fgl, UServerList;
    1212
    1313type
     
    9191    FormClients: TFPGObjectList<TFormClient>;
    9292    Clients: TClients;
     93    ServerList: TServerList;
    9394    procedure Spectate(Player: TPlayer);
    9495    procedure UpdateActions;
    9596    procedure Init;
     97    procedure Done;
    9698    property Initialized: Boolean read FInitialized;
    9799  end;
     
    295297  try
    296298    FormNew.Load(Server);
     299    FormNew.ServerList := ServerList;
    297300    if FormNew.ShowModal = mrOk then begin
    298301      FormNew.Save(Server);
     
    392395  ForceDirectories(GetAppConfigDir(False));
    393396  FormClients := TFPGObjectList<TFormClient>.Create;
     397  ServerList := TServerList.Create;
    394398end;
    395399
    396400procedure TCore.DataModuleDestroy(Sender: TObject);
    397401begin
     402  FreeAndNil(ServerList);
    398403  if Assigned(FormPlayersStats) then FreeAndNil(FormPlayersStats);
    399404  if Assigned(FormUnitMoves) then FreeAndNil(FormUnitMoves);
     
    401406  FreeAndNil(FormClients);
    402407  FreeAndNil(StoredDimension);
    403   Game.SaveConfig(XMLConfig1, 'Game');
    404   Server.SaveConfig(XMLConfig1, 'Server');
    405   SaveConfig;
    406408  FreeAndNil(Server);
    407409  FreeAndNil(Game);
     
    546548    Game.LoadConfig(XMLConfig1, 'Game');
    547549    Server.LoadConfig(XMLConfig1, 'Server');
     550    ServerList.LoadConfig(XmlConfig1, 'ServerList');
    548551
    549552    CommandLineParams;
     
    556559end;
    557560
     561procedure TCore.Done;
     562begin
     563  Game.SaveConfig(XMLConfig1, 'Game');
     564  Server.SaveConfig(XMLConfig1, 'Server');
     565  ServerList.SaveConfig(XmlConfig1, 'ServerList');
     566  SaveConfig;
     567  XMLConfig1.Flush;
     568end;
     569
    558570end.
    559571
Note: See TracChangeset for help on using the changeset viewer.