Fix incorrect paths for textures relative to mission file

This commit is contained in:
Jarrod Doyle 2024-08-07 18:40:46 +01:00
parent 9d49b38bf2
commit aaf93477d0
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 6 additions and 2 deletions

View File

@ -371,6 +371,7 @@ public partial class Mission : Node3D
private void LoadTextures(TxList textureList) private void LoadTextures(TxList textureList)
{ {
// TODO: This has hardcoded .png extension and relies on you placing extracted and converted images in godot user directory // TODO: This has hardcoded .png extension and relies on you placing extracted and converted images in godot user directory
// TODO: Use PathJoin
var count = textureList.ItemCount; var count = textureList.ItemCount;
for (var i = 0; i < count; i++) for (var i = 0; i < count; i++)
{ {
@ -388,9 +389,11 @@ public partial class Mission : Node3D
} }
path += item.Name + ".png"; // Hardcoded extension! path += item.Name + ".png"; // Hardcoded extension!
if (File.Exists(FileName + path)) // TODO: It's case sensitive :)
var fmFamPath = Path.GetDirectoryName(FileName).PathJoin(path);
if (File.Exists(fmFamPath))
{ {
path = FileName + path; path = fmFamPath;
} }
else if (File.Exists(ProjectSettings.GlobalizePath($"user://textures{path}"))) else if (File.Exists(ProjectSettings.GlobalizePath($"user://textures{path}")))
{ {
@ -398,6 +401,7 @@ public partial class Mission : Node3D
} }
else else
{ {
GD.Print($"Failed to find texture: {path}");
path = "user://textures/jorge.png"; path = "user://textures/jorge.png";
} }