From b9f455e33de2d79e0ea691200c34348a69f23652 Mon Sep 17 00:00:00 2001 From: maj00r Date: Fri, 4 Sep 2026 22:29:04 +0200 Subject: [PATCH] Show vehicle and texture info when a browser entry is picked The General and About texture tabs only ever described the selected consist car, so clicking a vehicle in the list told the user nothing about it. --- StarterNG/Domain/VehicleInfo.cs | 4 ++++ StarterNG/Views/Depot.axaml.cs | 2 ++ StarterNG/Views/Depot/VehicleBrowser.cs | 7 +++++++ StarterNG/Views/Depot/VehicleDetails.cs | 20 ++++++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/StarterNG/Domain/VehicleInfo.cs b/StarterNG/Domain/VehicleInfo.cs index d83e68d..1193e58 100644 --- a/StarterNG/Domain/VehicleInfo.cs +++ b/StarterNG/Domain/VehicleInfo.cs @@ -22,6 +22,10 @@ public sealed class VehicleInfo public string? CategoryOf(Dynamic car) => TextureFor(car) is { } t ? CategoryOf(t) : null; + public VehiclePhysics? PhysicsFor(VehicleTexture texture) => + AppServices.Current.Physics.For(texture.Directory, texture.Model) + ?? AppServices.Current.Physics.For(texture.Directory, texture.Skinfile); + public VehiclePhysics? PhysicsFor(Dynamic car) { string? dbModel = TextureFor(car)?.Model; diff --git a/StarterNG/Views/Depot.axaml.cs b/StarterNG/Views/Depot.axaml.cs index 2bf6957..f703b78 100644 --- a/StarterNG/Views/Depot.axaml.cs +++ b/StarterNG/Views/Depot.axaml.cs @@ -89,6 +89,8 @@ public partial class Depot : UserControl _db, _info, _consist, _cargo, _hand, RebuildConsist, _cards.RefreshMemberChrome, _browser.ShowTextureInfo); + _browser.TextureSelected = _details.ShowTexture; + Dispatcher.UIThread.Post(() => { hideArchivalCheck.IsChecked = AppServices.Current.Settings.HideArchivalVehicles; diff --git a/StarterNG/Views/Depot/VehicleBrowser.cs b/StarterNG/Views/Depot/VehicleBrowser.cs index e67c8b2..1fc4c2a 100644 --- a/StarterNG/Views/Depot/VehicleBrowser.cs +++ b/StarterNG/Views/Depot/VehicleBrowser.cs @@ -49,6 +49,8 @@ public sealed class VehicleBrowser public VehicleTexture? Selected { get; private set; } + public Action? TextureSelected { get; set; } + private bool _suppress; private bool _syncingCombos; @@ -342,6 +344,11 @@ public sealed class VehicleBrowser miniPreview.Source = _minis.Get(_db.ResolveMiniName(texture), MiniPreviewHeight); addVehicleButton.IsEnabled = true; SyncCombosTo(texture); + + // Clicking a card in the consist also selects its texture here. The + // detail panels then belong to that car, not to the catalogue entry. + if (!_syncingCombos) + TextureSelected?.Invoke(texture); } else { diff --git a/StarterNG/Views/Depot/VehicleDetails.cs b/StarterNG/Views/Depot/VehicleDetails.cs index e420df5..5b8f0c9 100644 --- a/StarterNG/Views/Depot/VehicleDetails.cs +++ b/StarterNG/Views/Depot/VehicleDetails.cs @@ -122,6 +122,26 @@ public sealed class VehicleDetails AddConsistLoadSection(); } + public void ShowTexture(VehicleTexture texture) + { + generalPanel.Children.Clear(); + consistTexturePanel.Children.Clear(); + + var inv = CultureInfo.InvariantCulture; + var physics = _info.PhysicsFor(texture); + + generalPanel.Children.Add(Reading($"{App.Loc["Length"]} [m]", + physics?.Length.ToString("0.##", inv))); + generalPanel.Children.Add(Reading($"{App.Loc["Mass"]} [t]", + physics is null ? null : (physics.Mass / 1000.0).ToString("0.#", inv))); + generalPanel.Children.Add(Reading($"{App.Loc["VMax"]} [km/h]", + physics?.VMax.ToString("0", inv))); + generalPanel.Children.Add(Reading(App.Loc["Model"], texture.Model)); + generalPanel.Children.Add(Reading(App.Loc["Texture"], texture.Skinfile)); + + _showTextureInfo(texture, consistTexturePanel); + } + private void BuildGeneralInfo(ConsistItem item) { var car = _consist.ActiveCar(item);