Move the battery option to the depot as a consist property

It was a global preference that rewrote the trainset speed at launch, while what
it really sets is whether this consist starts prepared or cold. Now a checkbox in
the consist-scope section, acting on the consist being edited.
This commit is contained in:
maj00r
2026-09-04 23:17:17 +02:00
parent 1939493b47
commit cef00c4e3c
13 changed files with 115 additions and 55 deletions

View File

@@ -555,7 +555,7 @@ public sealed class VehicleDetails
if (_consist.Count == 0)
return;
var buttons = Stack(
var tools = Stack(
LoadToolButton(App.Loc["ConsistRandomType"],
() => { _cargo.RandomTypes(_consist); _redraw(); }, secondary: true),
LoadToolButton(App.Loc["ConsistMaxAmount"],
@@ -563,6 +563,8 @@ public sealed class VehicleDetails
LoadToolButton(App.Loc["ConsistRandomAmount"],
() => { _cargo.RandomAmounts(_consist); _redraw(); }, secondary: true));
var buttons = Stack(ReadyToGoRow(), tools);
var count = new TextBlock
{
Text = $"{App.Loc["VehicleCount"]}: {_consist.Count}",
@@ -574,6 +576,29 @@ public sealed class VehicleDetails
loadsPanel.Children.Add(Section(App.Loc["ConsistLoadTools"], buttons, count));
}
private Control ReadyToGoRow()
{
var trainset = _consist.EditingTrainset;
var ready = new CheckBox
{
Content = App.Loc["ConsistReady"],
FontSize = 12,
IsEnabled = trainset is not null,
IsChecked = trainset?.ReadyToGo ?? false
};
ToolTip.SetTip(ready, App.Loc["ConsistReadyDesc"]);
ready.IsCheckedChanged += (_, _) =>
{
if (trainset is null)
return;
trainset.ReadyToGo = ready.IsChecked == true;
_redraw();
};
return Row(content: ready);
}
private Button LoadToolButton(string text, Action onClick, bool secondary = false)
{
var b = new Button