From 5b43e29f9ea76fd857dc5f99eb60b888b3cfba9a Mon Sep 17 00:00:00 2001 From: maj00r Date: Mon, 16 Nov 2026 00:16:13 +0100 Subject: [PATCH] fix(start): unsaved settings let go rather than started without, a failed save starts nothing - the second answer discards the edits (as "Restore" does): kept, the starter would write them when it closes, with auto-close while the simulator reads the file - a save that fails is said and the simulator is not started - settings read again from a file changed outside leave the page with no edit of its own - a closed tape window lets go of the file it read last, shown or not --- StarterNG/MainWindow.axaml.cs | 16 +++++++++++++--- StarterNG/Views/Settings.axaml.cs | 13 +++++++++++-- StarterNG/Views/Tapes/HaslerTapeWindow.cs | 7 +++++-- StarterNG/startercfg/lang/cz.xml | 4 ++-- StarterNG/startercfg/lang/en.xml | 4 ++-- StarterNG/startercfg/lang/hu.xml | 4 ++-- StarterNG/startercfg/lang/pl.xml | 4 ++-- StarterNG/startercfg/lang/ru.xml | 4 ++-- 8 files changed, 39 insertions(+), 17 deletions(-) diff --git a/StarterNG/MainWindow.axaml.cs b/StarterNG/MainWindow.axaml.cs index 008905a..f978000 100644 --- a/StarterNG/MainWindow.axaml.cs +++ b/StarterNG/MainWindow.axaml.cs @@ -610,16 +610,26 @@ public partial class MainWindow : Window App.Loc["StartNoStaffTitle"], MessageBoxButtons.YesNo)) return; - // edits on the settings page not saved: said before they go to the simulator, or not + // edits on the settings page not saved: saved, or let go - kept, the starter would write them when it + // closes, perhaps while the simulator reads the file if (saveSettings && SettingsView.HasUnsavedChanges) { var save = await MessageBox.Choose(this, App.Loc["StartUnsavedMessage"], App.Loc["UnsavedChanges"], App.Loc["StartUnsavedSave"], App.Loc["StartUnsavedWithout"]); if (save is null) return; - if (save == true) + if (save == false) + SettingsView.DiscardChanges(); + else + { SettingsView.Save(); - saveSettings = save == true; + if (AppServices.Current.SettingsStore.LastSaveFailed) + { + await MessageBox.Show(this, App.Loc["SettingsNotSaved"], App.Loc["UnsavedChanges"], + MessageBoxButtons.Ok); + return; + } + } } LoadingScreen.Prepare(trainset?.Logo, Path.GetFileNameWithoutExtension(scenery.Path)); diff --git a/StarterNG/Views/Settings.axaml.cs b/StarterNG/Views/Settings.axaml.cs index 176c839..c47af0d 100644 --- a/StarterNG/Views/Settings.axaml.cs +++ b/StarterNG/Views/Settings.axaml.cs @@ -316,7 +316,13 @@ public partial class Settings : UserControl, ISettingsCapture SelectExeCb.SelectedIndex = index; } - public void ReloadFromSettings() => ApplyToUi(); + /// The settings read again from the file: the page shows them, no edit of its own left. + public void ReloadFromSettings() + { + ApplyToUi(); + _dirty = false; + UpdateSaveState(); + } /// /// True while a cab-control binding is waiting for a keypress. The window's own @@ -1145,7 +1151,10 @@ public partial class Settings : UserControl, ISettingsCapture ThumbnailSizeChanged?.Invoke(); } - private void ResetButton_OnClick(object? sender, RoutedEventArgs e) + private void ResetButton_OnClick(object? sender, RoutedEventArgs e) => DiscardChanges(); + + /// The edits not saved let go, the page and the keys as the files have them: "Przywróć". + public void DiscardChanges() { AppServices.Current.SettingsStore.Load(); ApplyToUi(); diff --git a/StarterNG/Views/Tapes/HaslerTapeWindow.cs b/StarterNG/Views/Tapes/HaslerTapeWindow.cs index 004338d..46e29da 100644 --- a/StarterNG/Views/Tapes/HaslerTapeWindow.cs +++ b/StarterNG/Views/Tapes/HaslerTapeWindow.cs @@ -75,6 +75,8 @@ public sealed class HaslerTapeWindow : Window private bool _looking; // closed: a read already under way when it closed is let go, not kept followed private bool _closed; + // the file read last, kept by the tapes to be followed even once another is picked or none is shown + private string? _read; /// A setting went on from here; the settings page's boxes have to follow it. public event Action? LogEnabled; @@ -230,8 +232,8 @@ public sealed class HaslerTapeWindow : Window { _closed = true; _timer.Stop(); - if (_shown is { } shown) - _tapes.Forget(shown.Path); + if (_read is { } read) + _tapes.Forget(read); }; } @@ -646,6 +648,7 @@ public sealed class HaslerTapeWindow : Window { // the same tape grown, as the simulator writes it: only what was added is read bool follow = file.Path == _shown?.Path && file.Size >= _shown.Size; + _read = file.Path; var tape = await Task.Run(() => _tapes.Load(file, follow)); if (_closed) { diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml index 7fdd310..daeac62 100644 --- a/StarterNG/startercfg/lang/cz.xml +++ b/StarterNG/startercfg/lang/cz.xml @@ -632,9 +632,9 @@ Připojit soupravu ze skladu Přidat soupravy ze souboru... Spustit bez uložení nastavení - Nastavení obsahuje neuložené změny. Simulátor se s nimi spustí, jen pokud budou uloženy. + Nastavení obsahuje neuložené změny. Uložit je před spuštěním simulátoru? Uložit a spustit - Spustit bez uložení + Zahodit změny a spustit Další způsoby spuštění Spustit bez vozidla Editor scenérie diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml index 17fa374..d3944ce 100644 --- a/StarterNG/startercfg/lang/en.xml +++ b/StarterNG/startercfg/lang/en.xml @@ -658,9 +658,9 @@ Append warehouse consist Add consists from file... Start without saving settings - The settings have unsaved changes. The simulator starts with them only if they are saved. + The settings have unsaved changes. Save them before starting the simulator? Save and start - Start without saving + Discard changes and start More ways to start Start with no vehicle Scenery editor diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml index 8223491..1799721 100644 --- a/StarterNG/startercfg/lang/hu.xml +++ b/StarterNG/startercfg/lang/hu.xml @@ -632,9 +632,9 @@ Raktári szerelvény hozzáfűzése Szerelvények hozzáadása fájlból... Indítás a beállítások mentése nélkül - A beállításokban nem mentett módosítások vannak. A szimulátor csak akkor indul velük, ha mentve lesznek. + A beállításokban nem mentett módosítások vannak. Menti őket a szimulátor indítása előtt? Mentés és indítás - Indítás mentés nélkül + Módosítások elvetése és indítás További indítási módok Indítás jármű nélkül Pályaszerkesztő diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml index 2ad493a..d819706 100644 --- a/StarterNG/startercfg/lang/pl.xml +++ b/StarterNG/startercfg/lang/pl.xml @@ -658,9 +658,9 @@ Dołącz skład z magazynu Dodaj składy z pliku... Uruchom bez zapisu ustawień - Ustawienia mają niezapisane zmiany. Symulator uruchomi się z nimi tylko wtedy, gdy zostaną zapisane. + Ustawienia mają niezapisane zmiany. Zapisać je przed uruchomieniem symulatora? Zapisz i uruchom - Uruchom bez zapisu + Odrzuć zmiany i uruchom Inne sposoby uruchomienia Uruchom bez pojazdu Edytor scenerii diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml index f16810a..ea72368 100644 --- a/StarterNG/startercfg/lang/ru.xml +++ b/StarterNG/startercfg/lang/ru.xml @@ -632,9 +632,9 @@ Присоединить состав со склада Добавить составы из файла... Запустить без сохранения настроек - В настройках есть несохранённые изменения. Симулятор запустится с ними, только если их сохранить. + В настройках есть несохранённые изменения. Сохранить их перед запуском симулятора? Сохранить и запустить - Запустить без сохранения + Отменить изменения и запустить Другие способы запуска Запустить без транспорта Редактор сценария