From b7eefcd0ed18f0c002993285c8a2160e2e4e461a Mon Sep 17 00:00:00 2001 From: maj00r Date: Wed, 11 Nov 2026 18:25:54 +0100 Subject: [PATCH] fix(tapes): a session picked with no tape stays picked when the list refreshes, and an empty one says it has no black box either --- StarterNG/Views/Tapes/HaslerTapeWindow.cs | 22 ++++++++++++++++++---- StarterNG/startercfg/lang/cz.xml | 1 + StarterNG/startercfg/lang/en.xml | 1 + StarterNG/startercfg/lang/hu.xml | 1 + StarterNG/startercfg/lang/pl.xml | 1 + StarterNG/startercfg/lang/ru.xml | 1 + 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/StarterNG/Views/Tapes/HaslerTapeWindow.cs b/StarterNG/Views/Tapes/HaslerTapeWindow.cs index 8634740..76a9640 100644 --- a/StarterNG/Views/Tapes/HaslerTapeWindow.cs +++ b/StarterNG/Views/Tapes/HaslerTapeWindow.cs @@ -66,6 +66,8 @@ public sealed class HaslerTapeWindow : Window private readonly Action _picked; private TapeFile? _shown; + /// The session picked that has no tape, so that a refresh of the list goes back to it and not to a tape of another. + private DateTime? _tapeless; private string? _followed; private string _listed = ""; private bool _running; @@ -139,7 +141,7 @@ public sealed class HaslerTapeWindow : Window if (file is null) { if (session is not null) - ShowNoTape(); + ShowNoTape(session); return; } if (file == _shown) @@ -340,6 +342,7 @@ public sealed class HaslerTapeWindow : Window if (toDriven) _followed = driven; string? selected = toDriven && driven is not null ? driven : _shown?.Path; + DateTime? tapeless = toDriven && driven is not null ? null : _tapeless; FollowBlackBoxes(sessions); foreach (var node in _list.Items.OfType()) @@ -347,10 +350,13 @@ public sealed class HaslerTapeWindow : Window _list.Items.Clear(); (TreeViewItem Node, TreeViewItem Tape)? first = null, pick = null; + TreeViewItem? again = null; for (int i = 0; i < sessions.Count; i++) { var node = SessionItem(sessions[i], _expanded.GetValueOrDefault(sessions[i].StartedUtc, i == 0)); _list.Items.Add(node); + if (sessions[i].StartedUtc == tapeless) + again = node; foreach (var tape in node.Items.OfType().Where(item => item.Tag is TapeFile)) { first ??= (node, tape); @@ -362,6 +368,12 @@ public sealed class HaslerTapeWindow : Window _empty.Text = string.Format(App.Loc["HaslerNoTapes"], _tapes.Folder); _empty.IsVisible = first is null; _scroll.IsVisible = first is not null; + if (pick is null && again is not null) + { + // The session picked had no tape; picked again, it shows the tape it has now, or still none. + _list.SelectedItem = again; + return; + } if ((pick ?? first) is not { } chosen) { _shown = null; @@ -595,14 +607,15 @@ public sealed class HaslerTapeWindow : Window _recorder.SelectedIndex = context.Recorder == RecorderKind.Electronic ? 1 : 0; } - /// A session with a black box and no tape: no tape of another session left beside it. - private void ShowNoTape() + /// A session with no tape, a black box at most: no tape of another session left beside it. + private void ShowNoTape(TapeSession session) { _shown = null; + _tapeless = session.StartedUtc; _view.Tape = null; _view.Mark = null; _cursor.Text = ""; - _summary.Text = App.Loc["HaslerSessionNoTape"]; + _summary.Text = App.Loc[session.BlackBoxes.Count > 0 ? "HaslerSessionNoTape" : "HaslerSessionEmpty"]; } private async Task ShowAsync(TapeFile file, bool scrollToEnd) @@ -615,6 +628,7 @@ public sealed class HaslerTapeWindow : Window var tape = await Task.Run(() => _tapes.Load(file)); bool another = file.Path != _shown?.Path; _shown = file; + _tapeless = null; if (tape is null) { _view.Tape = null; diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml index 4f33134..0bb1d32 100644 --- a/StarterNG/startercfg/lang/cz.xml +++ b/StarterNG/startercfg/lang/cz.xml @@ -854,6 +854,7 @@ Celá relace na mapě: jízda oproti AI, povely, návěstidla, kabina klikněte na pásku: černá skříňka v tom okamžiku Tato relace nemá pásku, jen černou skříňku. + Tato relace zatím nemá pásku ani černou skříňku. Ve skladu: {0} Vyberte soupravu s vozidly Úroveň jen pro tuto část grafiky diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml index 051a8f8..e0a4ba1 100644 --- a/StarterNG/startercfg/lang/en.xml +++ b/StarterNG/startercfg/lang/en.xml @@ -1083,6 +1083,7 @@ The whole session on a map: the driving against the AI, the commands, the signals, the cab click the tape: the black box at that moment This session has no tape, only the black box. + This session has no tape or black box yet. In the warehouse: {0} Pick a consist with vehicles Level for this part of the graphics only diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml index 9403a73..4c1a4dc 100644 --- a/StarterNG/startercfg/lang/hu.xml +++ b/StarterNG/startercfg/lang/hu.xml @@ -854,6 +854,7 @@ A teljes menet a térképen: vezetés az AI-hoz képest, parancsok, jelzők, vezetőfülke kattintson a szalagra: a fekete doboz abban a pillanatban Ebben a munkamenetben nincs szalag, csak a fekete doboz. + Ebben a munkamenetben még nincs se szalag, se fekete doboz. A raktárban: {0} Válassz járműveket tartalmazó szerelvényt Csak a grafika ezen részének szintje diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml index 82db58a..3713dd5 100644 --- a/StarterNG/startercfg/lang/pl.xml +++ b/StarterNG/startercfg/lang/pl.xml @@ -905,6 +905,7 @@ Cała sesja na mapie: jazda względem AI, komendy, sygnalizatory, kabina kliknij taśmę: czarna skrzynka w tym momencie W tej sesji nie ma taśmy, jest tylko czarna skrzynka. + W tej sesji nie ma jeszcze ani taśmy, ani czarnej skrzynki. W magazynie: {0} Wybierz skład z pojazdami Poziom tylko tej części grafiki diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml index 8f74f8a..c73f842 100644 --- a/StarterNG/startercfg/lang/ru.xml +++ b/StarterNG/startercfg/lang/ru.xml @@ -854,6 +854,7 @@ Вся сессия на карте: езда по сравнению с ИИ, команды, светофоры, кабина щёлкните по ленте: чёрный ящик в этот момент В этом сеансе нет ленты, только чёрный ящик. + В этом сеансе пока нет ни ленты, ни чёрного ящика. На складе: {0} Выберите состав с транспортом Уровень только для этой части графики