mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
feat: add ITextureSubstitutionProvider.InvalidatePaths()
This commit is contained in:
parent
24ad2d4c8b
commit
4c15df80b9
2 changed files with 54 additions and 10 deletions
|
|
@ -213,6 +213,39 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void InvalidatePaths(IEnumerable<string> paths)
|
||||||
|
{
|
||||||
|
lock (this.activeTextures)
|
||||||
|
{
|
||||||
|
foreach (var path in paths)
|
||||||
|
{
|
||||||
|
if (!this.activeTextures.TryGetValue(path, out var info) || info == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
info.Wrap = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
@ -263,16 +296,10 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
||||||
|
|
||||||
if (!this.im.IsReady)
|
if (!this.im.IsReady)
|
||||||
throw new InvalidOperationException("Cannot create textures before scene is ready");
|
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;
|
TextureWrap? wrap;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
namespace Dalamud.Plugin.Services;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Dalamud.Plugin.Services;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Service that grants you the ability to replace texture data that is to be loaded by Dalamud.
|
/// 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.
|
/// Event that will be called once Dalamud wants to load texture data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event TextureDataInterceptorDelegate? InterceptTexDataLoad;
|
public event TextureDataInterceptorDelegate? InterceptTexDataLoad;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a path that may be substituted by a subscriber to ITextureSubstitutionProvider.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="originalPath">The original path to substitute.</param>
|
||||||
|
/// <returns>The original path, if no subscriber is registered or there is no substitution, or the substituted path.</returns>
|
||||||
|
public string GetSubstitutedPath(string originalPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paths">The paths with a changed substitution status.</param>
|
||||||
|
public void InvalidatePaths(IEnumerable<string> paths);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue