diff --git a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs index 92152b1fb..156ffa56f 100644 --- a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs +++ b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs @@ -45,6 +45,10 @@ ISharedImmediateTexture ITextureProvider.GetFromFile(string path) => ISharedImmediateTexture ITextureProvider.GetFromFile(FileInfo file) => this.Shared.GetFromFile(file); + /// + public ISharedImmediateTexture GetFromFileAbsolute(string fullPath) => + this.Shared.GetFromFileAbsolute(fullPath); + /// ISharedImmediateTexture ITextureProvider.GetFromManifestResource(Assembly assembly, string name) => this.Shared.GetFromManifestResource(assembly, name); @@ -141,7 +145,12 @@ public SharedImmediateTexture.PureImpl GetFromFile(string path) => /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public SharedImmediateTexture.PureImpl GetFromFile(FileInfo file) => - this.fileDict.GetOrAdd(file.FullName, FileSystemSharedImmediateTexture.CreatePlaceholder) + this.GetFromFileAbsolute(file.FullName); + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public SharedImmediateTexture.PureImpl GetFromFileAbsolute(string fullPath) => + this.fileDict.GetOrAdd(fullPath, FileSystemSharedImmediateTexture.CreatePlaceholder) .PublicUseInstance; /// diff --git a/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs b/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs index 27f97168e..68e2dde47 100644 --- a/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs +++ b/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs @@ -313,6 +313,14 @@ public ISharedImmediateTexture GetFromFile(FileInfo file) return shared; } + /// + public ISharedImmediateTexture GetFromFileAbsolute(string fullPath) + { + var shared = this.ManagerOrThrow.Shared.GetFromFileAbsolute(fullPath); + shared.AddOwnerPlugin(this.plugin); + return shared; + } + /// public ISharedImmediateTexture GetFromManifestResource(Assembly assembly, string name) { diff --git a/Dalamud/Plugin/Services/ITextureProvider.cs b/Dalamud/Plugin/Services/ITextureProvider.cs index d75899bd4..d914b1091 100644 --- a/Dalamud/Plugin/Services/ITextureProvider.cs +++ b/Dalamud/Plugin/Services/ITextureProvider.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; @@ -232,6 +232,15 @@ Task CreateFromTexFileAsync( /// ISharedImmediateTexture GetFromFile(FileInfo file); + /// Gets a shared texture corresponding to the given file on the filesystem. + /// The file on the filesystem to load. Requires a full path. + /// The shared texture that you may use to obtain the loaded texture wrap and load states. + /// + /// This function does not throw exceptions. + /// Caching the returned object is not recommended. Performance benefit will be minimal. + /// + ISharedImmediateTexture GetFromFileAbsolute(string fullPath); + /// Gets a shared texture corresponding to the given file of the assembly manifest resources. /// The assembly containing manifest resources. /// The case-sensitive name of the manifest resource being requested.