diff --git a/Dalamud/Interface/Internal/TextureManager.cs b/Dalamud/Interface/Internal/TextureManager.cs index 2f8ac27d9..4b2f1f362 100644 --- a/Dalamud/Interface/Internal/TextureManager.cs +++ b/Dalamud/Interface/Internal/TextureManager.cs @@ -83,6 +83,25 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP /// to render the icon. /// public TextureManagerTextureWrap? GetIcon(uint iconId, ITextureProvider.IconFlags flags = ITextureProvider.IconFlags.HiRes, ClientLanguage? language = null, bool keepAlive = false) + { + var path = this.GetIconPath(iconId, flags, language); + return path == null ? null : this.CreateWrap(path, keepAlive); + } + + /// + /// Get a path for a specific icon's .tex file. + /// + /// The ID of the icon to look up. + /// Options to be considered when loading the icon. + /// + /// The language to be considered when loading the icon, if the icon has versions for multiple languages. + /// If null, default to the game's current language. + /// + /// + /// Null, if the icon does not exist in the specified configuration, or the path to the texture's .tex file, + /// which can be loaded via IDataManager. + /// + public string? GetIconPath(uint iconId, ITextureProvider.IconFlags flags = ITextureProvider.IconFlags.HiRes, ClientLanguage? language = null) { var hiRes = flags.HasFlag(ITextureProvider.IconFlags.HiRes); @@ -92,7 +111,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP flags.HasFlag(ITextureProvider.IconFlags.ItemHighQuality) ? "hq/" : string.Empty, hiRes); if (this.dataManager.FileExists(path)) - return this.CreateWrap(path, keepAlive); + return path; language ??= this.startInfo.Language; var languageFolder = language switch @@ -110,7 +129,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP languageFolder, hiRes); if (this.dataManager.FileExists(path)) - return this.CreateWrap(path, keepAlive); + return path; if (hiRes) { @@ -120,7 +139,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP languageFolder, false); if (this.dataManager.FileExists(path)) - return this.CreateWrap(path, keepAlive); + return path; } // 4. Regular icon, without language, hi-res @@ -129,7 +148,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP null, hiRes); if (this.dataManager.FileExists(path)) - return this.CreateWrap(path, keepAlive); + return path; // 4. Regular icon, without language, no hi-res if (hiRes) @@ -139,7 +158,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP null, false); if (this.dataManager.FileExists(path)) - return this.CreateWrap(path, keepAlive); + return path; } return null; @@ -480,6 +499,10 @@ internal class TextureManagerPluginScoped : ITextureProvider, IServiceType, IDis return wrap; } + /// + public string? GetIconPath(uint iconId, ITextureProvider.IconFlags flags = ITextureProvider.IconFlags.HiRes, ClientLanguage? language = null) + => this.textureManager.GetIconPath(iconId, flags, language); + /// public IDalamudTextureWrap? GetTextureFromGame(string path, bool keepAlive = false) { diff --git a/Dalamud/Plugin/Services/ITextureProvider.cs b/Dalamud/Plugin/Services/ITextureProvider.cs index b2ffbb5cd..091b2ed67 100644 --- a/Dalamud/Plugin/Services/ITextureProvider.cs +++ b/Dalamud/Plugin/Services/ITextureProvider.cs @@ -52,6 +52,21 @@ public interface ITextureProvider /// public IDalamudTextureWrap? GetIcon(uint iconId, IconFlags flags = IconFlags.HiRes, ClientLanguage? language = null, bool keepAlive = false); + /// + /// Get a path for a specific icon's .tex file. + /// + /// The ID of the icon to look up. + /// Options to be considered when loading the icon. + /// + /// The language to be considered when loading the icon, if the icon has versions for multiple languages. + /// If null, default to the game's current language. + /// + /// + /// Null, if the icon does not exist in the specified configuration, or the path to the texture's .tex file, + /// which can be loaded via IDataManager. + /// + public string? GetIconPath(uint iconId, IconFlags flags = IconFlags.HiRes, ClientLanguage? language = null); + /// /// Get a texture handle for the texture at the specified path. /// You may only specify paths in the game's VFS.