Loosely handle campaigns not having an obj folder when trying to get obj texture path

This commit is contained in:
Jarrod Doyle 2024-08-25 17:09:59 +01:00
parent 05e90c1a30
commit 1cfbd498c7
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 16 additions and 6 deletions

View File

@ -191,7 +191,7 @@ public class ResourcePathManager
} }
// TODO: Store these as part of the resources // TODO: Store these as part of the resources
public string GetObjectTexturePath(string campaignName, string textureName) public string GetObjectTexturePath(string campaignName, string modelName, string textureName)
{ {
var options = new EnumerationOptions var options = new EnumerationOptions
{ {
@ -211,11 +211,20 @@ public class ResourcePathManager
} }
else if (_fmResources.TryGetValue(campaignName, out var campaign)) else if (_fmResources.TryGetValue(campaignName, out var campaign))
{ {
var fmDir = Path.Join(_fmsDir, campaignName); // TODO: This is a fucking mess
var fmPaths = Directory.GetFiles(Path.Join(fmDir, "obj"), textureName, options); // Basically we need to handle when the campaign doesn't have a models folder lol
if (fmPaths.Length > 0) if (campaign.objectPathMap.TryGetValue(modelName, out var modelPath))
{ {
return fmPaths[0]; var dir = Path.GetDirectoryName(modelPath);
var fmPaths = Directory.GetFiles(dir, textureName, options);
if (fmPaths.Length > 0)
{
return fmPaths[0];
}
else if (omPaths.Length > 0)
{
return omPaths[0];
}
} }
else if (omPaths.Length > 0) else if (omPaths.Length > 0)
{ {

View File

@ -26,9 +26,10 @@ public static class ModelLoader
{ {
if (material.Type == 0) if (material.Type == 0)
{ {
var path = pathManager.GetObjectTexturePath(campaignName, material.Name); var path = pathManager.GetObjectTexturePath(campaignName, modelName, material.Name);
if (path == null) if (path == null)
{ {
// TODO: JORGE
GD.Print($"Failed to load model texture: {material.Name}"); GD.Print($"Failed to load model texture: {material.Name}");
continue; continue;
} }