diff --git a/StarterNG.Tests/PhysicsPresetTests.cs b/StarterNG.Tests/PhysicsPresetTests.cs
new file mode 100644
index 0000000..9d81787
--- /dev/null
+++ b/StarterNG.Tests/PhysicsPresetTests.cs
@@ -0,0 +1,105 @@
+using StarterNG.Domain.Settings;
+using StarterNG.Tests.Fakes;
+
+namespace StarterNG.Tests;
+
+public class PhysicsPresetTests
+{
+ private static SimulatorSettings Defaults()
+ {
+ var installation = new TestInstallation();
+ installation.SettingsStore.Load();
+ return installation.SettingsStore.Settings.Copy();
+ }
+
+ [Fact]
+ public void The_simulators_own_physics_are_neither_arcade_nor_realistic()
+ {
+ Assert.Null(PhysicsPreset.Matching(Defaults()));
+ }
+
+ [Fact]
+ public void A_level_of_realism_applied_is_recognised_until_one_setting_moves()
+ {
+ foreach (var preset in PhysicsPreset.All)
+ {
+ var settings = Defaults();
+ preset.ApplyTo(settings);
+ Assert.Same(preset, PhysicsPreset.Matching(settings));
+
+ settings.CrashDamage = !settings.CrashDamage;
+ Assert.Null(PhysicsPreset.Matching(settings));
+ }
+ }
+
+ [Fact]
+ public void Arcade_forgives_and_realistic_takes_the_physical_models()
+ {
+ var arcade = Defaults();
+ PhysicsPreset.Arcade.ApplyTo(arcade);
+ Assert.False(arcade.CrashDamage);
+ Assert.False(arcade.LiveTraction);
+ Assert.Equal(ConsistReadyOverride.AlwaysReady, arcade.ReadyOverride);
+ Assert.Equal("off", arcade.Extra["physics.derailment"]);
+
+ var realistic = Defaults();
+ PhysicsPreset.Realistic.ApplyTo(realistic);
+ Assert.True(realistic.CrashDamage);
+ Assert.Equal(ConsistReadyOverride.Scenery, realistic.ReadyOverride);
+ Assert.Equal("yes", realistic.Extra["couplerphysics"]);
+ Assert.Equal("new", realistic.Extra["physics.derailment"]);
+ Assert.Equal("new", realistic.Extra["physics.collisions"]);
+ Assert.Equal("auto", realistic.Extra["physics.trackbuckling"]);
+ }
+
+ [Fact]
+ public void Every_value_of_a_level_is_one_its_row_offers()
+ {
+ foreach (var preset in PhysicsPreset.All)
+ foreach (var (name, value) in preset.Keys)
+ Assert.True(SimulatorKeys.Named(name).ChoiceIndex(value) >= 0, $"{preset.NameKey} {name} {value}");
+ Assert.All(PhysicsPreset.All.SelectMany(preset => preset.Keys.Keys), key => Assert.Contains(key, PhysicsPreset.AllKeys));
+ }
+
+ [Fact]
+ public void No_level_of_realism_touches_the_picture_nor_a_level_of_detail_the_realism()
+ {
+ var settings = Defaults();
+ GraphicsPreset.Low.ApplyTo(settings);
+ PhysicsPreset.Realistic.ApplyTo(settings);
+ Assert.Same(GraphicsPreset.Low, GraphicsPreset.Matching(settings));
+
+ GraphicsPreset.VeryHigh.ApplyTo(settings);
+ Assert.Same(PhysicsPreset.Realistic, PhysicsPreset.Matching(settings));
+ }
+
+ [Theory]
+ [InlineData("couplerphysics", "true", "yes")]
+ [InlineData("couplerphysics", "1", "yes")]
+ [InlineData("physics.derailment", "no", "off")]
+ [InlineData("physics.trackbuckling", "no", "off")]
+ [InlineData("couplerphysics", "no", "no")]
+ public void A_word_the_simulator_takes_for_another_stands_for_it(string name, string raw, string word)
+ {
+ var key = SimulatorKeys.Named(name);
+ Assert.Equal(key.ChoiceIndex(word), key.ChoiceIndex(raw));
+ }
+
+ [Fact]
+ public void A_level_of_realism_survives_a_save()
+ {
+ var installation = new TestInstallation();
+ var store = installation.SettingsStore;
+ store.Load();
+ PhysicsPreset.Realistic.ApplyTo(store.Settings);
+
+ store.Save();
+
+ var again = new TestInstallation(installation.Files).SettingsStore;
+ again.Load();
+ Assert.Same(PhysicsPreset.Realistic, PhysicsPreset.Matching(again.Settings));
+ string saved = installation.Files.ReadAllText(store.SavePath);
+ Assert.Contains("physics.derailment new", saved);
+ Assert.Contains("couplerphysics yes", saved);
+ }
+}
diff --git a/StarterNG.Tests/SettingsUnknownValueTests.cs b/StarterNG.Tests/SettingsUnknownValueTests.cs
index 12ab51a..74251f0 100644
--- a/StarterNG.Tests/SettingsUnknownValueTests.cs
+++ b/StarterNG.Tests/SettingsUnknownValueTests.cs
@@ -81,6 +81,32 @@ public class SettingsUnknownValueTests
});
}
+ [Fact]
+ public void A_level_of_realism_picked_is_saved_and_marked_until_a_setting_moves()
+ {
+ WithPage(Standard, (page, services, saved) =>
+ {
+ var buttons = page.FindControl("PhysicsPresetButtons")!.Children.OfType
@@ -372,8 +363,21 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -383,6 +387,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ _physicsButtons = new();
+
+ private void BuildPhysicsPresets()
+ {
+ foreach (var preset in PhysicsPreset.All)
+ {
+ var button = new Button { Cursor = new Cursor(StandardCursorType.Hand) };
+ button.Classes.Add("Flat");
+ button.Click += (_, _) => ApplyPhysicsPreset(preset);
+ PhysicsPresetButtons.Children.Add(button);
+ _physicsButtons.Add((preset, button));
+ }
+ UpdatePhysicsPresetTexts();
+ App.Loc.LanguageChanged += UpdatePhysicsPresetTexts;
+ }
+
+ private void UpdatePhysicsPresetTexts()
+ {
+ foreach (var (preset, button) in _physicsButtons)
+ button.Content = App.Loc[preset.NameKey];
+ UpdatePhysicsPresetMarks(Trial());
+ }
+
+ /// Puts a level of realism on the screen, as edits waiting for Save.
+ private void ApplyPhysicsPreset(PhysicsPreset preset)
+ {
+ var trial = Trial();
+ preset.ApplyTo(trial);
+ ShowAsEdits(trial, PhysicsPreset.AllKeys);
+ foreach (var (key, value) in preset.Keys)
+ _keyRows.Show(key, value);
+
+ ForgetShown(PhysicsPreset.AllKeys);
+ UpdatePresetMarks();
+ Announcer.Say(this, ScreenReaderNames.PickerText(App.Loc["PhysicsPresets"], App.Loc[preset.NameKey]));
+ }
+
+ private void UpdatePhysicsPresetMarks(SimulatorSettings trial)
+ {
+ if (!_built)
+ return;
+ var matching = PhysicsPreset.Matching(trial);
+ foreach (var (preset, button) in _physicsButtons)
+ {
+ button.Classes.Set("Accent", preset == matching);
+ button.Classes.Set("Flat", preset != matching);
+ }
+ PhysicsPresetState.Text = matching is null ? App.Loc["PresetCustom"] : string.Empty;
+ }
+
// ── The ray-traced reflections ───────────────────────────────────────────
/// The list's item for a reach none of the levels has, while the rows have one.
diff --git a/StarterNG/Views/SimulatorKeyRows.cs b/StarterNG/Views/SimulatorKeyRows.cs
index 2d360c3..3c06490 100644
--- a/StarterNG/Views/SimulatorKeyRows.cs
+++ b/StarterNG/Views/SimulatorKeyRows.cs
@@ -116,16 +116,18 @@ internal sealed class SimulatorKeyRows
{
var list = new ComboBox { MinWidth = 160 };
foreach (string choice in key.Choices ?? Array.Empty())
- list.Items.Add(new ComboBoxItem { Tag = choice, Content = ChoiceText(choice) });
+ list.Items.Add(new ComboBoxItem { Tag = choice, Content = ChoiceText(key, choice) });
return list;
}
///
- /// A word of a list as the player reads it: translated where the language has it (no, low, high...), else in
- /// English, else as the simulator writes it (DLSS's preset letters).
+ /// A word of a list as the player reads it: as that key names it (the "new" of the derailment), else as every
+ /// list names it (no, low, high...), translated where the language has it, else in English, else as the
+ /// simulator writes it (DLSS's preset letters).
///
- private static string ChoiceText(string choice) =>
- App.Loc.OptOrEnglish(SimulatorKey.ChoiceLabelKey(choice)) is { Length: > 0 } text ? text : choice;
+ private static string ChoiceText(SimulatorKey key, string choice) =>
+ App.Loc.OptOrEnglish(SimulatorKey.ChoiceLabelKey(key.Key + "." + choice)) is { Length: > 0 } own ? own
+ : App.Loc.OptOrEnglish(SimulatorKey.ChoiceLabelKey(choice)) is { Length: > 0 } text ? text : choice;
/// The developer tab's rows are named in the language where it has them, else in English.
private static string Text(string key) => App.Loc.OptOrEnglish(key);
@@ -188,7 +190,7 @@ internal sealed class SimulatorKeyRows
case ComboBox list:
row.Setting.Label = label;
foreach (var item in list.Items.OfType())
- item.Content = ChoiceText(item.Tag as string ?? string.Empty);
+ item.Content = ChoiceText(row.Key, item.Tag as string ?? string.Empty);
break;
default:
row.Setting.Label = label;
diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml
index 63abefb..4d5539a 100644
--- a/StarterNG/startercfg/lang/cz.xml
+++ b/StarterNG/startercfg/lang/cz.xml
@@ -957,4 +957,27 @@
SimulátorRay tracing (odrazy)Vypnuto
+ Realismus jízdy
+ Úroveň realismu
+ Arkádový
+ Realistický
+ Brzda z klávesnice
+ Spřáhla
+ Vykolejení
+ Srážky
+ Vybočení koleje v horku
+ Zvěř u trati
+ Zjednodušená
+ Fyzikální – vlak hráče
+ Fyzikální – všechny vlaky
+ Vypnuto
+ Klasické
+ Fyzikální
+ Klasické, bez protokolu
+ Klasické
+ Fyzikální
+ Klasické, fyzikální do protokolu
+ Vypnuto
+ Ze scenérie
+ I z horka
diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml
index d0a79db..72c0407 100644
--- a/StarterNG/startercfg/lang/en.xml
+++ b/StarterNG/startercfg/lang/en.xml
@@ -1257,4 +1257,38 @@
OffRay-traced reflections: more exact, but costly. Vulkan and a card with ray tracing only (NVIDIA RTX, AMD RX 6000 and newer). The level is how far the rays reach; no level of detail turns them on.Automatic picks the build that runs on this processor. Choose another only when several builds are installed.
+ Driving realism
+ Realism level
+ Arcade
+ Realistic
+ Brake from the keyboard
+ Couplings
+ Derailment
+ Collisions
+ Track buckling in heat
+ Animals by the track
+ Simplified
+ Physical – the player's train
+ Physical – every train
+ Off
+ Classic
+ Physical
+ Classic, nothing to the log
+ Classic
+ Physical
+ Classic, physical to the log
+ Off
+ From the scenery
+ Also from heat
+ Arcade forgives: no derailment, no damage, power without the wires, every consist ready to drive. Realistic takes the physical models of the couplings, derailment, collisions and track. Each setting below can still be changed on its own.
+ Physical: buffers and draw gear with play, give and breaking, as a rough start or a hard stop shows. On every train it costs more processor time.
+ Physical: a vehicle too fast in a curve overturns or climbs the rail; within the track's own speed limit nothing derails. Classic: the old rule.
+ Physical: the ends crush, a vehicle may ride up onto another or be pushed off the track. Classic: the old rule of a safe closing speed.
+ From the scenery: only where its author put a buckle. Also from heat: weak places of welded track buckle when the rails get hot.
+ Deer graze by the track ahead and run away from the horn.
+ A track's speed limit derails nothing
+ With physical derailment: within the limit only the couplings, a buckle or damage derail.
+ No multiple-unit control of electric and diesel
+ AI sets the brakes by Cw-1
+ Suspicious track geometry to the log
diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml
index 9be43c7..d37d12a 100644
--- a/StarterNG/startercfg/lang/hu.xml
+++ b/StarterNG/startercfg/lang/hu.xml
@@ -957,4 +957,27 @@
SzimulátorSugárkövetés (tükröződések)Ki
+ Vezetési realizmus
+ Realizmus szintje
+ Árkád
+ Valósághű
+ Fék a billentyűzetről
+ Kapcsolókészülékek
+ Kisiklás
+ Ütközések
+ Vágánykivetődés hőségben
+ Állatok a pálya mellett
+ Egyszerűsített
+ Fizikai – a játékos vonata
+ Fizikai – minden vonat
+ Ki
+ Klasszikus
+ Fizikai
+ Klasszikus, napló nélkül
+ Klasszikus
+ Fizikai
+ Klasszikus, a fizikai a naplóba
+ Ki
+ A pályáról
+ Hőségtől is
diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml
index e3f9a27..4a681c4 100644
--- a/StarterNG/startercfg/lang/pl.xml
+++ b/StarterNG/startercfg/lang/pl.xml
@@ -1079,4 +1079,38 @@
WyłączonyOdbicia liczone ray tracingiem: dokładniejsze, ale kosztowne. Tylko Vulkan i karta z ray tracingiem (NVIDIA RTX, AMD RX 6000 i nowsze). Poziom to zasięg promieni; poziomy jakości grafiki go nie włączają.Automatycznie wybiera wersję, która działa na tym procesorze. Wybierz inną tylko wtedy, gdy masz zainstalowanych kilka wersji.
+ Realizm jazdy
+ Poziom realizmu
+ Arcade
+ Realistyczny
+ Hamulec z klawiatury
+ Sprzęgi
+ Wykolejenia
+ Zderzenia
+ Wyboczenie toru w upale
+ Zwierzęta przy torach
+ Uproszczone
+ Fizyczne – pociąg gracza
+ Fizyczne – wszystkie pociągi
+ Wyłączone
+ Klasyczne
+ Fizyczne
+ Klasyczne, bez wpisów w logu
+ Klasyczne
+ Fizyczne
+ Klasyczne, fizyczne do logu
+ Wyłączone
+ Ze scenerii
+ Także od upału
+ Arcade wybacza: bez wykolejeń i uszkodzeń, prąd bez sieci, każdy skład gotowy do jazdy. Realistyczny włącza fizyczne modele sprzęgów, wykolejeń, zderzeń i toru. Każde ustawienie poniżej można potem zmienić osobno.
+ Fizyczne: zderzaki i sprzęgi z luzem, uginaniem i zrywaniem, co czuć przy szarpnięciu i ostrym hamowaniu. Dla wszystkich pociągów bardziej obciąża procesor.
+ Fizyczne: pojazd za szybki w łuku przewraca się albo wspina na szynę; w granicach prędkości dozwolonej na torze nic się nie wykoleja. Klasyczne: dawna reguła.
+ Fizyczne: czoła się zgniatają, pojazd może wjechać na drugi albo zostać zepchnięty z toru. Klasyczne: dawna reguła bezpiecznej prędkości najazdu.
+ Ze scenerii: tylko tam, gdzie umieścił je autor. Także od upału: słabe miejsca toru bezstykowego wyboczają się, gdy szyny się nagrzeją.
+ Sarny pasą się przy torze przed pociągiem i uciekają przed sygnałem.
+ Prędkość dozwolona toru nie wykoleja
+ Przy fizycznych wykolejeniach: w granicach dozwolonej prędkości wykolejają tylko sprzęgi, wyboczenie albo uszkodzenie.
+ Bez sterowania wielokrotnego elektrycznych ze spalinowymi
+ AI nastawia hamulce według Cw-1
+ Podejrzana geometria torów do logu
diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml
index 2afb0d1..7cecb21 100644
--- a/StarterNG/startercfg/lang/ru.xml
+++ b/StarterNG/startercfg/lang/ru.xml
@@ -957,4 +957,27 @@
СимуляторТрассировка лучей (отражения)Выкл.
+ Реализм вождения
+ Уровень реализма
+ Аркадный
+ Реалистичный
+ Тормоз с клавиатуры
+ Сцепки
+ Сход с рельсов
+ Столкновения
+ Выброс пути в жару
+ Животные у пути
+ Упрощённые
+ Физические – поезд игрока
+ Физические – все поезда
+ Выкл.
+ Классические
+ Физические
+ Классические, без журнала
+ Классические
+ Физические
+ Классические, физические в журнал
+ Выкл.
+ Из сценерии
+ Также от жары
diff --git a/StarterNG/startercfg/lang/zh.xml b/StarterNG/startercfg/lang/zh.xml
index 56c7a83..2548b0c 100644
--- a/StarterNG/startercfg/lang/zh.xml
+++ b/StarterNG/startercfg/lang/zh.xml
@@ -1205,4 +1205,27 @@
关闭高级模式会把“开发者”选项卡中的所有内容恢复为启动器自带的值(Vulkan,所有优化开启),并保存本页的设置。画质保持“图形”选项卡中显示的样子。要关闭吗?模拟器关闭
+ 驾驶真实度
+ 真实度
+ 街机
+ 真实
+ 键盘制动
+ 车钩
+ 脱轨
+ 碰撞
+ 高温胀轨
+ 轨道旁的动物
+ 简化
+ 物理 – 玩家列车
+ 物理 – 所有列车
+ 关闭
+ 经典
+ 物理
+ 经典(不记录日志)
+ 经典
+ 物理
+ 经典(物理结果记录日志)
+ 关闭
+ 来自场景
+ 也包括高温