fix: open a scenery's attachments whatever the case of their names

A //$f attachment is looked up from the game folder through the new
AttachmentLocator, so on Linux its button is enabled and opens the file
when the scenery names it in other letter case or with backslashes.
This commit is contained in:
maj00r
2026-11-13 16:07:05 +01:00
parent 6279228a7d
commit 290b753f40
4 changed files with 55 additions and 7 deletions

View File

@@ -492,20 +492,18 @@ public partial class Scenarios : UserControl
btn.Classes.Add("Flat");
ToolTip.SetTip(btn, att.FilePath);
// A button that does nothing is no way to say the file is not there.
btn.IsEnabled = File.Exists(Path.GetFullPath(att.FilePath));
btn.IsEnabled = AppServices.Current.Attachments.Resolve(att) is not null;
ToolTip.SetShowOnDisabled(btn, true);
btn.Click += (_, _) => OpenAttachment(att.FilePath);
btn.Click += (_, _) => OpenAttachment(att);
attachmentsPanel.Children.Add(btn);
}
}
private static void OpenAttachment(string relativePath)
private static void OpenAttachment(SceneryAttachment attachment)
{
string full = Path.GetFullPath(relativePath);
if (!File.Exists(full))
full = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), relativePath));
if (!File.Exists(full))
if (AppServices.Current.Attachments.Resolve(attachment) is not { } found)
return;
string full = Path.GetFullPath(found);
try
{
Process.Start(new ProcessStartInfo(full) { UseShellExecute = true });