diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs
index 407a1b0da..8c0a33081 100644
--- a/Dalamud/Data/DataManager.cs
+++ b/Dalamud/Data/DataManager.cs
@@ -185,15 +185,17 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager
///
/// The icon ID.
/// The containing the icon.
- /// TODO(v9): remove in api9 in favor of GetIcon(uint iconId, bool highResolution)
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(uint iconId)
=> this.GetIcon(this.Language, iconId, false);
///
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(uint iconId, bool highResolution)
=> this.GetIcon(this.Language, iconId, highResolution);
///
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(bool isHq, uint iconId)
{
var type = isHq ? "hq/" : string.Empty;
@@ -206,11 +208,12 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager
/// The requested language.
/// The icon ID.
/// The containing the icon.
- /// TODO(v9): remove in api9 in favor of GetIcon(ClientLanguage iconLanguage, uint iconId, bool highResolution)
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(ClientLanguage iconLanguage, uint iconId)
=> this.GetIcon(iconLanguage, iconId, false);
///
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(ClientLanguage iconLanguage, uint iconId, bool highResolution)
{
var type = iconLanguage switch
@@ -231,11 +234,12 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager
/// The type of the icon (e.g. 'hq' to get the HQ variant of an item icon).
/// The icon ID.
/// The containing the icon.
- /// TODO(v9): remove in api9 in favor of GetIcon(string? type, uint iconId, bool highResolution)
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(string? type, uint iconId)
=> this.GetIcon(type, iconId, false);
///
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(string? type, uint iconId, bool highResolution)
{
var format = highResolution ? HighResolutionIconFileFormat : IconFileFormat;
@@ -257,14 +261,17 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager
}
///
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetHqIcon(uint iconId)
=> this.GetIcon(true, iconId);
///
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTexture(TexFile? tex)
=> tex == null ? null : Service.Get().LoadImageRaw(tex.GetRgbaImageData(), tex.Header.Width, tex.Header.Height, 4);
///
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTexture(string path)
=> this.GetImGuiTexture(this.GetFile(path));
@@ -274,26 +281,32 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager
/// The icon ID.
/// The containing the icon.
/// TODO(v9): remove in api9 in favor of GetImGuiTextureIcon(uint iconId, bool highResolution)
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(uint iconId)
=> this.GetImGuiTexture(this.GetIcon(iconId, false));
///
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(uint iconId, bool highResolution)
=> this.GetImGuiTexture(this.GetIcon(iconId, highResolution));
///
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(bool isHq, uint iconId)
=> this.GetImGuiTexture(this.GetIcon(isHq, iconId));
///
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId)
=> this.GetImGuiTexture(this.GetIcon(iconLanguage, iconId));
///
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(string type, uint iconId)
=> this.GetImGuiTexture(this.GetIcon(type, iconId));
///
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureHqIcon(uint iconId)
=> this.GetImGuiTexture(this.GetHqIcon(iconId));
diff --git a/Dalamud/Interface/Internal/TextureManager.cs b/Dalamud/Interface/Internal/TextureManager.cs
index 9cff8f54d..ba0a7045d 100644
--- a/Dalamud/Interface/Internal/TextureManager.cs
+++ b/Dalamud/Interface/Internal/TextureManager.cs
@@ -176,7 +176,21 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
ArgumentNullException.ThrowIfNull(file);
return !file.Exists ? null : this.CreateWrap(file.FullName, keepAlive);
}
-
+
+ ///
+ /// Get a texture handle for the specified Lumina TexFile.
+ ///
+ /// The texture to obtain a handle to.
+ /// A texture wrap that can be used to render the texture.
+ public IDalamudTextureWrap? GetTexture(TexFile file)
+ {
+ ArgumentNullException.ThrowIfNull(file);
+
+#pragma warning disable CS0618
+ return this.dataManager.GetImGuiTexture(file) as IDalamudTextureWrap;
+#pragma warning restore CS0618
+ }
+
///
public void Dispose()
{
@@ -253,7 +267,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
{
// Attempt to load via Lumina
var file = this.dataManager.GameData.GetFileFromDisk(path);
- wrap = this.dataManager.GetImGuiTexture(file);
+ wrap = this.GetTexture(file);
Log.Verbose("Texture {Path} loaded FS via Lumina", path);
}
else
@@ -267,7 +281,10 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
{
// Load regularly from dats
var file = this.dataManager.GetFile(path);
- wrap = this.dataManager.GetImGuiTexture(file);
+ if (file == null)
+ throw new Exception("Could not load TexFile from dat.");
+
+ wrap = this.GetTexture(file);
Log.Verbose("Texture {Path} loaded from SqPack", path);
}
@@ -427,7 +444,6 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
#pragma warning restore SA1015
internal class TextureManagerPluginScoped : ITextureProvider, IServiceType, IDisposable
{
- private readonly DataManager dataManager;
private readonly TextureManager textureManager;
private readonly List trackedTextures = new();
@@ -435,11 +451,9 @@ internal class TextureManagerPluginScoped : ITextureProvider, IServiceType, IDis
///
/// Initializes a new instance of the class.
///
- /// DataManager instance.
/// TextureManager instance.
- public TextureManagerPluginScoped(DataManager dataManager, TextureManager textureManager)
+ public TextureManagerPluginScoped(TextureManager textureManager)
{
- this.dataManager = dataManager;
this.textureManager = textureManager;
}
@@ -485,10 +499,8 @@ internal class TextureManagerPluginScoped : ITextureProvider, IServiceType, IDis
}
///
- public IDalamudTextureWrap GetTexture(TexFile file)
- {
- return this.dataManager.GetImGuiTexture(file) as DalamudTextureWrap ?? throw new ArgumentException("Could not load texture");
- }
+ public IDalamudTextureWrap? GetTexture(TexFile file)
+ => this.textureManager.GetTexture(file);
///
public void Dispose()
diff --git a/Dalamud/Plugin/Services/IDataManager.cs b/Dalamud/Plugin/Services/IDataManager.cs
index 8e36905f9..4f08cf618 100644
--- a/Dalamud/Plugin/Services/IDataManager.cs
+++ b/Dalamud/Plugin/Services/IDataManager.cs
@@ -92,7 +92,7 @@ public interface IDataManager
/// The icon ID.
/// Return high resolution version.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(uint iconId, bool highResolution = false);
///
@@ -102,7 +102,7 @@ public interface IDataManager
/// The icon ID.
/// Return high resolution version.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(ClientLanguage iconLanguage, uint iconId, bool highResolution = false);
///
@@ -112,7 +112,7 @@ public interface IDataManager
/// The icon ID.
/// Return high resolution version.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(string? type, uint iconId, bool highResolution = false);
///
@@ -121,7 +121,7 @@ public interface IDataManager
/// The icon ID.
/// Return the high resolution version.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(uint iconId, bool highResolution = false);
///
@@ -130,7 +130,7 @@ public interface IDataManager
/// A value indicating whether the icon should be HQ.
/// The icon ID.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetIcon(bool isHq, uint iconId);
///
@@ -138,7 +138,7 @@ public interface IDataManager
///
/// The icon ID.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TexFile? GetHqIcon(uint iconId);
///
@@ -146,7 +146,7 @@ public interface IDataManager
///
/// The Lumina .
/// A that can be used to draw the texture.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTexture(TexFile? tex);
///
@@ -154,7 +154,7 @@ public interface IDataManager
///
/// The internal path to the texture.
/// A that can be used to draw the texture.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTexture(string path);
///
@@ -163,7 +163,7 @@ public interface IDataManager
/// A value indicating whether the icon should be HQ.
/// The icon ID.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(bool isHq, uint iconId);
///
@@ -172,7 +172,7 @@ public interface IDataManager
/// The requested language.
/// The icon ID.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId);
///
@@ -181,7 +181,7 @@ public interface IDataManager
/// The type of the icon (e.g. 'hq' to get the HQ variant of an item icon).
/// The icon ID.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(string type, uint iconId);
///
@@ -189,6 +189,6 @@ public interface IDataManager
///
/// The icon ID.
/// The containing the icon.
- [Obsolete("Use ITextureManager instead")]
+ [Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureHqIcon(uint iconId);
}