Changeset 133


Ignore:
Timestamp:
May 2, 2023, 10:29:11 AM (19 months ago)
Author:
chronos
Message:
  • Added: Last game is automatically saved on exit.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r129 r133  
    119119procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    120120begin
    121   //Engine.SaveToFile('Game.bmg');
    122121  Core.PersistentForm1.Save(Self);
    123122end;
  • trunk/Languages/TransLines.cs.po

    r130 r133  
    6868msgstr "Automaticky"
    6969
     70#: uengine.sautosave
     71msgid "Auto save"
     72msgstr "Automaticky uložené"
     73
    7074#: uengine.sback
    7175msgctxt "uengine.sback"
  • trunk/Languages/TransLines.de.po

    r130 r133  
    7070msgstr "Automatisch"
    7171
     72#: uengine.sautosave
     73msgid "Auto save"
     74msgstr ""
     75
    7276#: uengine.sback
    7377msgctxt "uengine.sback"
  • trunk/Languages/TransLines.fr.po

    r130 r133  
    7171msgstr "Automatique"
    7272
     73#: uengine.sautosave
     74msgid "Auto save"
     75msgstr ""
     76
    7377#: uengine.sback
    7478msgctxt "uengine.sback"
  • trunk/Languages/TransLines.pot

    r130 r133  
    5858msgstr ""
    5959
     60#: uengine.sautosave
     61msgid "Auto save"
     62msgstr ""
     63
    6064#: uengine.sback
    6165msgctxt "uengine.sback"
  • trunk/UEngine.pas

    r132 r133  
    311311    procedure ReloadGameSlots(Save: Boolean);
    312312    function GetGameSlotFileName(Index: Integer): string;
     313    procedure AutoSave;
    313314  public
    314315    // Test
     
    473474  SStationStyle = 'Station style';
    474475  SSlot = 'Slot';
     476  SAutoSave = 'Auto save';
    475477
    476478  // Cities
     
    22962298procedure TEngine.MenuItemGameExit(Sender: TObject);
    22972299begin
     2300  AutoSave;
    22982301  State := gsMenu;
    22992302  Clear;
     
    23222325begin
    23232326  LoadFromFile(GetGameSlotFileName(Integer(TMenuItemButton(Sender).Ref)));
    2324   State := gsRunning;
     2327  if State in [gsMenu] then State := gsRunning;
     2328  Redraw;
    23252329end;
    23262330
     
    24702474  ControlName: string;
    24712475const
    2472   GameSlotCount = 6;
     2476  GameSlotCount = 5;
    24732477begin
    24742478  with MenuGameSlots, Items do begin
     
    24772481    if Save then Action := MenuItemGameSlotSave
    24782482      else Action := MenuItemGameSlotLoad;
    2479     for I := 1 to GameSlotCount do begin
     2483    for I := 0 to GameSlotCount do begin
    24802484      FileName := GetGameSlotFileName(Integer(I));
    2481       ControlName := SSlot + ' ' + IntToStr(I);
     2485      if I = 0 then ControlName := SAutoSave
     2486        else ControlName := SSlot + ' ' + IntToStr(I);
    24822487      if FileExists(FileName) then begin
    24832488        FileAge(FileName, FileDateTime);
     
    24862491      with AddButton(ControlName, Action) do begin
    24872492        Ref := TObject(I);
    2488         Enabled := FileExists(FileName) or Save;
     2493        Enabled := FileExists(FileName) or (Save and (I > 0));
    24892494        TextSize := 40;
    24902495        TextColor := Colors.MenuItemText;
     
    25082513begin
    25092514  Result := GetAppConfigDir(False) + 'Saved game ' + IntToStr(Index) + TransLinesExt;
     2515end;
     2516
     2517procedure TEngine.AutoSave;
     2518begin
     2519  if (State = gsNotStarted) or ((State = gsMenu) and (LastState = gsNotStarted)) then Exit;
     2520  SaveToFile(GetGameSlotFileName(0));
    25102521end;
    25112522
     
    41124123  WriteInteger(Node, 'ServedPassengerCount', ServedPassengerCount);
    41134124  WriteInteger(Node, 'DestinationCount', DestinationCount);
    4114   WriteInteger(Node, 'State', Integer(State));
     4125  if State = gsMenu then WriteInteger(Node, 'State', Integer(LastState))
     4126    else WriteInteger(Node, 'State', Integer(State));
    41154127  WriteDateTime(Node, 'Time', FTime);
    41164128  if Assigned(City) then WriteString(Node, 'CityName', City.SysName);
     
    42534265destructor TEngine.Destroy;
    42544266begin
     4267  AutoSave;
    42554268  FreeAndNil(MetaCanvas);
    42564269  FreeAndNil(Trains);
Note: See TracChangeset for help on using the changeset viewer.