mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-04 05:11:50 +01:00
Read the last run's log before a start has to
A start notes down which vehicles the player drove in the run before, as the log begins anew. With the tape window never opened nothing of a long run's log had been read yet, and Start waited on the whole of it. It is now read off the UI thread when the simulator exits and when the starter opens.
This commit is contained in:
@@ -113,6 +113,17 @@ public sealed class HaslerTapes
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public void FollowLastRun()
|
||||
{
|
||||
if (Launches().LastOrDefault() is { } launch)
|
||||
PlayerIn(launch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
private static void FollowLastRun()
|
||||
{
|
||||
if (AppServices.Current.Settings.PhysicsLog)
|
||||
_ = Task.Run(AppServices.Current.Tapes.FollowLastRun);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
|
||||
Reference in New Issue
Block a user