mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: deprecate all DataManager texture funcs
This commit is contained in:
parent
7a6916c732
commit
3d0d5e9bc0
3 changed files with 51 additions and 26 deletions
|
|
@ -185,15 +185,17 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager
|
|||
/// </summary>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
/// 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);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TexFile? GetIcon(uint iconId, bool highResolution)
|
||||
=> this.GetIcon(this.Language, iconId, highResolution);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[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
|
|||
/// <param name="iconLanguage">The requested language.</param>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
/// 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);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[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
|
|||
/// <param name="type">The type of the icon (e.g. 'hq' to get the HQ variant of an item icon).</param>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
/// 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);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[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
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TexFile? GetHqIcon(uint iconId)
|
||||
=> this.GetIcon(true, iconId);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTexture(TexFile? tex)
|
||||
=> tex == null ? null : Service<InterfaceManager>.Get().LoadImageRaw(tex.GetRgbaImageData(), tex.Header.Width, tex.Header.Height, 4);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTexture(string path)
|
||||
=> this.GetImGuiTexture(this.GetFile<TexFile>(path));
|
||||
|
||||
|
|
@ -274,26 +281,32 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager
|
|||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TextureWrap"/> containing the icon.</returns>
|
||||
/// 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));
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(uint iconId, bool highResolution)
|
||||
=> this.GetImGuiTexture(this.GetIcon(iconId, highResolution));
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(bool isHq, uint iconId)
|
||||
=> this.GetImGuiTexture(this.GetIcon(isHq, iconId));
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId)
|
||||
=> this.GetImGuiTexture(this.GetIcon(iconLanguage, iconId));
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(string type, uint iconId)
|
||||
=> this.GetImGuiTexture(this.GetIcon(type, iconId));
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureHqIcon(uint iconId)
|
||||
=> this.GetImGuiTexture(this.GetHqIcon(iconId));
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,21 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
|||
ArgumentNullException.ThrowIfNull(file);
|
||||
return !file.Exists ? null : this.CreateWrap(file.FullName, keepAlive);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a texture handle for the specified Lumina TexFile.
|
||||
/// </summary>
|
||||
/// <param name="file">The texture to obtain a handle to.</param>
|
||||
/// <returns>A texture wrap that can be used to render the texture.</returns>
|
||||
public IDalamudTextureWrap? GetTexture(TexFile file)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(file);
|
||||
|
||||
#pragma warning disable CS0618
|
||||
return this.dataManager.GetImGuiTexture(file) as IDalamudTextureWrap;
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
@ -253,7 +267,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
|||
{
|
||||
// Attempt to load via Lumina
|
||||
var file = this.dataManager.GameData.GetFileFromDisk<TexFile>(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<TexFile>(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<TextureManagerTextureWrap> trackedTextures = new();
|
||||
|
|
@ -435,11 +451,9 @@ internal class TextureManagerPluginScoped : ITextureProvider, IServiceType, IDis
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TextureManagerPluginScoped"/> class.
|
||||
/// </summary>
|
||||
/// <param name="dataManager">DataManager instance.</param>
|
||||
/// <param name="textureManager">TextureManager instance.</param>
|
||||
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
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public interface IDataManager
|
|||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <param name="highResolution">Return high resolution version.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TexFile? GetIcon(uint iconId, bool highResolution = false);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -102,7 +102,7 @@ public interface IDataManager
|
|||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <param name="highResolution">Return high resolution version.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TexFile? GetIcon(ClientLanguage iconLanguage, uint iconId, bool highResolution = false);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -112,7 +112,7 @@ public interface IDataManager
|
|||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <param name="highResolution">Return high resolution version.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TexFile? GetIcon(string? type, uint iconId, bool highResolution = false);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -121,7 +121,7 @@ public interface IDataManager
|
|||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <param name="highResolution">Return the high resolution version.</param>
|
||||
/// <returns>The <see cref="TextureWrap"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(uint iconId, bool highResolution = false);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -130,7 +130,7 @@ public interface IDataManager
|
|||
/// <param name="isHq">A value indicating whether the icon should be HQ.</param>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TexFile? GetIcon(bool isHq, uint iconId);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -138,7 +138,7 @@ public interface IDataManager
|
|||
/// </summary>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TexFile? GetHqIcon(uint iconId);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -146,7 +146,7 @@ public interface IDataManager
|
|||
/// </summary>
|
||||
/// <param name="tex">The Lumina <see cref="TexFile"/>.</param>
|
||||
/// <returns>A <see cref="TextureWrap"/> that can be used to draw the texture.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTexture(TexFile? tex);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -154,7 +154,7 @@ public interface IDataManager
|
|||
/// </summary>
|
||||
/// <param name="path">The internal path to the texture.</param>
|
||||
/// <returns>A <see cref="TextureWrap"/> that can be used to draw the texture.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTexture(string path);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -163,7 +163,7 @@ public interface IDataManager
|
|||
/// <param name="isHq">A value indicating whether the icon should be HQ.</param>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TextureWrap"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(bool isHq, uint iconId);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -172,7 +172,7 @@ public interface IDataManager
|
|||
/// <param name="iconLanguage">The requested language.</param>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TextureWrap"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -181,7 +181,7 @@ public interface IDataManager
|
|||
/// <param name="type">The type of the icon (e.g. 'hq' to get the HQ variant of an item icon).</param>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TextureWrap"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureIcon(string type, uint iconId);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -189,6 +189,6 @@ public interface IDataManager
|
|||
/// </summary>
|
||||
/// <param name="iconId">The icon ID.</param>
|
||||
/// <returns>The <see cref="TextureWrap"/> containing the icon.</returns>
|
||||
[Obsolete("Use ITextureManager instead")]
|
||||
[Obsolete("Use ITextureProvider instead")]
|
||||
public TextureWrap? GetImGuiTextureHqIcon(uint iconId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue