diff --git a/Eu07.BlackBox.Views/BlackBoxStrings.cs b/Eu07.BlackBox.Views/BlackBoxStrings.cs
index 645599d..dd94933 100644
--- a/Eu07.BlackBox.Views/BlackBoxStrings.cs
+++ b/Eu07.BlackBox.Views/BlackBoxStrings.cs
@@ -26,7 +26,7 @@ public sealed class DefaultBlackBoxStrings : IBlackBoxStrings
["Pause"] = "Pause",
["Follow"] = "Follow the train",
["Fit"] = "Whole map",
- ["NoFile"] = "Open a black box: physicslog/*.blackbox, written with the physics logs on.",
+ ["NoFile"] = "Open a black box: physicslog/*.blackbox, written with the black box or the physics logs on.",
["Unreadable"] = "Can't read {0}: {1}",
["Reading"] = "Reading {0}…",
["Summary"] = "{0} · {1:0.0} km · max {2:0} km/h · driven {3} · autopilot {4} · over the AI {5} ({6} by more than {7:0} km/h, at most +{8:0} km/h) · signals {9} · at danger {10} · commands {11}",
@@ -297,7 +297,7 @@ public sealed class DefaultBlackBoxStrings : IBlackBoxStrings
["Pause"] = "Pauza",
["Follow"] = "Śledź pociąg",
["Fit"] = "Cała mapa",
- ["NoFile"] = "Otwórz czarną skrzynkę: physicslog/*.blackbox, zapisywaną razem z logami fizyki.",
+ ["NoFile"] = "Otwórz czarną skrzynkę: physicslog/*.blackbox, zapisywaną przy włączonej czarnej skrzynce albo logach fizyki.",
["Unreadable"] = "Nie można odczytać {0}: {1}",
["Reading"] = "Czytanie {0}…",
["Summary"] = "{0} · {1:0.0} km · maks. {2:0} km/h · jazda {3} · autopilot {4} · ponad AI {5} (w tym {6} o więcej niż {7:0} km/h, najwyżej +{8:0} km/h) · sygnalizatory {9} · minięte na „Stój” {10} · komendy {11}",
diff --git a/StarterNG.Tests/SettingsStoreTests.cs b/StarterNG.Tests/SettingsStoreTests.cs
index 66ce35c..1abd865 100644
--- a/StarterNG.Tests/SettingsStoreTests.cs
+++ b/StarterNG.Tests/SettingsStoreTests.cs
@@ -1302,4 +1302,86 @@ public class SettingsStoreTests
Assert.False(store.LoadFailed);
Assert.Equal(60, store.Settings.FieldOfView);
}
+
+ [Theory]
+ [InlineData("physicslog yes\n", true)]
+ [InlineData("physicslog no\n", false)]
+ [InlineData("physicslog yes\nblackbox no\n", false)]
+ [InlineData("physicslog no\nblackbox yes\n", true)]
+ public void The_black_box_goes_with_the_physics_log_unless_the_ini_says_otherwise(string ini, bool recorded)
+ {
+ var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
+
+ installation.SettingsStore.Load();
+
+ Assert.Equal(recorded, installation.SettingsStore.Settings.BlackBox);
+ }
+
+ [Fact]
+ public void Tapes_turned_on_write_the_black_box_and_leave_the_physics_log_off()
+ {
+ var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog no\n"));
+ installation.SettingsStore.Load();
+ installation.SettingsStore.Settings.BlackBox = true;
+
+ installation.SettingsStore.Save();
+
+ Assert.Equal("blackbox yes", LineFor(installation, "blackbox"));
+ Assert.Equal("physicslog no", LineFor(installation, "physicslog"));
+ }
+
+ [Fact]
+ public void A_black_box_that_says_no_more_than_the_physics_log_adds_no_line()
+ {
+ var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog yes\n"));
+ installation.SettingsStore.Load();
+ installation.SettingsStore.Settings.Width = 1600;
+
+ installation.SettingsStore.Save();
+
+ Assert.Null(LineFor(installation, "blackbox"));
+ }
+
+ [Theory]
+ [InlineData("physicslog yes\nblackbox yes\n")]
+ [InlineData("physicslog no\nblackbox yes\n")]
+ public void A_black_box_line_of_the_file_says_no_once_the_box_is_off(string ini)
+ {
+ var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
+ installation.SettingsStore.Load();
+ installation.SettingsStore.Settings.BlackBox = false;
+ installation.SettingsStore.Settings.PhysicsLog = false;
+
+ installation.SettingsStore.Save();
+
+ Assert.Equal("blackbox no", LineFor(installation, "blackbox"));
+ Assert.Equal("physicslog no", LineFor(installation, "physicslog"));
+ }
+
+ [Fact]
+ public void The_physics_log_turned_off_keeps_the_tapes_it_brought()
+ {
+ // an ini of before the black box had a key: the tapes came with the physics log
+ var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog yes\n"));
+ installation.SettingsStore.Load();
+ installation.SettingsStore.Settings.PhysicsLog = false;
+
+ installation.SettingsStore.Save();
+
+ Assert.Equal("blackbox yes", LineFor(installation, "blackbox"));
+ }
+
+ [Fact]
+ public void A_black_box_line_written_once_goes_away_when_it_says_no_more()
+ {
+ var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog no\n"));
+ installation.SettingsStore.Load();
+ installation.SettingsStore.Settings.BlackBox = true;
+ installation.SettingsStore.Save();
+
+ installation.SettingsStore.Settings.BlackBox = false;
+ installation.SettingsStore.Save();
+
+ Assert.Null(LineFor(installation, "blackbox"));
+ }
}
diff --git a/StarterNG.Tests/StartSimulationTests.cs b/StarterNG.Tests/StartSimulationTests.cs
index 359c73c..973683b 100644
--- a/StarterNG.Tests/StartSimulationTests.cs
+++ b/StarterNG.Tests/StartSimulationTests.cs
@@ -40,6 +40,18 @@ public class StartSimulationTests
Assert.Contains($"vehicle\t{driven}\tPKP/EP07\tep07.mmd", noted);
}
+ [Fact]
+ public void With_the_black_box_alone_the_launch_is_noted_for_the_tapes_it_writes_at_the_end()
+ {
+ var (start, _, installation) = Rig(files => files.WithExecutable(Build), sceneryClock: "07:52");
+ installation.SettingsStore.Settings.BlackBox = true;
+
+ start.Execute(freeFly: false, saveSettings: false);
+
+ string noted = installation.Files.ReadAllText(TestInstallation.At("physicslog", "starter-launch.txt"));
+ Assert.Contains("clock\t07:52", noted);
+ }
+
[Fact]
public void Without_the_physics_log_nothing_is_noted()
{
diff --git a/StarterNG/Application/StartSimulation.cs b/StarterNG/Application/StartSimulation.cs
index 6cacc79..cd310e1 100644
--- a/StarterNG/Application/StartSimulation.cs
+++ b/StarterNG/Application/StartSimulation.cs
@@ -144,7 +144,7 @@ public sealed class StartSimulation
if (saveSettings)
_settings.CaptureAndSave();
- if (_settings.Settings.PhysicsLog)
+ if (_settings.Settings.PhysicsLog || _settings.Settings.BlackBox)
_tapes.RecordLaunch(scenery, trainset, freeFly ? null : vehicle);
string[] arguments = freeFly || string.IsNullOrEmpty(vehicle)
diff --git a/StarterNG/Domain/Settings/SimulatorSettings.cs b/StarterNG/Domain/Settings/SimulatorSettings.cs
index d600399..8e34200 100644
--- a/StarterNG/Domain/Settings/SimulatorSettings.cs
+++ b/StarterNG/Domain/Settings/SimulatorSettings.cs
@@ -133,6 +133,13 @@ public sealed class SimulatorSettings
public bool EnableTraction = true;
public bool LiveTraction = true;
public bool PhysicsLog;
+ ///
+ /// The black box of the session, and with it the tapes (.dat) of the vehicles the player was in, written when the
+ /// simulator closes: the tapes without the log of every vehicle. With no entry of its own it goes with the physics log.
+ ///
+ public bool BlackBox;
+ /// Whether eu07.ini had a line of its own for the black box when read: it is kept saying what is wanted.
+ public bool BlackBoxInIni;
public bool DebugLog = true;
public bool MultipleLogs;
public bool DisplaySimulation = true;
diff --git a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs
index ab66b2f..0d7227b 100644
--- a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs
+++ b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs
@@ -157,6 +157,9 @@ public sealed class SettingsSerializer
s.EnableTraction = c.GetBool("enabletraction", true);
s.LiveTraction = c.GetBool("livetraction", true);
s.PhysicsLog = c.GetBool("physicslog", false);
+ // the simulator records the black box along with the physics log when the ini says nothing of it
+ s.BlackBoxInIni = c.Has("blackbox");
+ s.BlackBox = s.BlackBoxInIni ? c.GetBool("blackbox", false) : s.PhysicsLog;
int debugLog = c.GetInt("debuglog", 3);
s.DebugLog = (debugLog & 1) != 0;
s.DebugLogVisible = (debugLog & 2) != 0;
@@ -370,6 +373,10 @@ public sealed class SettingsSerializer
c.SetBool("enabletraction", s.EnableTraction);
c.SetBool("livetraction", s.LiveTraction);
c.SetBool("physicslog", s.PhysicsLog);
+ // written where it says more than the physics log, or where the file has it already: an ini without it
+ // stays so, and a line written once and no longer saying more goes away on the next save
+ if (s.BlackBoxInIni || s.BlackBox != s.PhysicsLog)
+ c.SetBool("blackbox", s.BlackBox);
c.SetInt("debuglog",
(s.DebugLog ? 1 : 0) | (s.DebugLogVisible ? 2 : 0) | s.DebugLogExtraBits);
c.SetBool("multiplelogs", s.MultipleLogs);
diff --git a/StarterNG/MainWindow.axaml.cs b/StarterNG/MainWindow.axaml.cs
index 2a203ad..4388013 100644
--- a/StarterNG/MainWindow.axaml.cs
+++ b/StarterNG/MainWindow.axaml.cs
@@ -709,7 +709,7 @@ public partial class MainWindow : Window
///
private static void FollowLastRun()
{
- if (AppServices.Current.Settings.PhysicsLog)
+ if (AppServices.Current.Settings.PhysicsLog || AppServices.Current.Settings.BlackBox)
_ = Task.Run(AppServices.Current.Tapes.FollowLastRun);
}
diff --git a/StarterNG/Views/Settings.axaml b/StarterNG/Views/Settings.axaml
index f6cd705..b49cc4d 100644
--- a/StarterNG/Views/Settings.axaml
+++ b/StarterNG/Views/Settings.axaml
@@ -553,6 +553,9 @@
+
+
+
diff --git a/StarterNG/Views/Settings.axaml.cs b/StarterNG/Views/Settings.axaml.cs
index aecbad4..bebe2b1 100644
--- a/StarterNG/Views/Settings.axaml.cs
+++ b/StarterNG/Views/Settings.axaml.cs
@@ -329,6 +329,7 @@ public partial class Settings : UserControl, ISettingsCapture
WhileLoading(() =>
{
SpeedometerTapesCb.IsChecked = AppServices.Current.Settings.PhysicsLog;
+ BlackBoxCb.IsChecked = AppServices.Current.Settings.BlackBox;
SimLogsCb.IsChecked = AppServices.Current.Settings.DebugLog;
});
@@ -441,6 +442,7 @@ public partial class Settings : UserControl, ISettingsCapture
PantographBreakCb.IsChecked = s.EnableTraction;
OverheadOnlyCb.IsChecked = s.LiveTraction;
SpeedometerTapesCb.IsChecked = s.PhysicsLog;
+ BlackBoxCb.IsChecked = s.BlackBox;
SimLogsCb.IsChecked = s.DebugLog;
KeepLogsCb.IsChecked = s.MultipleLogs;
DisplaySimulationCb.IsChecked = s.DisplaySimulation;
@@ -874,6 +876,7 @@ public partial class Settings : UserControl, ISettingsCapture
s.EnableTraction = IsChecked(PantographBreakCb);
s.LiveTraction = IsChecked(OverheadOnlyCb);
s.PhysicsLog = IsChecked(SpeedometerTapesCb);
+ s.BlackBox = IsChecked(BlackBoxCb);
s.DebugLog = IsChecked(SimLogsCb);
s.MultipleLogs = IsChecked(KeepLogsCb);
s.DisplaySimulation = IsChecked(DisplaySimulationCb);
diff --git a/StarterNG/Views/Tapes/HaslerTapeWindow.cs b/StarterNG/Views/Tapes/HaslerTapeWindow.cs
index 2ad9942..bef75b2 100644
--- a/StarterNG/Views/Tapes/HaslerTapeWindow.cs
+++ b/StarterNG/Views/Tapes/HaslerTapeWindow.cs
@@ -163,7 +163,7 @@ public sealed class HaslerTapeWindow : Window
Content = _view
};
- _recordingOff = Strip("HaslerRecordingOff", "HaslerRecordingEnable", settings => settings.PhysicsLog = true);
+ _recordingOff = Strip("HaslerRecordingOff", "HaslerRecordingEnable", settings => settings.BlackBox = true);
_logOff = Strip("HaslerLogOff", "HaslerLogEnable", settings => settings.DebugLog = true);
var folder = ToolButton(App.Loc["HaslerOpenFolder"]);
@@ -229,14 +229,18 @@ public sealed class HaslerTapeWindow : Window
private void ShowWhatIsKnown()
{
var settings = AppServices.Current.Settings;
- _recordingOff.IsVisible = !settings.PhysicsLog;
- _logOff.IsVisible = settings.PhysicsLog && !settings.DebugLog;
+ bool recording = settings.PhysicsLog || settings.BlackBox;
+ _recordingOff.IsVisible = !recording;
+ _logOff.IsVisible = recording && !settings.DebugLog;
- bool canFollow = _running && _tapes.DrivenVehicle is not null;
+ // the black box alone writes the tapes when the simulator closes: only the physics log grows while it runs
+ bool canFollow = _running && settings.PhysicsLog && _tapes.DrivenVehicle is not null;
_live.IsEnabled = canFollow;
if (!canFollow)
_live.IsChecked = false;
- ToolTip.SetTip(_live, App.Loc[canFollow ? "HaslerLiveTip" : "HaslerLiveIdle"]);
+ ToolTip.SetTip(_live, App.Loc[canFollow ? "HaslerLiveTip"
+ : _running && !settings.PhysicsLog ? "HaslerLiveAtClose"
+ : "HaslerLiveIdle"]);
}
private DockPanel Strip(string textKey, string buttonKey, Action enable)
diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml
index 0bb1d32..674e288 100644
--- a/StarterNG/startercfg/lang/cz.xml
+++ b/StarterNG/startercfg/lang/cz.xml
@@ -497,7 +497,9 @@
Zvýšená přesnost fyziky
Možnost zlomení pantografu
Napájení jen pod trolejí
- Ukládat pásky rychloměru
+ Nahrávat černou skříňku a pásky rychloměru
+ Nahrává jízdu do jednoho souboru ve složce physicslog/ a po zavření simulátoru zapíše pásky (.dat) vozidel, ve kterých jste byli.
+ Ukládat fyzikální log všech vozidel
Ukládat log simulace
Zachovat předchozí logy
Zobrazit simulaci
@@ -844,6 +846,7 @@
vlak {0}
Řízené dříve
Funguje, když běží relace spuštěná ze starteru.
+ Černá skříňka zapíše pásky po zavření simulátoru. Živě funguje s fyzikálním logem.
Log simulátoru je vypnutý: starter nevidí přesedání.
Zapnout log
Vozidlo ze startu
diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml
index e0a4ba1..53f5576 100644
--- a/StarterNG/startercfg/lang/en.xml
+++ b/StarterNG/startercfg/lang/en.xml
@@ -516,8 +516,10 @@
Disabling protects the pantograph from breaking on faulty overhead line geometry.
Powered only under overhead line
When disabled, a raised pantograph can power the vehicle even without touching the wire.
- Save physics parameters log
- Writes a detailed trip log to the physicslog/ folder.
+ Record the black box and the speedometer tapes
+ Records the session to one file in the physicslog/ folder and, when the simulator closes, writes the tapes (.dat) of the vehicles you were in.
+ Save the physics log of every vehicle
+ Writes the log of every vehicle of the scenery to the physicslog/ folder as it runs, 20 times a second. For diagnostics: on a large scenery that is hundreds of open files.
Save simulation log
Keep previous logs
Creates a separate log file for each scenery instead of overwriting errors.txt.
@@ -1073,6 +1075,7 @@
train {0}
Driven earlier
Works while a session started from the starter runs.
+ The black box writes the tapes when the simulator closes. Live works with the physics log.
The simulator's log is off: the starter does not see changes of vehicle.
Turn the log on
Vehicle at the start
diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml
index 4c1a4dc..04e7cd2 100644
--- a/StarterNG/startercfg/lang/hu.xml
+++ b/StarterNG/startercfg/lang/hu.xml
@@ -497,7 +497,9 @@
Növelt fizikai pontosság
Áramszedő törésének lehetősége
Táplálás csak felsővezeték alatt
- Sebességmérő-szalagok mentése
+ Fekete doboz és sebességmérő-szalagok rögzítése
+ A menetet egy fájlba rögzíti a physicslog/ mappában, és a szimulátor bezárásakor kiírja azoknak a járműveknek a szalagjait (.dat), amelyekben ültél.
+ Minden jármű fizikai naplójának mentése
Szimulációs napló mentése
Korábbi naplók megtartása
Szimuláció megjelenítése
@@ -844,6 +846,7 @@
vonat {0}
Korábban vezetett
Az indítóból indított munkamenet alatt működik.
+ A fekete doboz a szimulátor bezárásakor írja ki a szalagokat. Az élő nézet a fizikai naplóval működik.
A szimulátor naplója ki van kapcsolva: az indító nem látja a járműváltást.
Napló bekapcsolása
Indulási jármű
diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml
index 3713dd5..d8e8edf 100644
--- a/StarterNG/startercfg/lang/pl.xml
+++ b/StarterNG/startercfg/lang/pl.xml
@@ -516,8 +516,10 @@
Wyłączenie chroni pantograf przed uszkodzeniem przy błędnej geometrii sieci.
Zasilanie tylko pod siecią trakcyjna
Gdy wyłączone, podniesiony pantograf zasila pojazd nawet bez kontaktu z drutem.
- Zapisuj log parametrów fizycznych
- Zapisuje szczegółowy log jazdy do folderu physicslog/.
+ Zapisuj czarną skrzynkę i taśmy prędkościomierza
+ Nagrywa przejazd do jednego pliku w folderze physicslog/, a po zamknięciu symulatora zapisuje taśmy (.dat) pojazdów, w których byłeś.
+ Zapisuj log parametrów fizycznych wszystkich pojazdów
+ Zapisuje na bieżąco log każdego pojazdu scenerii do folderu physicslog/, 20 razy na sekundę. Do diagnostyki: na dużej scenerii to setki otwartych plików.
Zapisuj log z symulacji
Zachowuj poprzednie logi
Tworzy osobny plik logu dla każdej scenerii zamiast nadpisywać errors.txt.
@@ -895,6 +897,7 @@
pociąg {0}
Prowadzony wcześniej
Działa, gdy trwa sesja uruchomiona ze Startera.
+ Czarna skrzynka zapisuje taśmy po zamknięciu symulatora. Na żywo działa z logiem parametrów fizycznych.
Log symulatora jest wyłączony: Starter nie widzi przesiadek.
Włącz log
Pojazd ze startu
diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml
index c73f842..a4639d9 100644
--- a/StarterNG/startercfg/lang/ru.xml
+++ b/StarterNG/startercfg/lang/ru.xml
@@ -497,7 +497,9 @@
Повышенная точность физики
Возможность излома пантографа
Питание только под контактной сетью
- Сохранять ленты скоростемера
+ Записывать чёрный ящик и ленты скоростемера
+ Записывает поездку в один файл в папке physicslog/, а при закрытии симулятора сохраняет ленты (.dat) тех единиц, в которых вы были.
+ Сохранять физический лог всех единиц
Сохранять журнал симуляции
Сохранять предыдущие журналы
Показывать симуляцию
@@ -844,6 +846,7 @@
поезд {0}
Управлялся ранее
Работает, пока идёт сеанс, запущенный из стартера.
+ Чёрный ящик сохраняет ленты при закрытии симулятора. Режим «вживую» работает с физическим логом.
Журнал симулятора выключен: стартер не видит пересадок.
Включить журнал
Транспорт на старте