diff --git a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs
index d6c2fb346..e437b6c28 100644
--- a/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs
+++ b/Dalamud/Interface/Textures/Internal/TextureManager.SharedTextures.cs
@@ -19,6 +19,20 @@ internal sealed partial class TextureManager
ISharedImmediateTexture ITextureProvider.GetFromGameIcon(in GameIconLookup lookup) =>
this.Shared.GetFromGameIcon(lookup);
+ ///
+ bool ITextureProvider.TryGetFromGameIcon(
+ in GameIconLookup lookup, [NotNullWhen(true)] out ISharedImmediateTexture? texture)
+ {
+ if (this.Shared.TryGetFromGameIcon(lookup, out var pureImpl))
+ {
+ texture = pureImpl;
+ return true;
+ }
+
+ texture = null;
+ return false;
+ }
+
///
ISharedImmediateTexture ITextureProvider.GetFromGame(string path) =>
this.Shared.GetFromGame(path);
@@ -94,6 +108,24 @@ internal sealed partial class TextureManager
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public SharedImmediateTexture.PureImpl GetFromGameIcon(in GameIconLookup lookup) =>
this.GetFromGame(this.lookupCache.GetOrAdd(lookup, this.GetIconPathByValue));
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public bool TryGetFromGameIcon(in GameIconLookup lookup, [NotNullWhen(true)] out SharedImmediateTexture.PureImpl? texture)
+ {
+ texture = null;
+
+ if (!this.lookupCache.TryGet(lookup, out var path))
+ {
+ if (!this.textureManager.TryGetIconPath(lookup, out path))
+ return false;
+
+ this.lookupCache.AddOrUpdate(lookup, path);
+ }
+
+ texture = this.GetFromGame(path);
+ return texture != null;
+ }
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs b/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs
index 9107754a3..27f97168e 100644
--- a/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs
+++ b/Dalamud/Interface/Textures/Internal/TextureManagerPluginScoped.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -274,6 +275,20 @@ internal sealed class TextureManagerPluginScoped
return shared;
}
+ ///
+ public bool TryGetFromGameIcon(in GameIconLookup lookup, [NotNullWhen(true)] out ISharedImmediateTexture? texture)
+ {
+ if (this.ManagerOrThrow.Shared.TryGetFromGameIcon(lookup, out var shared))
+ {
+ shared.AddOwnerPlugin(this.plugin);
+ texture = shared;
+ return true;
+ }
+
+ texture = null;
+ return false;
+ }
+
///
public ISharedImmediateTexture GetFromGame(string path)
{
diff --git a/Dalamud/Plugin/Services/ITextureProvider.cs b/Dalamud/Plugin/Services/ITextureProvider.cs
index 65db7db81..d75899bd4 100644
--- a/Dalamud/Plugin/Services/ITextureProvider.cs
+++ b/Dalamud/Plugin/Services/ITextureProvider.cs
@@ -189,10 +189,20 @@ public interface ITextureProvider
/// The shared texture that you may use to obtain the loaded texture wrap and load states.
///
/// This function is under the effect of .
- /// This function does not throw exceptions.
/// Caching the returned object is not recommended. Performance benefit will be minimal.
///
ISharedImmediateTexture GetFromGameIcon(in GameIconLookup lookup);
+
+ /// Gets a shared texture corresponding to the given game resource icon specifier.
+ ///
+ /// This function does not throw exceptions.
+ /// This function is under the effect of .
+ /// Caching the returned object is not recommended. Performance benefit will be minimal.
+ ///
+ /// A game icon specifier.
+ /// The resulting .
+ /// Whether or not the lookup succeeded.
+ bool TryGetFromGameIcon(in GameIconLookup lookup, [NotNullWhen(true)] out ISharedImmediateTexture? texture);
/// Gets a shared texture corresponding to the given path to a game resource.
/// A path to a game resource.