Skip to content

Commit

Permalink
Refactor consist loader in launcher to remove annoying startup except…
Browse files Browse the repository at this point in the history
…ions.
  • Loading branch information
YoRyan committed Jul 15, 2020
1 parent 55d874a commit 4084c75
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Source/ORTS.Menu/Consists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,33 @@ internal Locomotive(string filePath)
}
else if (File.Exists(filePath))
{
var showInList = true;
EngineFile engFile;
try
{
var engFile = new EngineFile(filePath);
showInList = !string.IsNullOrEmpty(engFile.CabViewFile);
Name = engFile.Name.Trim();
Description = engFile.Description.Trim();
engFile = new EngineFile(filePath);
}
catch
{
Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
Name = $"<{catalog.GetString("load error:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";
engFile = null;
}
if (engFile != null)
{
bool showInList = !string.IsNullOrEmpty(engFile.CabViewFile);
if (!showInList)
throw new InvalidDataException(catalog.GetStringFmt("Locomotive '{0}' is excluded.", filePath));

string name = (engFile.Name ?? "").Trim();
Name = name != "" ? name : $"<{catalog.GetString("unnamed:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";

string description = (engFile.Description ?? "").Trim();
if (description != "")
Description = description;
}
if (!showInList) throw new InvalidDataException(catalog.GetStringFmt("Locomotive '{0}' is excluded.", filePath));
if (string.IsNullOrEmpty(Name)) Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
if (string.IsNullOrEmpty(Description)) Description = null;
}
else
{
Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
Name = $"<{catalog.GetString("missing:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";
}
FilePath = filePath;
}
Expand Down

0 comments on commit 4084c75

Please sign in to comment.