Merge GetTexturePath implementations

This commit is contained in:
Jarrod Doyle 2024-08-25 10:43:17 +01:00
parent be205897bb
commit 85599b4069
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 20 additions and 25 deletions

View File

@ -133,28 +133,32 @@ public class ResourcePathManager
return null;
}
public string GetTexturePath(string textureName)
{
if (!_initialised) return null;
textureName = textureName.ToLower();
if (_omResources.texturePathMap.TryGetValue(textureName, out var path))
{
return path;
}
return null;
}
// TODO: OMs fail to find a path, but FMs using OM textures do find them
// The OMs still fail even if I put them in a folder with FMs that work=??
public string GetTexturePath(string campaignName, string textureName)
{
if (!_initialised) return null;
textureName = textureName.ToLower();
if (_fmResources.TryGetValue(campaignName, out var campaign) &&
campaign.texturePathMap.TryGetValue(textureName, out var path))
if (campaignName == null || campaignName == "")
{
return path;
if (_omResources.texturePathMap.TryGetValue(textureName, out var path))
{
return path;
}
}
else if (_fmResources.TryGetValue(campaignName, out var campaign))
{
if (campaign.texturePathMap.TryGetValue(textureName, out var fmPath))
{
return fmPath;
}
else if (_omResources.texturePathMap.TryGetValue(textureName, out var omPath))
{
return omPath;
}
}
return null;
}

View File

@ -29,16 +29,7 @@ public partial class TextureLoader
public bool Load(ResourcePathManager installManager, int id, string path)
{
var loaded = false;
string texPath;
if (_fmName != null)
{
texPath = installManager.GetTexturePath(_fmName, path);
texPath ??= installManager.GetTexturePath(path);
}
else
{
texPath = installManager.GetTexturePath(path);
}
string texPath = installManager.GetTexturePath(_fmName, path);
if (texPath != null)
{