mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-21 16:09:19 +01:00
feat: add ITextureProvider.GetIconPath() function to allow for icon path lookups by plugins
This commit is contained in:
parent
389ff91097
commit
8df154c1a9
2 changed files with 43 additions and 5 deletions
|
|
@ -83,6 +83,25 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
||||||
/// to render the icon.
|
/// to render the icon.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public TextureManagerTextureWrap? GetIcon(uint iconId, ITextureProvider.IconFlags flags = ITextureProvider.IconFlags.HiRes, ClientLanguage? language = null, bool keepAlive = false)
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a path for a specific icon's .tex file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iconId">The ID of the icon to look up.</param>
|
||||||
|
/// <param name="flags">Options to be considered when loading the icon.</param>
|
||||||
|
/// <param name="language">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
|
public string? GetIconPath(uint iconId, ITextureProvider.IconFlags flags = ITextureProvider.IconFlags.HiRes, ClientLanguage? language = null)
|
||||||
{
|
{
|
||||||
var hiRes = flags.HasFlag(ITextureProvider.IconFlags.HiRes);
|
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,
|
flags.HasFlag(ITextureProvider.IconFlags.ItemHighQuality) ? "hq/" : string.Empty,
|
||||||
hiRes);
|
hiRes);
|
||||||
if (this.dataManager.FileExists(path))
|
if (this.dataManager.FileExists(path))
|
||||||
return this.CreateWrap(path, keepAlive);
|
return path;
|
||||||
|
|
||||||
language ??= this.startInfo.Language;
|
language ??= this.startInfo.Language;
|
||||||
var languageFolder = language switch
|
var languageFolder = language switch
|
||||||
|
|
@ -110,7 +129,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
||||||
languageFolder,
|
languageFolder,
|
||||||
hiRes);
|
hiRes);
|
||||||
if (this.dataManager.FileExists(path))
|
if (this.dataManager.FileExists(path))
|
||||||
return this.CreateWrap(path, keepAlive);
|
return path;
|
||||||
|
|
||||||
if (hiRes)
|
if (hiRes)
|
||||||
{
|
{
|
||||||
|
|
@ -120,7 +139,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
||||||
languageFolder,
|
languageFolder,
|
||||||
false);
|
false);
|
||||||
if (this.dataManager.FileExists(path))
|
if (this.dataManager.FileExists(path))
|
||||||
return this.CreateWrap(path, keepAlive);
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Regular icon, without language, hi-res
|
// 4. Regular icon, without language, hi-res
|
||||||
|
|
@ -129,7 +148,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
||||||
null,
|
null,
|
||||||
hiRes);
|
hiRes);
|
||||||
if (this.dataManager.FileExists(path))
|
if (this.dataManager.FileExists(path))
|
||||||
return this.CreateWrap(path, keepAlive);
|
return path;
|
||||||
|
|
||||||
// 4. Regular icon, without language, no hi-res
|
// 4. Regular icon, without language, no hi-res
|
||||||
if (hiRes)
|
if (hiRes)
|
||||||
|
|
@ -139,7 +158,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
||||||
null,
|
null,
|
||||||
false);
|
false);
|
||||||
if (this.dataManager.FileExists(path))
|
if (this.dataManager.FileExists(path))
|
||||||
return this.CreateWrap(path, keepAlive);
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -480,6 +499,10 @@ internal class TextureManagerPluginScoped : ITextureProvider, IServiceType, IDis
|
||||||
return wrap;
|
return wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string? GetIconPath(uint iconId, ITextureProvider.IconFlags flags = ITextureProvider.IconFlags.HiRes, ClientLanguage? language = null)
|
||||||
|
=> this.textureManager.GetIconPath(iconId, flags, language);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IDalamudTextureWrap? GetTextureFromGame(string path, bool keepAlive = false)
|
public IDalamudTextureWrap? GetTextureFromGame(string path, bool keepAlive = false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,21 @@ public interface ITextureProvider
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public IDalamudTextureWrap? GetIcon(uint iconId, IconFlags flags = IconFlags.HiRes, ClientLanguage? language = null, bool keepAlive = false);
|
public IDalamudTextureWrap? GetIcon(uint iconId, IconFlags flags = IconFlags.HiRes, ClientLanguage? language = null, bool keepAlive = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a path for a specific icon's .tex file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iconId">The ID of the icon to look up.</param>
|
||||||
|
/// <param name="flags">Options to be considered when loading the icon.</param>
|
||||||
|
/// <param name="language">
|
||||||
|
/// 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.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// 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.
|
||||||
|
/// </returns>
|
||||||
|
public string? GetIconPath(uint iconId, IconFlags flags = IconFlags.HiRes, ClientLanguage? language = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a texture handle for the texture at the specified path.
|
/// Get a texture handle for the texture at the specified path.
|
||||||
/// You may only specify paths in the game's VFS.
|
/// You may only specify paths in the game's VFS.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue