Use the substitution provider for textures in the ULD Wrapper. (#1553)

This commit is contained in:
Ottermandias 2023-12-08 00:10:15 +01:00 committed by GitHub
parent 30c2872400
commit 6637bd8207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dalamud.Data;
using Dalamud.Interface.Internal;
using Dalamud.Utility;
using ImGuiScene;
using Lumina.Data.Files;
using Lumina.Data.Parsing.Uld;
@ -155,20 +155,27 @@ public class UldWrapper : IDisposable
// Try to load HD textures first.
var hrPath = texturePath.Replace(".tex", "_hr1.tex");
var substitution = Service<TextureManager>.Get();
hrPath = substitution.GetSubstitutedPath(hrPath);
var hd = true;
var file = this.data.GetFile<TexFile>(hrPath);
if (file == null)
var tex = Path.IsPathRooted(hrPath)
? this.data.GameData.GetFileFromDisk<TexFile>(hrPath)
: this.data.GetFile<TexFile>(hrPath);
if (tex == null)
{
hd = false;
file = this.data.GetFile<TexFile>(texturePath);
texturePath = substitution.GetSubstitutedPath(texturePath);
tex = Path.IsPathRooted(texturePath)
? this.data.GameData.GetFileFromDisk<TexFile>(texturePath)
: this.data.GetFile<TexFile>(texturePath);
// Neither texture could be loaded.
if (file == null)
if (tex == null)
{
return null;
}
}
return (id, file.Header.Width, file.Header.Height, hd, file.GetRgbaImageData());
return (id, tex.Header.Width, tex.Header.Height, hd, tex.GetRgbaImageData());
}
}