From c0cc696dc91818f5b00d231a8a153e9239ebe268 Mon Sep 17 00:00:00 2001 From: maj00r Date: Fri, 4 Sep 2026 23:24:45 +0200 Subject: [PATCH] Restore the three-state consist override in settings Keeps the old starter's starter.batterydefault key and its three states. The setting wins over the depot checkbox, which greys out and says so while an override is in force. --- StarterNG.Tests/SettingsStoreTests.cs | 26 +++++++++++++++++++ StarterNG/Application/StartSimulation.cs | 12 +++++++++ .../Domain/Settings/SimulatorSettings.cs | 5 ++++ .../Settings/SettingsSerializer.cs | 9 +++++++ StarterNG/Views/Depot/VehicleDetails.cs | 14 +++++++--- StarterNG/Views/Settings.axaml | 9 +++++++ StarterNG/Views/Settings.axaml.cs | 2 ++ StarterNG/startercfg/lang/cz.xml | 6 +++++ StarterNG/startercfg/lang/en.xml | 6 +++++ StarterNG/startercfg/lang/hu.xml | 6 +++++ StarterNG/startercfg/lang/pl.xml | 6 +++++ StarterNG/startercfg/lang/ru.xml | 6 +++++ 12 files changed, 104 insertions(+), 3 deletions(-) diff --git a/StarterNG.Tests/SettingsStoreTests.cs b/StarterNG.Tests/SettingsStoreTests.cs index 9b4c2b3..ba870a9 100644 --- a/StarterNG.Tests/SettingsStoreTests.cs +++ b/StarterNG.Tests/SettingsStoreTests.cs @@ -82,6 +82,32 @@ public class SettingsStoreTests Assert.Contains("lang zh", installation.Files.ReadAllText(UserIni)); } + [Fact] + public void The_consist_state_override_keeps_the_key_the_old_starter_used() + { + var installation = WithHome(new InMemoryFileSystem() + .WithFile(UserIni, "starter.batterydefault 2\n")); + + installation.SettingsStore.Load(); + Assert.Equal(ConsistReadyOverride.AlwaysReady, installation.SettingsStore.Settings.ReadyOverride); + + installation.SettingsStore.Settings.ReadyOverride = ConsistReadyOverride.AlwaysCold; + installation.SettingsStore.Save(); + + Assert.Contains("starter.batterydefault 1", installation.Files.ReadAllText(UserIni)); + } + + [Fact] + public void An_out_of_range_override_falls_back_to_leaving_the_scenery_alone() + { + var installation = WithHome(new InMemoryFileSystem() + .WithFile(UserIni, "starter.batterydefault 9\n")); + + installation.SettingsStore.Load(); + + Assert.Equal(ConsistReadyOverride.Scenery, installation.SettingsStore.Settings.ReadyOverride); + } + [Fact] public void A_first_run_falls_back_to_the_ini_shipped_with_the_installation() { diff --git a/StarterNG/Application/StartSimulation.cs b/StarterNG/Application/StartSimulation.cs index 18697c5..8e05d29 100644 --- a/StarterNG/Application/StartSimulation.cs +++ b/StarterNG/Application/StartSimulation.cs @@ -79,6 +79,18 @@ public sealed class StartSimulation if (scenery is null || trainset is null) return new SimulationStartResult(SimulationStartOutcome.NothingSelected); + // The depot checkbox is the consist's own state; this setting is a blanket + // override for people who always want the same thing, and it wins. + switch (_settings.Settings.ReadyOverride) + { + case ConsistReadyOverride.AlwaysCold: + trainset.ReadyToGo = false; + break; + case ConsistReadyOverride.AlwaysReady: + trainset.ReadyToGo = true; + break; + } + string? vehicle = TrainsetDisplay.UniquifyForLaunch(trainset, scenery, _state.StartingVehicleName) ?? StartableVehicle(trainset, _state.StartingVehicleName); _state.StartingVehicleName = vehicle; diff --git a/StarterNG/Domain/Settings/SimulatorSettings.cs b/StarterNG/Domain/Settings/SimulatorSettings.cs index 4aa48c2..a93169e 100644 --- a/StarterNG/Domain/Settings/SimulatorSettings.cs +++ b/StarterNG/Domain/Settings/SimulatorSettings.cs @@ -2,6 +2,9 @@ using System; namespace StarterNG.Domain.Settings; +// Values match the key eu07.ini has carried since the old starter. +public enum ConsistReadyOverride { Scenery = 0, AlwaysCold = 1, AlwaysReady = 2 } + public enum ExeProblem { None, NotFound, NotExecutable, WrongPlatform } public sealed class SimulatorSettings @@ -106,6 +109,8 @@ public sealed class SimulatorSettings public bool LargeThumbnails; public bool AutoExpandSceneryTree; + public ConsistReadyOverride ReadyOverride = ConsistReadyOverride.Scenery; + public bool ShowAiVehicles = true; public bool DrivableOnly = true; public bool ShowArchivalSceneries = true; diff --git a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs index 38561aa..498a50f 100644 --- a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs +++ b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs @@ -136,6 +136,14 @@ public sealed class SettingsSerializer s.AutoCloseStarter = c.GetBool("starter.autoclose", false); s.LargeThumbnails = c.GetBool("starter.largethumbnails", false); s.AutoExpandSceneryTree = c.GetBool("starter.expandtree", false); + // An unrecognised value means "do not interfere" rather than the nearest + // state: clamping upwards would silently force every consist ready. + s.ReadyOverride = c.GetInt("starter.batterydefault", 0) switch + { + 1 => ConsistReadyOverride.AlwaysCold, + 2 => ConsistReadyOverride.AlwaysReady, + _ => ConsistReadyOverride.Scenery + }; s.ShowAiVehicles = c.GetBool("starter.show.ai", true); s.DrivableOnly = c.GetBool("starter.drivableonly", true); s.ShowArchivalSceneries = c.GetBool("starter.show.archival", true); @@ -264,6 +272,7 @@ public sealed class SettingsSerializer c.SetBool("starter.autoclose", s.AutoCloseStarter); c.SetBool("starter.largethumbnails", s.LargeThumbnails); c.SetBool("starter.expandtree", s.AutoExpandSceneryTree); + c.SetInt("starter.batterydefault", (int)s.ReadyOverride); c.SetBool("starter.show.ai", s.ShowAiVehicles); c.SetBool("starter.drivableonly", s.DrivableOnly); c.SetBool("starter.show.archival", s.ShowArchivalSceneries); diff --git a/StarterNG/Views/Depot/VehicleDetails.cs b/StarterNG/Views/Depot/VehicleDetails.cs index 7fe8475..4527826 100644 --- a/StarterNG/Views/Depot/VehicleDetails.cs +++ b/StarterNG/Views/Depot/VehicleDetails.cs @@ -12,6 +12,7 @@ using Avalonia.Media; using StarterNG.Classes; using StarterNG.Controls; using StarterNG.Domain; +using StarterNG.Domain.Settings; using StarterNG.Domain.Vehicles; using StarterNG.Application; @@ -579,14 +580,21 @@ public sealed class VehicleDetails private Control ReadyToGoRow() { var trainset = _consist.EditingTrainset; + var over = AppServices.Current.Settings.ReadyOverride; + bool overridden = over != ConsistReadyOverride.Scenery; + var ready = new CheckBox { Content = App.Loc["ConsistReady"], FontSize = 12, - IsEnabled = trainset is not null, - IsChecked = trainset?.ReadyToGo ?? false + IsEnabled = trainset is not null && !overridden, + IsChecked = overridden + ? over == ConsistReadyOverride.AlwaysReady + : trainset?.ReadyToGo ?? false }; - ToolTip.SetTip(ready, App.Loc["ConsistReadyDesc"]); + ToolTip.SetTip(ready, overridden + ? App.Loc["ConsistReadyOverridden"] + : App.Loc["ConsistReadyDesc"]); ready.IsCheckedChanged += (_, _) => { diff --git a/StarterNG/Views/Settings.axaml b/StarterNG/Views/Settings.axaml index cf176fe..d441d5a 100644 --- a/StarterNG/Views/Settings.axaml +++ b/StarterNG/Views/Settings.axaml @@ -118,6 +118,15 @@ + + + + + + + diff --git a/StarterNG/Views/Settings.axaml.cs b/StarterNG/Views/Settings.axaml.cs index 8e480cf..0676034 100644 --- a/StarterNG/Views/Settings.axaml.cs +++ b/StarterNG/Views/Settings.axaml.cs @@ -260,6 +260,7 @@ public partial class Settings : UserControl, ISettingsCapture AutoCloseStarterCb.IsChecked = s.AutoCloseStarter; LargeThumbnailsCb.IsChecked = s.LargeThumbnails; AutoExpandTreeCb.IsChecked = s.AutoExpandSceneryTree; + ReadyOverrideCb.SelectedIndex = (int)s.ReadyOverride; } finally { @@ -357,6 +358,7 @@ public partial class Settings : UserControl, ISettingsCapture s.AutoCloseStarter = IsChecked(AutoCloseStarterCb); s.LargeThumbnails = IsChecked(LargeThumbnailsCb); s.AutoExpandSceneryTree = IsChecked(AutoExpandTreeCb); + s.ReadyOverride = (ConsistReadyOverride)Math.Clamp(ReadyOverrideCb.SelectedIndex, 0, 2); } private void ComButton_OnClick(object? sender, RoutedEventArgs e) diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml index 109f347..9332368 100644 --- a/StarterNG/startercfg/lang/cz.xml +++ b/StarterNG/startercfg/lang/cz.xml @@ -216,6 +216,12 @@ Náklad celé soupravy Consist ready to go The consist starts prepared: brake pipe charged, driver’s brake valve set, batteries closed. Unchecked it starts cold and braked. + Force the consist state on launch + Overrides the depot’s "consist ready to go" box for every scenario you start. + As authored + Always cold + Always ready + Overridden by "Force the consist state on launch" in Settings. Náhodný druh Maximální množství Náhodné množství diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml index 4199795..2886e96 100644 --- a/StarterNG/startercfg/lang/en.xml +++ b/StarterNG/startercfg/lang/en.xml @@ -216,6 +216,12 @@ Whole-consist load Consist ready to go The consist starts prepared: brake pipe charged, driver’s brake valve set, batteries closed. Unchecked it starts cold and braked. + Force the consist state on launch + Overrides the depot’s "consist ready to go" box for every scenario you start. + As authored + Always cold + Always ready + Overridden by "Force the consist state on launch" in Settings. Random type Maximum amount Random amount diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml index a8a22f4..d25ded6 100644 --- a/StarterNG/startercfg/lang/hu.xml +++ b/StarterNG/startercfg/lang/hu.xml @@ -216,6 +216,12 @@ A teljes szerelvény rakománya Consist ready to go The consist starts prepared: brake pipe charged, driver’s brake valve set, batteries closed. Unchecked it starts cold and braked. + Force the consist state on launch + Overrides the depot’s "consist ready to go" box for every scenario you start. + As authored + Always cold + Always ready + Overridden by "Force the consist state on launch" in Settings. Véletlen típus Legnagyobb mennyiség Véletlen mennyiség diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml index b78f82c..80405e7 100644 --- a/StarterNG/startercfg/lang/pl.xml +++ b/StarterNG/startercfg/lang/pl.xml @@ -216,6 +216,12 @@ Ładunki zestawienia Skład gotowy do jazdy Skład startuje przygotowany: przewód główny napełniony, kran maszynisty ustawiony, akumulatory załączone. Odznaczony startuje zimny i zahamowany. + Wymuś stan składu przy starcie + Nadpisuje pole „Skład gotowy do jazdy” w zajezdni dla każdego uruchamianego scenariusza. + Jak w scenerii + Zawsze zimny + Zawsze gotowy + Nadpisane opcją „Wymuś stan składu przy starcie” w Ustawieniach. Losowy rodzaj Maksymalna ilość Losowa ilość diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml index 1ecee1c..fbda204 100644 --- a/StarterNG/startercfg/lang/ru.xml +++ b/StarterNG/startercfg/lang/ru.xml @@ -216,6 +216,12 @@ Груз всего состава Consist ready to go The consist starts prepared: brake pipe charged, driver’s brake valve set, batteries closed. Unchecked it starts cold and braked. + Force the consist state on launch + Overrides the depot’s "consist ready to go" box for every scenario you start. + As authored + Always cold + Always ready + Overridden by "Force the consist state on launch" in Settings. Случайный тип Максимальное количество Случайное количество