diff --git a/StarterNG/Application/HaslerTapes.cs b/StarterNG/Application/HaslerTapes.cs index df067c0..3d0b464 100644 --- a/StarterNG/Application/HaslerTapes.cs +++ b/StarterNG/Application/HaslerTapes.cs @@ -113,6 +113,17 @@ public sealed class HaslerTapes } } + /// + /// Reads what the log of the last launch has gained since the last look. A start + /// notes that down before the log begins anew, and after a long run, with nothing + /// read of it yet, it would wait on the whole log. + /// + public void FollowLastRun() + { + if (Launches().LastOrDefault() is { } launch) + PlayerIn(launch); + } + /// /// The launches noted so far, oldest first. Read again only when the file has /// changed: this runs every few seconds next to a running simulator. diff --git a/StarterNG/MainWindow.axaml.cs b/StarterNG/MainWindow.axaml.cs index 8d71cd0..1956dd0 100644 --- a/StarterNG/MainWindow.axaml.cs +++ b/StarterNG/MainWindow.axaml.cs @@ -103,6 +103,7 @@ public partial class MainWindow : Window _openedUtc = DateTime.UtcNow; UpdateStartButton(); _sceneryFilesTimer.Start(); + FollowLastRun(); }; Activated += (_, _) => CheckExternalSettings(); _sceneryFilesTimer.Tick += async (_, _) => await LookAtSceneryFilesAsync(); @@ -693,11 +694,22 @@ public partial class MainWindow : Window _ = simulator.WaitForExitAsync().ContinueWith(_ => Dispatcher.UIThread.Post(() => { AppServices.Current.State.SimulatorRunning = false; + FollowLastRun(); RestoreFromSimulator(); ReportIfCrashed(simulator, executable, started); }), TaskScheduler.Default); } + /// + /// The player's vehicles in the last run, read from its log off the UI thread + /// while nobody waits: the next start has to have them before the log begins anew. + /// + private static void FollowLastRun() + { + if (AppServices.Current.Settings.PhysicsLog) + _ = Task.Run(AppServices.Current.Tapes.FollowLastRun); + } + /// /// Says why the simulator is gone when it did not end the way a session does: /// an error code, or a close so soon after the start that nobody played - a