Let the simulator be picked from outside the installation

A build tree kept beside the data can be chosen in the settings, and when no
simulator is found the starter asks for one instead of calling the
installation broken. The simulator now runs in the installation, not in the
folder of its binary, and a binary for the other system is no longer refused.
This commit is contained in:
maj00r
2026-10-04 13:27:28 +02:00
parent 2b3c46938c
commit 3083523ceb
17 changed files with 320 additions and 49 deletions

View File

@@ -199,10 +199,10 @@ public static class TrainsetDisplay
return p.LoadAccepted.Contains(loadType, StringComparison.OrdinalIgnoreCase);
}
public static string? UniquifyForLaunch(Trainset trainset, Scenery scenery, string? startName)
public static string? UniquifyForLaunch(Trainset trainset, Scenery scenery, string? startName,
VehicleCatalog db)
{
var used = CollectNames(scenery);
var db = AppServices.Current.Library.Vehicles;
bool mu = trainset.Vehicles.Any(v =>
{
@@ -221,18 +221,18 @@ public static class TrainsetDisplay
if (mu)
{
foreach (var v in trainset.Vehicles)
Rename(v, used);
Rename(v, used, db);
return target?.Name;
}
if (target != null)
Rename(target, used);
Rename(target, used, db);
return target?.Name;
}
public static string PreferredBaseName(Dynamic v)
public static string PreferredBaseName(Dynamic v, VehicleCatalog db)
{
var tex = AppServices.Current.Library.Vehicles.TextureForSkin(v.SkinFile);
var tex = db.TextureForSkin(v.SkinFile);
if (tex != null)
{
@@ -294,11 +294,11 @@ public static class TrainsetDisplay
return (n, "");
}
private static void Rename(Dynamic v, HashSet<string> used)
private static void Rename(Dynamic v, HashSet<string> used, VehicleCatalog db)
{
var (_, number) = SplitWagonNumber(v.Name);
if (!string.IsNullOrEmpty(v.Name))
used.Remove(v.Name!);
v.Name = EnsureUnique(PreferredBaseName(v), used) + number;
v.Name = EnsureUnique(PreferredBaseName(v, db), used) + number;
}
}