diff --git a/Dalamud/Interface/Internal/TextureManager.cs b/Dalamud/Interface/Internal/TextureManager.cs
index 905cac55a..ad7c0f2f8 100644
--- a/Dalamud/Interface/Internal/TextureManager.cs
+++ b/Dalamud/Interface/Internal/TextureManager.cs
@@ -213,6 +213,39 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
#pragma warning restore CS0618
}
+ ///
+ public string GetSubstitutedPath(string originalPath)
+ {
+ if (this.InterceptTexDataLoad == null)
+ return originalPath;
+
+ string? interceptPath = null;
+ this.InterceptTexDataLoad.Invoke(originalPath, ref interceptPath);
+
+ if (interceptPath != null)
+ {
+ Log.Verbose("Intercept: {OriginalPath} => {ReplacePath}", originalPath, interceptPath);
+ return interceptPath;
+ }
+
+ return originalPath;
+ }
+
+ ///
+ public void InvalidatePaths(IEnumerable paths)
+ {
+ lock (this.activeTextures)
+ {
+ foreach (var path in paths)
+ {
+ if (!this.activeTextures.TryGetValue(path, out var info) || info == null)
+ continue;
+
+ info.Wrap = null;
+ }
+ }
+ }
+
///
public void Dispose()
{
@@ -263,16 +296,10 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
if (!this.im.IsReady)
throw new InvalidOperationException("Cannot create textures before scene is ready");
-
- string? interceptPath = null;
- this.InterceptTexDataLoad?.Invoke(path, ref interceptPath);
-
- if (interceptPath != null)
- {
- Log.Verbose("Intercept: {OriginalPath} => {ReplacePath}", path, interceptPath);
- path = interceptPath;
- }
+ // Substitute the path here for loading, instead of when getting the respective TextureInfo
+ path = this.GetSubstitutedPath(path);
+
TextureWrap? wrap;
try
{
diff --git a/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs b/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs
index 90be71adb..3ddd7d13e 100644
--- a/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs
+++ b/Dalamud/Plugin/Services/ITextureSubstitutionProvider.cs
@@ -1,4 +1,6 @@
-namespace Dalamud.Plugin.Services;
+using System.Collections.Generic;
+
+namespace Dalamud.Plugin.Services;
///
/// Service that grants you the ability to replace texture data that is to be loaded by Dalamud.
@@ -17,4 +19,19 @@ public interface ITextureSubstitutionProvider
/// Event that will be called once Dalamud wants to load texture data.
///
public event TextureDataInterceptorDelegate? InterceptTexDataLoad;
+
+ ///
+ /// Get a path that may be substituted by a subscriber to ITextureSubstitutionProvider.
+ ///
+ /// The original path to substitute.
+ /// The original path, if no subscriber is registered or there is no substitution, or the substituted path.
+ public string GetSubstitutedPath(string originalPath);
+
+ ///
+ /// Notify Dalamud about substitution status for files at the specified VFS paths changing.
+ /// You should call this with all paths that were either previously substituted and are no longer,
+ /// and paths that are newly substituted.
+ ///
+ /// The paths with a changed substitution status.
+ public void InvalidatePaths(IEnumerable paths);
}