Merge remote-tracking branch 'origin/master' into v9-rollup

This commit is contained in:
github-actions[bot] 2023-08-03 18:27:09 +00:00
commit b5dd771843
14 changed files with 1019 additions and 85 deletions

View file

@ -1,4 +1,6 @@
using System.Collections.ObjectModel;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using ImGuiScene;
using Lumina;
@ -86,6 +88,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 ITextureProvider instead")]
public TexFile? GetIcon(uint iconId, bool highResolution = false);
/// <summary>
@ -95,6 +98,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 ITextureProvider instead")]
public TexFile? GetIcon(ClientLanguage iconLanguage, uint iconId, bool highResolution = false);
/// <summary>
@ -104,6 +108,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 ITextureProvider instead")]
public TexFile? GetIcon(string? type, uint iconId, bool highResolution = false);
/// <summary>
@ -112,6 +117,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 ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(uint iconId, bool highResolution = false);
/// <summary>
@ -120,6 +126,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 ITextureProvider instead")]
public TexFile? GetIcon(bool isHq, uint iconId);
/// <summary>
@ -127,6 +134,7 @@ public interface IDataManager
/// </summary>
/// <param name="iconId">The icon ID.</param>
/// <returns>The <see cref="TexFile"/> containing the icon.</returns>
[Obsolete("Use ITextureProvider instead")]
public TexFile? GetHqIcon(uint iconId);
/// <summary>
@ -134,6 +142,8 @@ 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 ITextureProvider instead")]
[return: NotNullIfNotNull(nameof(tex))]
public TextureWrap? GetImGuiTexture(TexFile? tex);
/// <summary>
@ -141,6 +151,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 ITextureProvider instead")]
public TextureWrap? GetImGuiTexture(string path);
/// <summary>
@ -149,6 +160,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 ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(bool isHq, uint iconId);
/// <summary>
@ -157,6 +169,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 ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(ClientLanguage iconLanguage, uint iconId);
/// <summary>
@ -165,6 +178,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 ITextureProvider instead")]
public TextureWrap? GetImGuiTextureIcon(string type, uint iconId);
/// <summary>
@ -172,5 +186,6 @@ public interface IDataManager
/// </summary>
/// <param name="iconId">The icon ID.</param>
/// <returns>The <see cref="TextureWrap"/> containing the icon.</returns>
[Obsolete("Use ITextureProvider instead")]
public TextureWrap? GetImGuiTextureHqIcon(uint iconId);
}

View file

@ -0,0 +1,96 @@
using System;
using System.IO;
using Dalamud.Interface.Internal;
using Lumina.Data.Files;
namespace Dalamud.Plugin.Services;
/// <summary>
/// Service that grants you access to textures you may render via ImGui.
/// </summary>
public interface ITextureProvider
{
/// <summary>
/// Flags describing the icon you wish to receive.
/// </summary>
[Flags]
public enum IconFlags
{
/// <summary>
/// Low-resolution, standard quality icon.
/// </summary>
None = 0,
/// <summary>
/// If this icon is an item icon, and it has a high-quality variant, receive the high-quality version.
/// Null if the item does not have a high-quality variant.
/// </summary>
ItemHighQuality = 1 << 0,
/// <summary>
/// Get the hi-resolution version of the icon, if it exists.
/// </summary>
HiRes = 1 << 1,
}
/// <summary>
/// Get a texture handle for a specific icon.
/// </summary>
/// <param name="iconId">The ID of the icon to load.</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>
/// <param name="keepAlive">
/// Prevent Dalamud from automatically unloading this icon to save memory. Usually does not need to be set.
/// </param>
/// <returns>
/// Null, if the icon does not exist in the specified configuration, or a texture wrap that can be used
/// to render the icon.
/// </returns>
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>
/// Get a texture handle for the texture at the specified path.
/// You may only specify paths in the game's VFS.
/// </summary>
/// <param name="path">The path to the texture in the game's VFS.</param>
/// <param name="keepAlive">Prevent Dalamud from automatically unloading this texture to save memory. Usually does not need to be set.</param>
/// <returns>Null, if the icon does not exist, or a texture wrap that can be used to render the texture.</returns>
public IDalamudTextureWrap? GetTextureFromGame(string path, bool keepAlive = false);
/// <summary>
/// Get a texture handle for the image or texture, specified by the passed FileInfo.
/// You may only specify paths on the native file system.
///
/// This API can load .png and .tex files.
/// </summary>
/// <param name="file">The FileInfo describing the image or texture file.</param>
/// <param name="keepAlive">Prevent Dalamud from automatically unloading this texture to save memory. Usually does not need to be set.</param>
/// <returns>Null, if the file does not exist, or a texture wrap that can be used to render the texture.</returns>
public IDalamudTextureWrap? GetTextureFromFile(FileInfo file, bool keepAlive = false);
/// <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);
}

View file

@ -0,0 +1,20 @@
namespace Dalamud.Plugin.Services;
/// <summary>
/// Service that grants you the ability to replace texture data that is to be loaded by Dalamud.
/// </summary>
public interface ITextureSubstitutionProvider
{
/// <summary>
/// Delegate describing a function that may be used to intercept and replace texture data.
/// The path assigned may point to another texture inside the game's dats, or a .tex file or image on the disk.
/// </summary>
/// <param name="path">The path to the texture that is to be loaded.</param>
/// <param name="replacementPath">The path that should be loaded instead.</param>
public delegate void TextureDataInterceptorDelegate(string path, ref string? replacementPath);
/// <summary>
/// Event that will be called once Dalamud wants to load texture data.
/// </summary>
public event TextureDataInterceptorDelegate? InterceptTexDataLoad;
}