feat: add support to load textures from files

This commit is contained in:
goat 2023-08-02 18:46:44 +02:00
parent 8df9821f0e
commit 22a6261c98
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
4 changed files with 116 additions and 33 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.IO;
using Dalamud.Interface.Internal;
using Lumina.Data.Files;
@ -58,7 +59,18 @@ public interface ITextureProvider
/// <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? GetTextureFromGamePath(string path, bool keepAlive = false);
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.

View file

@ -7,15 +7,14 @@ 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="data">The texture data. Null by default, assign something if you wish to replace the data from the game dats.</param>
public delegate void TextureDataInterceptorDelegate(string path, ref byte[]? data);
/// <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.
/// If you have data that should replace the data from the game dats, assign it to the
/// data argument.
/// </summary>
public event TextureDataInterceptorDelegate? InterceptTexDataLoad;
}