@@ -76,6 +76,7 @@ public class Viewer
7676 /// Monotonically increasing time value (in seconds) for the game/viewer. Starts at 0 and only ever increases, at real-time.
7777 /// </summary>
7878 public double RealTime { get ; private set ; }
79+ public double LastSave = - 1 ;
7980 InfoDisplay InfoDisplay ;
8081 public WindowManager WindowManager { get ; private set ; }
8182 public MessagesWindow MessagesWindow { get ; private set ; } // Game message window (special, always visible)
@@ -296,6 +297,8 @@ public Viewer(Simulator simulator, Orts.Viewer3D.Processes.Game game)
296297 Settings = simulator . Settings ;
297298 Use3DCabProperty = Settings . GetSavingProperty < bool > ( "Use3DCab" ) ;
298299
300+ LastSave = 15 * 60 ;
301+
299302 RenderProcess = game . RenderProcess ;
300303 UpdaterProcess = game . UpdaterProcess ;
301304 LoaderProcess = game . LoaderProcess ;
@@ -736,6 +739,14 @@ public void Update(RenderFrame frame, float elapsedRealTime)
736739 RealTime += elapsedRealTime ;
737740 var elapsedTime = new ElapsedTime ( Simulator . GetElapsedClockSeconds ( elapsedRealTime ) , elapsedRealTime ) ;
738741
742+ // auto save
743+ if ( RealTime > LastSave && ! Simulator . Paused )
744+ {
745+ GameStateRunActivity . Save ( ) ;
746+ LastSave = RealTime + 15 * 60 ;
747+ }
748+
749+ // show message
739750 if ( ComposeMessageWindow . Visible == true )
740751 {
741752 UserInput . Handled ( ) ;
@@ -930,7 +941,11 @@ void HandleUserInput(ElapsedTime elapsedTime)
930941 Simulator . GameSpeed = 1 ;
931942 Simulator . Confirmer . ConfirmWithPerCent ( CabControl . SimulationSpeed , CabSetting . Off , Simulator . GameSpeed * 100 ) ;
932943 }
933- if ( UserInput . IsPressed ( UserCommand . GameSave ) ) { GameStateRunActivity . Save ( ) ; }
944+ if ( UserInput . IsPressed ( UserCommand . GameSave ) )
945+ {
946+ GameStateRunActivity . Save ( ) ;
947+ LastSave = RealTime + 60 * 15 ;
948+ }
934949 if ( UserInput . IsPressed ( UserCommand . DisplayHelpWindow ) ) if ( UserInput . IsDown ( UserCommand . DisplayNextWindowTab ) ) HelpWindow . TabAction ( ) ; else HelpWindow . Visible = ! HelpWindow . Visible ;
935950 if ( UserInput . IsPressed ( UserCommand . DisplayTrackMonitorWindow ) ) if ( UserInput . IsDown ( UserCommand . DisplayNextWindowTab ) ) TrackMonitorWindow . TabAction ( ) ; else TrackMonitorWindow . Visible = ! TrackMonitorWindow . Visible ;
936951 if ( UserInput . IsPressed ( UserCommand . DisplayTrainDrivingWindow ) ) if ( UserInput . IsDown ( UserCommand . DisplayNextWindowTab ) ) TrainDrivingWindow . TabAction ( ) ; else TrainDrivingWindow . Visible = ! TrainDrivingWindow . Visible ;
0 commit comments