Changeset 195 for trunk/UCore.pas


Ignore:
Timestamp:
May 15, 2018, 4:30:54 PM (6 years ago)
Author:
chronos
Message:
  • Added: Settings option to automatically reopen last saved game on application start.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r193 r195  
    6363    StoredDimension: TControlDimension;
    6464    RegistryContext: TRegistryContext;
     65    GameLoaded: Boolean;
    6566    procedure LoadRecentExecute(Sender: TObject);
    6667    procedure ProcessComputerTurns;
     
    8788    AnimationSpeed: Integer;
    8889    AutoSaveEnabled: Boolean;
     90    ReopenLastFile: Boolean;
    8991    FormClients: TFPGObjectList<TFormClient>;
    9092    Clients: TClients;
     
    163165  AnimationSpeed := XMLConfig1.GetValue('AnimationSpeed', 50);
    164166  AutoSaveEnabled := XMLConfig1.GetValue('AutoSave', True);
     167  ReopenLastFile := XMLConfig1.GetValue('ReopenLastFile', True);
    165168  CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(String(XMLConfig1.GetValue('Language', '')));
    166169  ScaleDPI1.DPI := Point(XMLConfig1.GetValue('DPIX', 96), XMLConfig1.GetValue('DPIY', 96));
     
    175178  XMLConfig1.SetValue('AnimationSpeed', AnimationSpeed);
    176179  XMLConfig1.SetValue('AutoSave', AutoSaveEnabled);
     180  XMLConfig1.SetValue('ReopenLastFile', ReopenLastFile);
    177181  XMLConfig1.SetValue('DPIX', ScaleDPI1.DPI.X);
    178182  XMLConfig1.SetValue('DPIY', ScaleDPI1.DPI.Y);
     
    186190  // Command line parameter handling
    187191  if (ParamCount > 0) then begin
    188     FileName := UTF8Encode(ParamStr(1));
     192    FileName := ParamStr(1);
    189193    if FileExists(FileName) then LoadGame(FileName);
    190194  end;
     
    294298      FormNew.Save(Server);
    295299      StartNewGame;
     300      GameLoaded := False;
    296301    end;
    297302  finally
     
    419424  NewClient: TClient;
    420425begin
     426  GameLoaded := True;
     427
    421428  Game.LoadFromFile(FileName);
    422429  Server.InitClients;
     
    541548
    542549    CommandLineParams;
     550    if not GameLoaded and ReopenLastFile and (LastOpenedList1.Items.Count > 0) then
     551      LoadGame(LastOpenedList1.Items[0]);
    543552    ScaleDPI;
    544553
Note: See TracChangeset for help on using the changeset viewer.