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.
This commit is contained in:
maj00r
2026-09-04 22:29:04 +02:00
parent df21ec104f
commit b9f455e33d
4 changed files with 33 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -49,6 +49,8 @@ public sealed class VehicleBrowser
public VehicleTexture? Selected { get; private set; }
public Action<VehicleTexture>? 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
{

View File

@@ -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);