Explain the greyed-out ready box and count cars in the depot

A disabled checkbox shows no tooltip, so the settings override that greys
out "ready to go" is now said under it. The consist vehicle count counted
units, so a multi-unit was one vehicle; it now counts cars like the stats bar.
This commit is contained in:
maj00r
2026-10-04 18:55:21 +02:00
parent 00a62ab568
commit 53fe9aa48c
3 changed files with 22 additions and 5 deletions

View File

@@ -21,6 +21,17 @@ public class ConsistTailTests
_consist = new Consist(_catalog, new VehicleInfo(_catalog, installation.Physics)); _consist = new Consist(_catalog, new VehicleInfo(_catalog, installation.Physics));
} }
[Fact]
public void The_vehicle_count_counts_cars_not_units()
{
Append("b111-01");
var pair = Append("b111-02");
pair.Cars.Add(pair.Cars[0].Clone());
Assert.Equal(2, _consist.Count);
Assert.Equal(3, _consist.VehicleCount);
}
[Fact] [Fact]
public void A_new_last_car_is_left_uncoupled_at_the_back() public void A_new_last_car_is_left_uncoupled_at_the_back()
{ {

View File

@@ -35,6 +35,9 @@ public sealed class Consist : IReadOnlyList<ConsistItem>
public int Count => _items.Count; public int Count => _items.Count;
/// <summary>Every vehicle, a multi-unit counted car by car - <see cref="Count"/> counts units.</summary>
public int VehicleCount => _items.Sum(i => i.Cars.Count);
public ConsistItem this[int index] public ConsistItem this[int index]
{ {
get => _items[index]; get => _items[index];

View File

@@ -568,7 +568,7 @@ public sealed class VehicleDetails
var count = new TextBlock var count = new TextBlock
{ {
Text = $"{App.Loc["VehicleCount"]}: {_consist.Count}", Text = $"{App.Loc["VehicleCount"]}: {_consist.VehicleCount}",
FontSize = 12, FontSize = 12,
Foreground = DimBrush, Foreground = DimBrush,
VerticalAlignment = VerticalAlignment.Center VerticalAlignment = VerticalAlignment.Center
@@ -593,9 +593,7 @@ public sealed class VehicleDetails
? over == ConsistReadyOverride.AlwaysReady ? over == ConsistReadyOverride.AlwaysReady
: trainset?.ReadyToGo ?? false : trainset?.ReadyToGo ?? false
}; };
ToolTip.SetTip(ready, overridden ToolTip.SetTip(ready, App.Loc["ConsistReadyDesc"]);
? App.Loc["ConsistReadyOverridden"]
: App.Loc["ConsistReadyDesc"]);
ready.IsCheckedChanged += (_, _) => ready.IsCheckedChanged += (_, _) =>
{ {
@@ -605,7 +603,12 @@ public sealed class VehicleDetails
_redraw(); _redraw();
}; };
return Row(content: ready); // A disabled box shows no tooltip, so why it is greyed out is said beside it.
if (!overridden)
return Row(content: ready);
var why = PanelNote(App.Loc["ConsistReadyOverridden"]);
why.Margin = new Thickness(0);
return Row(content: new StackPanel { Spacing = 2, Children = { ready, why } });
} }
private Button LoadToolButton(string text, Action onClick, bool secondary = false) private Button LoadToolButton(string text, Action onClick, bool secondary = false)