Changeset 77 for trunk/UCore.pas


Ignore:
Timestamp:
Oct 5, 2014, 7:13:38 PM (10 years ago)
Author:
chronos
Message:
  • Added: Auto save game to file option in settings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r76 r77  
    4949    procedure DoOnWin(Player: TPlayer);
    5050    procedure Delay(Time: Integer);
     51    procedure GameNewTurnExecute(Sender: TObject);
     52    procedure AutoSave;
    5153  public
    5254    Game: TGame;
     
    5557    LastMapFileName: string;
    5658    AnimationSpeed: Integer;
     59    AutoSaveEnabled: Boolean;
    5760    procedure UpdateActions;
    5861    procedure Init;
     
    129132end;
    130133
     134procedure TCore.GameNewTurnExecute(Sender: TObject);
     135begin
     136  if AutoSaveEnabled then AutoSave;
     137end;
     138
     139procedure TCore.AutoSave;
     140begin
     141  Game.SaveToFile(GetAppConfigDir(False) + 'AutoSave.xtg');
     142  GetUserDir;
     143end;
     144
    131145procedure TCore.UpdateActions;
    132146begin
     
    249263  Game.OnMove := DoOnMove;
    250264  Game.OnWin := DoOnWin;
     265  Game.OnNewTurn := GameNewTurnExecute;
    251266end;
    252267
     
    258273  XMLConfig1.SetValue('DevelMode', DevelMode);
    259274  XMLConfig1.SetValue('AnimationSpeed', AnimationSpeed);
     275  XMLConfig1.SetValue('AutoSave', AutoSaveEnabled);
    260276  FreeAndNil(Game);
    261277end;
     
    269285  DevelMode := XMLConfig1.GetValue('DevelMode', false);
    270286  AnimationSpeed := XMLConfig1.GetValue('AnimationSpeed', 50);
     287  AutoSaveEnabled := XMLConfig1.GetValue('AutoSave', True);
    271288  CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(XMLConfig1.GetValue('Language', ''));
    272289  for I := 0 to Game.Players.Count - 1 do
Note: See TracChangeset for help on using the changeset viewer.