mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-12 00:58:12 +01:00
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
This commit is contained in:
@@ -66,6 +66,8 @@ public sealed class HaslerTapeWindow : Window
|
|||||||
private readonly Action<TapeSample> _picked;
|
private readonly Action<TapeSample> _picked;
|
||||||
|
|
||||||
private TapeFile? _shown;
|
private TapeFile? _shown;
|
||||||
|
/// <summary>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.</summary>
|
||||||
|
private DateTime? _tapeless;
|
||||||
private string? _followed;
|
private string? _followed;
|
||||||
private string _listed = "";
|
private string _listed = "";
|
||||||
private bool _running;
|
private bool _running;
|
||||||
@@ -139,7 +141,7 @@ public sealed class HaslerTapeWindow : Window
|
|||||||
if (file is null)
|
if (file is null)
|
||||||
{
|
{
|
||||||
if (session is not null)
|
if (session is not null)
|
||||||
ShowNoTape();
|
ShowNoTape(session);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (file == _shown)
|
if (file == _shown)
|
||||||
@@ -340,6 +342,7 @@ public sealed class HaslerTapeWindow : Window
|
|||||||
if (toDriven)
|
if (toDriven)
|
||||||
_followed = driven;
|
_followed = driven;
|
||||||
string? selected = toDriven && driven is not null ? driven : _shown?.Path;
|
string? selected = toDriven && driven is not null ? driven : _shown?.Path;
|
||||||
|
DateTime? tapeless = toDriven && driven is not null ? null : _tapeless;
|
||||||
FollowBlackBoxes(sessions);
|
FollowBlackBoxes(sessions);
|
||||||
|
|
||||||
foreach (var node in _list.Items.OfType<TreeViewItem>())
|
foreach (var node in _list.Items.OfType<TreeViewItem>())
|
||||||
@@ -347,10 +350,13 @@ public sealed class HaslerTapeWindow : Window
|
|||||||
_list.Items.Clear();
|
_list.Items.Clear();
|
||||||
|
|
||||||
(TreeViewItem Node, TreeViewItem Tape)? first = null, pick = null;
|
(TreeViewItem Node, TreeViewItem Tape)? first = null, pick = null;
|
||||||
|
TreeViewItem? again = null;
|
||||||
for (int i = 0; i < sessions.Count; i++)
|
for (int i = 0; i < sessions.Count; i++)
|
||||||
{
|
{
|
||||||
var node = SessionItem(sessions[i], _expanded.GetValueOrDefault(sessions[i].StartedUtc, i == 0));
|
var node = SessionItem(sessions[i], _expanded.GetValueOrDefault(sessions[i].StartedUtc, i == 0));
|
||||||
_list.Items.Add(node);
|
_list.Items.Add(node);
|
||||||
|
if (sessions[i].StartedUtc == tapeless)
|
||||||
|
again = node;
|
||||||
foreach (var tape in node.Items.OfType<TreeViewItem>().Where(item => item.Tag is TapeFile))
|
foreach (var tape in node.Items.OfType<TreeViewItem>().Where(item => item.Tag is TapeFile))
|
||||||
{
|
{
|
||||||
first ??= (node, tape);
|
first ??= (node, tape);
|
||||||
@@ -362,6 +368,12 @@ public sealed class HaslerTapeWindow : Window
|
|||||||
_empty.Text = string.Format(App.Loc["HaslerNoTapes"], _tapes.Folder);
|
_empty.Text = string.Format(App.Loc["HaslerNoTapes"], _tapes.Folder);
|
||||||
_empty.IsVisible = first is null;
|
_empty.IsVisible = first is null;
|
||||||
_scroll.IsVisible = first is not 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)
|
if ((pick ?? first) is not { } chosen)
|
||||||
{
|
{
|
||||||
_shown = null;
|
_shown = null;
|
||||||
@@ -595,14 +607,15 @@ public sealed class HaslerTapeWindow : Window
|
|||||||
_recorder.SelectedIndex = context.Recorder == RecorderKind.Electronic ? 1 : 0;
|
_recorder.SelectedIndex = context.Recorder == RecorderKind.Electronic ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>A session with a black box and no tape: no tape of another session left beside it.</summary>
|
/// <summary>A session with no tape, a black box at most: no tape of another session left beside it.</summary>
|
||||||
private void ShowNoTape()
|
private void ShowNoTape(TapeSession session)
|
||||||
{
|
{
|
||||||
_shown = null;
|
_shown = null;
|
||||||
|
_tapeless = session.StartedUtc;
|
||||||
_view.Tape = null;
|
_view.Tape = null;
|
||||||
_view.Mark = null;
|
_view.Mark = null;
|
||||||
_cursor.Text = "";
|
_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)
|
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));
|
var tape = await Task.Run(() => _tapes.Load(file));
|
||||||
bool another = file.Path != _shown?.Path;
|
bool another = file.Path != _shown?.Path;
|
||||||
_shown = file;
|
_shown = file;
|
||||||
|
_tapeless = null;
|
||||||
if (tape is null)
|
if (tape is null)
|
||||||
{
|
{
|
||||||
_view.Tape = null;
|
_view.Tape = null;
|
||||||
|
|||||||
@@ -854,6 +854,7 @@
|
|||||||
<String key="HaslerBlackBoxTip">Celá relace na mapě: jízda oproti AI, povely, návěstidla, kabina</String>
|
<String key="HaslerBlackBoxTip">Celá relace na mapě: jízda oproti AI, povely, návěstidla, kabina</String>
|
||||||
<String key="HaslerClickBlackBox">klikněte na pásku: černá skříňka v tom okamžiku</String>
|
<String key="HaslerClickBlackBox">klikněte na pásku: černá skříňka v tom okamžiku</String>
|
||||||
<String key="HaslerSessionNoTape">Tato relace nemá pásku, jen černou skříňku.</String>
|
<String key="HaslerSessionNoTape">Tato relace nemá pásku, jen černou skříňku.</String>
|
||||||
|
<String key="HaslerSessionEmpty">Tato relace zatím nemá pásku ani černou skříňku.</String>
|
||||||
<String key="WarehouseSaved">Ve skladu: {0}</String>
|
<String key="WarehouseSaved">Ve skladu: {0}</String>
|
||||||
<String key="WarehouseNothingToAdd">Vyberte soupravu s vozidly</String>
|
<String key="WarehouseNothingToAdd">Vyberte soupravu s vozidly</String>
|
||||||
<String key="GfxGroupLevelTip">Úroveň jen pro tuto část grafiky</String>
|
<String key="GfxGroupLevelTip">Úroveň jen pro tuto část grafiky</String>
|
||||||
|
|||||||
@@ -1083,6 +1083,7 @@
|
|||||||
<String key="HaslerBlackBoxTip">The whole session on a map: the driving against the AI, the commands, the signals, the cab</String>
|
<String key="HaslerBlackBoxTip">The whole session on a map: the driving against the AI, the commands, the signals, the cab</String>
|
||||||
<String key="HaslerClickBlackBox">click the tape: the black box at that moment</String>
|
<String key="HaslerClickBlackBox">click the tape: the black box at that moment</String>
|
||||||
<String key="HaslerSessionNoTape">This session has no tape, only the black box.</String>
|
<String key="HaslerSessionNoTape">This session has no tape, only the black box.</String>
|
||||||
|
<String key="HaslerSessionEmpty">This session has no tape or black box yet.</String>
|
||||||
<String key="WarehouseSaved">In the warehouse: {0}</String>
|
<String key="WarehouseSaved">In the warehouse: {0}</String>
|
||||||
<String key="WarehouseNothingToAdd">Pick a consist with vehicles</String>
|
<String key="WarehouseNothingToAdd">Pick a consist with vehicles</String>
|
||||||
<String key="GfxGroupLevelTip">Level for this part of the graphics only</String>
|
<String key="GfxGroupLevelTip">Level for this part of the graphics only</String>
|
||||||
|
|||||||
@@ -854,6 +854,7 @@
|
|||||||
<String key="HaslerBlackBoxTip">A teljes menet a térképen: vezetés az AI-hoz képest, parancsok, jelzők, vezetőfülke</String>
|
<String key="HaslerBlackBoxTip">A teljes menet a térképen: vezetés az AI-hoz képest, parancsok, jelzők, vezetőfülke</String>
|
||||||
<String key="HaslerClickBlackBox">kattintson a szalagra: a fekete doboz abban a pillanatban</String>
|
<String key="HaslerClickBlackBox">kattintson a szalagra: a fekete doboz abban a pillanatban</String>
|
||||||
<String key="HaslerSessionNoTape">Ebben a munkamenetben nincs szalag, csak a fekete doboz.</String>
|
<String key="HaslerSessionNoTape">Ebben a munkamenetben nincs szalag, csak a fekete doboz.</String>
|
||||||
|
<String key="HaslerSessionEmpty">Ebben a munkamenetben még nincs se szalag, se fekete doboz.</String>
|
||||||
<String key="WarehouseSaved">A raktárban: {0}</String>
|
<String key="WarehouseSaved">A raktárban: {0}</String>
|
||||||
<String key="WarehouseNothingToAdd">Válassz járműveket tartalmazó szerelvényt</String>
|
<String key="WarehouseNothingToAdd">Válassz járműveket tartalmazó szerelvényt</String>
|
||||||
<String key="GfxGroupLevelTip">Csak a grafika ezen részének szintje</String>
|
<String key="GfxGroupLevelTip">Csak a grafika ezen részének szintje</String>
|
||||||
|
|||||||
@@ -905,6 +905,7 @@
|
|||||||
<String key="HaslerBlackBoxTip">Cała sesja na mapie: jazda względem AI, komendy, sygnalizatory, kabina</String>
|
<String key="HaslerBlackBoxTip">Cała sesja na mapie: jazda względem AI, komendy, sygnalizatory, kabina</String>
|
||||||
<String key="HaslerClickBlackBox">kliknij taśmę: czarna skrzynka w tym momencie</String>
|
<String key="HaslerClickBlackBox">kliknij taśmę: czarna skrzynka w tym momencie</String>
|
||||||
<String key="HaslerSessionNoTape">W tej sesji nie ma taśmy, jest tylko czarna skrzynka.</String>
|
<String key="HaslerSessionNoTape">W tej sesji nie ma taśmy, jest tylko czarna skrzynka.</String>
|
||||||
|
<String key="HaslerSessionEmpty">W tej sesji nie ma jeszcze ani taśmy, ani czarnej skrzynki.</String>
|
||||||
<String key="WarehouseSaved">W magazynie: {0}</String>
|
<String key="WarehouseSaved">W magazynie: {0}</String>
|
||||||
<String key="WarehouseNothingToAdd">Wybierz skład z pojazdami</String>
|
<String key="WarehouseNothingToAdd">Wybierz skład z pojazdami</String>
|
||||||
<String key="GfxGroupLevelTip">Poziom tylko tej części grafiki</String>
|
<String key="GfxGroupLevelTip">Poziom tylko tej części grafiki</String>
|
||||||
|
|||||||
@@ -854,6 +854,7 @@
|
|||||||
<String key="HaslerBlackBoxTip">Вся сессия на карте: езда по сравнению с ИИ, команды, светофоры, кабина</String>
|
<String key="HaslerBlackBoxTip">Вся сессия на карте: езда по сравнению с ИИ, команды, светофоры, кабина</String>
|
||||||
<String key="HaslerClickBlackBox">щёлкните по ленте: чёрный ящик в этот момент</String>
|
<String key="HaslerClickBlackBox">щёлкните по ленте: чёрный ящик в этот момент</String>
|
||||||
<String key="HaslerSessionNoTape">В этом сеансе нет ленты, только чёрный ящик.</String>
|
<String key="HaslerSessionNoTape">В этом сеансе нет ленты, только чёрный ящик.</String>
|
||||||
|
<String key="HaslerSessionEmpty">В этом сеансе пока нет ни ленты, ни чёрного ящика.</String>
|
||||||
<String key="WarehouseSaved">На складе: {0}</String>
|
<String key="WarehouseSaved">На складе: {0}</String>
|
||||||
<String key="WarehouseNothingToAdd">Выберите состав с транспортом</String>
|
<String key="WarehouseNothingToAdd">Выберите состав с транспортом</String>
|
||||||
<String key="GfxGroupLevelTip">Уровень только для этой части графики</String>
|
<String key="GfxGroupLevelTip">Уровень только для этой части графики</String>
|
||||||
|
|||||||
Reference in New Issue
Block a user