From c072898e4f89f1133e8eb5793a612589fa6a517f Mon Sep 17 00:00:00 2001 From: maj00r Date: Fri, 4 Sep 2026 23:04:09 +0200 Subject: [PATCH] Depot: per-vehicle wagon number, model path, activation after removal The number editor was pinned to the unit's first car, so every vehicle in a multiple unit shared one number. Removing a vehicle only moved the highlight, leaving the starting vehicle and the panels on the deleted one. Drops the tab strip around the single configuration panel and shortens the consist row when the thumbnails are small. --- StarterNG/Views/Depot.axaml | 17 +++++++---------- StarterNG/Views/Depot.axaml.cs | 21 +++++++++++++++++++++ StarterNG/Views/Depot/VehicleBrowser.cs | 1 + StarterNG/Views/Depot/VehicleCards.cs | 7 +++++++ StarterNG/Views/Depot/VehicleDetails.cs | 8 +++++--- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/StarterNG/Views/Depot.axaml b/StarterNG/Views/Depot.axaml index 9c9c923..2990ac0 100644 --- a/StarterNG/Views/Depot.axaml +++ b/StarterNG/Views/Depot.axaml @@ -10,7 +10,7 @@ x:Class="StarterNG.Views.Depot"> - + @@ -23,7 +23,7 @@ cap fits the seven lines of the texture tab. --> - + @@ -127,7 +127,8 @@ + the consist. No tab strip: it was a single tab naming the only thing + the column could hold. --> - - - - - - - + + + diff --git a/StarterNG/Views/Depot.axaml.cs b/StarterNG/Views/Depot.axaml.cs index f703b78..ffce1a8 100644 --- a/StarterNG/Views/Depot.axaml.cs +++ b/StarterNG/Views/Depot.axaml.cs @@ -147,6 +147,19 @@ public partial class Depot : UserControl private void VehicleListBox_OnPointerPressed(object? sender, PointerPressedEventArgs e) => _drag.VehicleListPressed(sender, e); + /// + /// Floor of the consist row with the small thumbnails, one thumbnail height + /// below the roomy one. + /// + private const double SmallConsistRowHeight = 106; + + private const double LargeConsistRowHeight = 140; + + private void SyncConsistRowHeight() => + depotGrid.RowDefinitions[2].MinHeight = AppServices.Current.Settings.LargeThumbnails + ? LargeConsistRowHeight + : SmallConsistRowHeight; + private Dynamic NewVehicle(VehicleTexture texture) => _consist.MakeDynamic(texture, _listScenery ?? AppServices.Current.State.CurrentScenery); @@ -177,6 +190,7 @@ public partial class Depot : UserControl private void RebuildConsist() { + SyncConsistRowHeight(); consistStack.Children.Clear(); _cards.Forget(); _drag.Reset(); @@ -192,6 +206,13 @@ public partial class Depot : UserControl } emptyHint.IsVisible = _consist.Count == 0; + + // A selection the consist moved on its own - after a removal, say - is only + // highlighted; activating it runs what a click would have run. + if (_consist.Selected is { } moved && + (_consist.SelectedCar is null || !moved.Cars.Contains(_consist.SelectedCar))) + _cards.Activate(moved); + _details.Refresh(); UpdateTrainStats(); WriteBackToScenery(); diff --git a/StarterNG/Views/Depot/VehicleBrowser.cs b/StarterNG/Views/Depot/VehicleBrowser.cs index 1fc4c2a..bcecf32 100644 --- a/StarterNG/Views/Depot/VehicleBrowser.cs +++ b/StarterNG/Views/Depot/VehicleBrowser.cs @@ -445,6 +445,7 @@ public sealed class VehicleBrowser } Reading(App.Loc["TextureInfo"], Consist.Base(texture.Skinfile)); + Reading(App.Loc["Model"], texture.Directory + texture.Model); if (texture.Meta is { } meta) { diff --git a/StarterNG/Views/Depot/VehicleCards.cs b/StarterNG/Views/Depot/VehicleCards.cs index 231c59c..00a2701 100644 --- a/StarterNG/Views/Depot/VehicleCards.cs +++ b/StarterNG/Views/Depot/VehicleCards.cs @@ -234,6 +234,13 @@ public sealed class VehicleCards /// Selects an item without going through a redraw. picks the /// active member of a multi-vehicle unit; null keeps the current one when possible. /// + /// + /// Gives an item the selection a click would give it. Removing a vehicle only + /// moves the highlight, which left the starting vehicle, the detail panels and + /// the browser pointing at what was deleted. + /// + public void Activate(ConsistItem item) => Select(item, null); + private void Select(ConsistItem item, Dynamic? car) { var target = car ?? (ReferenceEquals(_consist.Selected, item) diff --git a/StarterNG/Views/Depot/VehicleDetails.cs b/StarterNG/Views/Depot/VehicleDetails.cs index 5b8f0c9..97d5c03 100644 --- a/StarterNG/Views/Depot/VehicleDetails.cs +++ b/StarterNG/Views/Depot/VehicleDetails.cs @@ -304,19 +304,21 @@ public sealed class VehicleDetails if (IsPassengerVehicle(item)) { - var lead = item.Cars[0]; + // The number rides in each vehicle's own name, so it belongs to the + // member the user picked inside the unit, not to its first car. + var numbered = _consist.ActiveCar(item); var numBox = new NumericUpDown { FontSize = 12, Minimum = 0, Maximum = 99999, Increment = 1, - Value = Consist.GetWagonNumber(lead), + Value = Consist.GetWagonNumber(numbered), FormatString = "0" }; numBox.ValueChanged += (_, _) => { - _consist.SetWagonNumber(lead, (int)(numBox.Value ?? 0)); + _consist.SetWagonNumber(numbered, (int)(numBox.Value ?? 0)); _redraw(); }; rows.Children.Add(Row(App.Loc["WagonNumber"], numBox));