chore: don't use ImGuiScene.TextureWrap for any external API, IDalamudTextureWrap does not inherit from ImGuiScene.TextureWrap any longer

This commit is contained in:
goat 2023-09-23 13:05:19 +02:00
parent af52da06b0
commit 6fbcd0e0e4
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
17 changed files with 91 additions and 78 deletions

View file

@ -1,4 +1,3 @@
using System;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace Dalamud.Game.Addon;

View file

@ -270,7 +270,7 @@ public static class ColorHelpers
=> RgbaVector4ToUint(Fade(RgbaUintToVector4(color), amount));
/// <summary>
/// Convert a KnownColor to a RGBA vector with values between 0.0f and 1.0f
/// Convert a KnownColor to a RGBA vector with values between 0.0f and 1.0f.
/// </summary>
/// <param name="knownColor">Known Color to convert.</param>
/// <returns>RGBA Vector with values between 0.0f and 1.0f.</returns>

View file

@ -66,8 +66,8 @@ internal class DalamudInterface : IDisposable, IServiceType
private readonly BranchSwitcherWindow branchSwitcherWindow;
private readonly HitchSettingsWindow hitchSettingsWindow;
private readonly TextureWrap logoTexture;
private readonly TextureWrap tsmLogoTexture;
private readonly IDalamudTextureWrap logoTexture;
private readonly IDalamudTextureWrap tsmLogoTexture;
private bool isCreditsDarkening = false;
private OutCubic creditsDarkeningAnimation = new(TimeSpan.FromSeconds(10));

View file

@ -1,6 +1,4 @@
using System;
using ImGuiScene;
using ImGuiScene;
namespace Dalamud.Interface.Internal;
@ -8,8 +6,22 @@ namespace Dalamud.Interface.Internal;
/// Base TextureWrap interface for all Dalamud-owned texture wraps.
/// Used to avoid referencing ImGuiScene.
/// </summary>
public interface IDalamudTextureWrap : TextureWrap
public interface IDalamudTextureWrap : IDisposable
{
/// <summary>
/// Gets a texture handle suitable for direct use with ImGui functions.
/// </summary>
IntPtr ImGuiHandle { get; }
/// <summary>
/// Gets the width of the texture.
/// </summary>
int Width { get; }
/// <summary>
/// Gets the height of the texture.
/// </summary>
int Height { get; }
}
/// <summary>

View file

@ -241,7 +241,7 @@ internal class InterfaceManager : IDisposable, IServiceType
/// </summary>
/// <param name="filePath">The filepath to load.</param>
/// <returns>A texture, ready to use in ImGui.</returns>
public TextureWrap? LoadImage(string filePath)
public IDalamudTextureWrap? LoadImage(string filePath)
{
if (this.scene == null)
throw new InvalidOperationException("Scene isn't ready.");
@ -264,7 +264,7 @@ internal class InterfaceManager : IDisposable, IServiceType
/// </summary>
/// <param name="imageData">The data to load.</param>
/// <returns>A texture, ready to use in ImGui.</returns>
public TextureWrap? LoadImage(byte[] imageData)
public IDalamudTextureWrap? LoadImage(byte[] imageData)
{
if (this.scene == null)
throw new InvalidOperationException("Scene isn't ready.");
@ -290,7 +290,7 @@ internal class InterfaceManager : IDisposable, IServiceType
/// <param name="height">The height in pixels.</param>
/// <param name="numChannels">The number of channels.</param>
/// <returns>A texture, ready to use in ImGui.</returns>
public TextureWrap? LoadImageRaw(byte[] imageData, int width, int height, int numChannels)
public IDalamudTextureWrap? LoadImageRaw(byte[] imageData, int width, int height, int numChannels)
{
if (this.scene == null)
throw new InvalidOperationException("Scene isn't ready.");

View file

@ -43,7 +43,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
private readonly Dictionary<string, TextureInfo> activeTextures = new();
private TextureWrap? fallbackTextureWrap;
private IDalamudTextureWrap? fallbackTextureWrap;
/// <summary>
/// Initializes a new instance of the <see cref="TextureManager"/> class.
@ -319,7 +319,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
// Substitute the path here for loading, instead of when getting the respective TextureInfo
path = this.GetSubstitutedPath(path);
TextureWrap? wrap;
IDalamudTextureWrap? wrap;
try
{
// We want to load this from the disk, probably, if the path has a root
@ -495,7 +495,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
/// <summary>
/// Gets or sets the actual texture wrap. May be unpopulated.
/// </summary>
public TextureWrap? Wrap { get; set; }
public IDalamudTextureWrap? Wrap { get; set; }
/// <summary>
/// Gets or sets the time the texture was last accessed.

View file

@ -36,7 +36,7 @@ Thanks and have fun!";
private readonly string assemblyVersion = Util.AssemblyVersion;
private readonly TextureWrap logoTexture;
private readonly IDalamudTextureWrap logoTexture;
/// <summary>
/// Initializes a new instance of the <see cref="ChangelogWindow"/> class.

View file

@ -15,7 +15,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
/// </summary>
internal class TexWidget : IDataWindowWidget
{
private readonly List<TextureWrap> addedTextures = new();
private readonly List<IDalamudTextureWrap> addedTextures = new();
private string iconId = "18";
private bool hiRes = true;
@ -104,7 +104,7 @@ internal class TexWidget : IDataWindowWidget
ImGuiHelpers.ScaledDummy(10);
TextureWrap? toRemove = null;
IDalamudTextureWrap? toRemove = null;
for (var i = 0; i < this.addedTextures.Count; i++)
{
if (ImGui.CollapsingHeader($"Tex #{i}"))

View file

@ -59,24 +59,24 @@ internal class PluginImageCache : IDisposable, IServiceType
private readonly Task downloadTask;
private readonly Task loadTask;
private readonly ConcurrentDictionary<string, TextureWrap?> pluginIconMap = new();
private readonly ConcurrentDictionary<string, TextureWrap?[]?> pluginImagesMap = new();
private readonly ConcurrentDictionary<string, IDalamudTextureWrap?> pluginIconMap = new();
private readonly ConcurrentDictionary<string, IDalamudTextureWrap?[]?> pluginImagesMap = new();
private readonly Task<TextureWrap> emptyTextureTask;
private readonly Task<TextureWrap> disabledIconTask;
private readonly Task<TextureWrap> outdatedInstallableIconTask;
private readonly Task<TextureWrap> defaultIconTask;
private readonly Task<TextureWrap> troubleIconTask;
private readonly Task<TextureWrap> updateIconTask;
private readonly Task<TextureWrap> installedIconTask;
private readonly Task<TextureWrap> thirdIconTask;
private readonly Task<TextureWrap> thirdInstalledIconTask;
private readonly Task<TextureWrap> corePluginIconTask;
private readonly Task<IDalamudTextureWrap> emptyTextureTask;
private readonly Task<IDalamudTextureWrap> disabledIconTask;
private readonly Task<IDalamudTextureWrap> outdatedInstallableIconTask;
private readonly Task<IDalamudTextureWrap> defaultIconTask;
private readonly Task<IDalamudTextureWrap> troubleIconTask;
private readonly Task<IDalamudTextureWrap> updateIconTask;
private readonly Task<IDalamudTextureWrap> installedIconTask;
private readonly Task<IDalamudTextureWrap> thirdIconTask;
private readonly Task<IDalamudTextureWrap> thirdInstalledIconTask;
private readonly Task<IDalamudTextureWrap> corePluginIconTask;
[ServiceManager.ServiceConstructor]
private PluginImageCache(Dalamud dalamud)
{
Task<TextureWrap>? TaskWrapIfNonNull(TextureWrap? tw) => tw == null ? null : Task.FromResult(tw!);
Task<IDalamudTextureWrap>? TaskWrapIfNonNull(IDalamudTextureWrap? tw) => tw == null ? null : Task.FromResult(tw!);
var imwst = Task.Run(() => this.imWithScene);
this.emptyTextureTask = imwst.ContinueWith(task => task.Result.Manager.LoadImageRaw(new byte[64], 8, 8, 4)!);
@ -99,70 +99,70 @@ internal class PluginImageCache : IDisposable, IServiceType
/// <summary>
/// Gets the fallback empty texture.
/// </summary>
public TextureWrap EmptyTexture => this.emptyTextureTask.IsCompleted
public IDalamudTextureWrap EmptyTexture => this.emptyTextureTask.IsCompleted
? this.emptyTextureTask.Result
: this.emptyTextureTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the disabled plugin icon.
/// </summary>
public TextureWrap DisabledIcon => this.disabledIconTask.IsCompleted
public IDalamudTextureWrap DisabledIcon => this.disabledIconTask.IsCompleted
? this.disabledIconTask.Result
: this.disabledIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the outdated installable plugin icon.
/// </summary>
public TextureWrap OutdatedInstallableIcon => this.outdatedInstallableIconTask.IsCompleted
public IDalamudTextureWrap OutdatedInstallableIcon => this.outdatedInstallableIconTask.IsCompleted
? this.outdatedInstallableIconTask.Result
: this.outdatedInstallableIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the default plugin icon.
/// </summary>
public TextureWrap DefaultIcon => this.defaultIconTask.IsCompleted
public IDalamudTextureWrap DefaultIcon => this.defaultIconTask.IsCompleted
? this.defaultIconTask.Result
: this.defaultIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the plugin trouble icon overlay.
/// </summary>
public TextureWrap TroubleIcon => this.troubleIconTask.IsCompleted
public IDalamudTextureWrap TroubleIcon => this.troubleIconTask.IsCompleted
? this.troubleIconTask.Result
: this.troubleIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the plugin update icon overlay.
/// </summary>
public TextureWrap UpdateIcon => this.updateIconTask.IsCompleted
public IDalamudTextureWrap UpdateIcon => this.updateIconTask.IsCompleted
? this.updateIconTask.Result
: this.updateIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the plugin installed icon overlay.
/// </summary>
public TextureWrap InstalledIcon => this.installedIconTask.IsCompleted
public IDalamudTextureWrap InstalledIcon => this.installedIconTask.IsCompleted
? this.installedIconTask.Result
: this.installedIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the third party plugin icon overlay.
/// </summary>
public TextureWrap ThirdIcon => this.thirdIconTask.IsCompleted
public IDalamudTextureWrap ThirdIcon => this.thirdIconTask.IsCompleted
? this.thirdIconTask.Result
: this.thirdIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the installed third party plugin icon overlay.
/// </summary>
public TextureWrap ThirdInstalledIcon => this.thirdInstalledIconTask.IsCompleted
public IDalamudTextureWrap ThirdInstalledIcon => this.thirdInstalledIconTask.IsCompleted
? this.thirdInstalledIconTask.Result
: this.thirdInstalledIconTask.GetAwaiter().GetResult();
/// <summary>
/// Gets the core plugin icon.
/// </summary>
public TextureWrap CorePluginIcon => this.corePluginIconTask.IsCompleted
public IDalamudTextureWrap CorePluginIcon => this.corePluginIconTask.IsCompleted
? this.corePluginIconTask.Result
: this.corePluginIconTask.GetAwaiter().GetResult();
@ -233,7 +233,7 @@ internal class PluginImageCache : IDisposable, IServiceType
/// <param name="isThirdParty">If the plugin was third party sourced.</param>
/// <param name="iconTexture">Cached image textures, or an empty array.</param>
/// <returns>True if an entry exists, may be null if currently downloading.</returns>
public bool TryGetIcon(LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, out TextureWrap? iconTexture)
public bool TryGetIcon(LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, out IDalamudTextureWrap? iconTexture)
{
iconTexture = null;
@ -275,16 +275,16 @@ internal class PluginImageCache : IDisposable, IServiceType
/// <param name="isThirdParty">If the plugin was third party sourced.</param>
/// <param name="imageTextures">Cached image textures, or an empty array.</param>
/// <returns>True if the image array exists, may be empty if currently downloading.</returns>
public bool TryGetImages(LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, out TextureWrap?[] imageTextures)
public bool TryGetImages(LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, out IDalamudTextureWrap?[] imageTextures)
{
if (!this.pluginImagesMap.TryAdd(manifest.InternalName, null))
{
var found = this.pluginImagesMap[manifest.InternalName];
imageTextures = found ?? Array.Empty<TextureWrap?>();
imageTextures = found ?? Array.Empty<IDalamudTextureWrap?>();
return true;
}
var target = new TextureWrap?[5];
var target = new IDalamudTextureWrap?[5];
this.pluginImagesMap[manifest.InternalName] = target;
imageTextures = target;
@ -304,7 +304,7 @@ internal class PluginImageCache : IDisposable, IServiceType
return false;
}
private async Task<TextureWrap?> TryLoadImage(
private async Task<IDalamudTextureWrap?> TryLoadImage(
byte[]? bytes,
string name,
string? loc,
@ -319,7 +319,7 @@ internal class PluginImageCache : IDisposable, IServiceType
var interfaceManager = this.imWithScene.Manager;
var framework = await Service<Framework>.GetAsync();
TextureWrap? image;
IDalamudTextureWrap? image;
// FIXME(goat): This is a hack around this call failing randomly in certain situations. Might be related to not being called on the main thread.
try
{
@ -492,7 +492,7 @@ internal class PluginImageCache : IDisposable, IServiceType
Log.Debug("Plugin image loader has shutdown");
}
private async Task<TextureWrap?> DownloadPluginIconAsync(LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, ulong requestedFrame)
private async Task<IDalamudTextureWrap?> DownloadPluginIconAsync(LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, ulong requestedFrame)
{
if (plugin is { IsDev: true })
{
@ -559,7 +559,7 @@ internal class PluginImageCache : IDisposable, IServiceType
return icon;
}
private async Task DownloadPluginImagesAsync(TextureWrap?[] pluginImages, LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, ulong requestedFrame)
private async Task DownloadPluginImagesAsync(IDalamudTextureWrap?[] pluginImages, LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, ulong requestedFrame)
{
if (plugin is { IsDev: true })
{

View file

@ -62,8 +62,8 @@ internal class PluginInstallerWindow : Window, IDisposable
private string[] testerImagePaths = new string[5];
private string testerIconPath = string.Empty;
private TextureWrap?[] testerImages;
private TextureWrap? testerIcon;
private IDalamudTextureWrap?[] testerImages;
private IDalamudTextureWrap? testerIcon;
private bool testerError = false;
private bool testerUpdateAvailable = false;
@ -1525,7 +1525,7 @@ internal class PluginInstallerWindow : Window, IDisposable
ImGuiHelpers.ScaledDummy(20);
static void CheckImageSize(TextureWrap? image, int maxWidth, int maxHeight, bool requireSquare)
static void CheckImageSize(IDalamudTextureWrap? image, int maxWidth, int maxHeight, bool requireSquare)
{
if (image == null)
return;
@ -1570,7 +1570,7 @@ internal class PluginInstallerWindow : Window, IDisposable
this.testerIcon = im.LoadImage(this.testerIconPath);
}
this.testerImages = new TextureWrap[this.testerImagePaths.Length];
this.testerImages = new IDalamudTextureWrap[this.testerImagePaths.Length];
for (var i = 0; i < this.testerImagePaths.Length; i++)
{
@ -1822,7 +1822,7 @@ internal class PluginInstallerWindow : Window, IDisposable
var rectOffset = ImGui.GetWindowContentRegionMin() + ImGui.GetWindowPos();
if (ImGui.IsRectVisible(rectOffset + cursorBeforeImage, rectOffset + cursorBeforeImage + iconSize))
{
TextureWrap icon;
IDalamudTextureWrap icon;
if (log is PluginChangelogEntry pluginLog)
{
icon = this.imageCache.DefaultIcon;

View file

@ -171,7 +171,7 @@ Dalamud is licensed under AGPL v3 or later.
Contribute at: https://github.com/goatcorp/Dalamud
";
private readonly TextureWrap logoTexture;
private readonly IDalamudTextureWrap logoTexture;
private readonly Stopwatch creditsThrottler;
private string creditsText;

View file

@ -25,7 +25,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
private const float TargetFontSizePt = 18f;
private const float TargetFontSizePx = TargetFontSizePt * 4 / 3;
private readonly TextureWrap shadeTexture;
private readonly IDalamudTextureWrap shadeTexture;
private readonly Dictionary<Guid, InOutCubic> shadeEasings = new();
private readonly Dictionary<Guid, InOutQuint> moveEasings = new();

View file

@ -2,6 +2,7 @@
using System.Linq;
using System.Reflection;
using Dalamud.Interface.Internal;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
@ -32,7 +33,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
public IReadOnlyList<TitleScreenMenuEntry> Entries => this.entries;
/// <inheritdoc/>
public TitleScreenMenuEntry AddEntry(string text, TextureWrap texture, Action onTriggered)
public TitleScreenMenuEntry AddEntry(string text, IDalamudTextureWrap texture, Action onTriggered)
{
if (texture.Height != TextureSize || texture.Width != TextureSize)
{
@ -55,7 +56,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
}
/// <inheritdoc/>
public TitleScreenMenuEntry AddEntry(ulong priority, string text, TextureWrap texture, Action onTriggered)
public TitleScreenMenuEntry AddEntry(ulong priority, string text, IDalamudTextureWrap texture, Action onTriggered)
{
if (texture.Height != TextureSize || texture.Width != TextureSize)
{
@ -91,7 +92,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
/// <param name="onTriggered">The action to execute when the option is selected.</param>
/// <returns>A <see cref="TitleScreenMenu"/> object that can be used to manage the entry.</returns>
/// <exception cref="ArgumentException">Thrown when the texture provided does not match the required resolution(64x64).</exception>
internal TitleScreenMenuEntry AddEntryCore(ulong priority, string text, TextureWrap texture, Action onTriggered)
internal TitleScreenMenuEntry AddEntryCore(ulong priority, string text, IDalamudTextureWrap texture, Action onTriggered)
{
if (texture.Height != TextureSize || texture.Width != TextureSize)
{
@ -117,7 +118,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
/// <param name="onTriggered">The action to execute when the option is selected.</param>
/// <returns>A <see cref="TitleScreenMenu"/> object that can be used to manage the entry.</returns>
/// <exception cref="ArgumentException">Thrown when the texture provided does not match the required resolution(64x64).</exception>
internal TitleScreenMenuEntry AddEntryCore(string text, TextureWrap texture, Action onTriggered)
internal TitleScreenMenuEntry AddEntryCore(string text, IDalamudTextureWrap texture, Action onTriggered)
{
if (texture.Height != TextureSize || texture.Width != TextureSize)
{
@ -169,7 +170,7 @@ internal class TitleScreenMenuPluginScoped : IDisposable, IServiceType, ITitleSc
}
/// <inheritdoc/>
public TitleScreenMenuEntry AddEntry(string text, TextureWrap texture, Action onTriggered)
public TitleScreenMenuEntry AddEntry(string text, IDalamudTextureWrap texture, Action onTriggered)
{
var entry = this.titleScreenMenuService.AddEntry(text, texture, onTriggered);
this.pluginEntries.Add(entry);
@ -178,7 +179,7 @@ internal class TitleScreenMenuPluginScoped : IDisposable, IServiceType, ITitleSc
}
/// <inheritdoc/>
public TitleScreenMenuEntry AddEntry(ulong priority, string text, TextureWrap texture, Action onTriggered)
public TitleScreenMenuEntry AddEntry(ulong priority, string text, IDalamudTextureWrap texture, Action onTriggered)
{
var entry = this.titleScreenMenuService.AddEntry(priority, text, texture, onTriggered);
this.pluginEntries.Add(entry);

View file

@ -1,6 +1,6 @@
using System.Reflection;
using ImGuiScene;
using Dalamud.Interface.Internal;
namespace Dalamud.Interface;
@ -19,7 +19,7 @@ public class TitleScreenMenuEntry : IComparable<TitleScreenMenuEntry>
/// <param name="text">The text to show.</param>
/// <param name="texture">The texture to show.</param>
/// <param name="onTriggered">The action to execute when the option is selected.</param>
internal TitleScreenMenuEntry(Assembly? callingAssembly, ulong priority, string text, TextureWrap texture, Action onTriggered)
internal TitleScreenMenuEntry(Assembly? callingAssembly, ulong priority, string text, IDalamudTextureWrap texture, Action onTriggered)
{
this.CallingAssembly = callingAssembly;
this.Priority = priority;
@ -41,7 +41,7 @@ public class TitleScreenMenuEntry : IComparable<TitleScreenMenuEntry>
/// <summary>
/// Gets or sets the texture of this entry.
/// </summary>
public TextureWrap Texture { get; set; }
public IDalamudTextureWrap Texture { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not this entry is internal.

View file

@ -235,7 +235,7 @@ public sealed class UiBuilder : IDisposable
/// </summary>
/// <param name="filePath">The full filepath to the image.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public TextureWrap LoadImage(string filePath)
public IDalamudTextureWrap LoadImage(string filePath)
=> this.InterfaceManagerWithScene?.LoadImage(filePath)
?? throw new InvalidOperationException("Load failed.");
@ -244,7 +244,7 @@ public sealed class UiBuilder : IDisposable
/// </summary>
/// <param name="imageData">A byte array containing the raw image data.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public TextureWrap LoadImage(byte[] imageData)
public IDalamudTextureWrap LoadImage(byte[] imageData)
=> this.InterfaceManagerWithScene?.LoadImage(imageData)
?? throw new InvalidOperationException("Load failed.");
@ -256,7 +256,7 @@ public sealed class UiBuilder : IDisposable
/// <param name="height">The height of the image contained in <paramref name="imageData"/>.</param>
/// <param name="numChannels">The number of channels (bytes per pixel) of the image contained in <paramref name="imageData"/>. This should usually be 4.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels)
public IDalamudTextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels)
=> this.InterfaceManagerWithScene?.LoadImageRaw(imageData, width, height, numChannels)
?? throw new InvalidOperationException("Load failed.");
@ -273,7 +273,7 @@ public sealed class UiBuilder : IDisposable
/// </summary>
/// <param name="filePath">The full filepath to the image.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public Task<TextureWrap> LoadImageAsync(string filePath) => Task.Run(
public Task<IDalamudTextureWrap> LoadImageAsync(string filePath) => Task.Run(
async () =>
(await this.InterfaceManagerWithSceneAsync).LoadImage(filePath)
?? throw new InvalidOperationException("Load failed."));
@ -283,7 +283,7 @@ public sealed class UiBuilder : IDisposable
/// </summary>
/// <param name="imageData">A byte array containing the raw image data.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public Task<TextureWrap> LoadImageAsync(byte[] imageData) => Task.Run(
public Task<IDalamudTextureWrap> LoadImageAsync(byte[] imageData) => Task.Run(
async () =>
(await this.InterfaceManagerWithSceneAsync).LoadImage(imageData)
?? throw new InvalidOperationException("Load failed."));
@ -296,7 +296,7 @@ public sealed class UiBuilder : IDisposable
/// <param name="height">The height of the image contained in <paramref name="imageData"/>.</param>
/// <param name="numChannels">The number of channels (bytes per pixel) of the image contained in <paramref name="imageData"/>. This should usually be 4.</param>
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image().</returns>
public Task<TextureWrap> LoadImageRawAsync(byte[] imageData, int width, int height, int numChannels) => Task.Run(
public Task<IDalamudTextureWrap> LoadImageRawAsync(byte[] imageData, int width, int height, int numChannels) => Task.Run(
async () =>
(await this.InterfaceManagerWithSceneAsync).LoadImageRaw(imageData, width, height, numChannels)
?? throw new InvalidOperationException("Load failed."));

View file

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Data;
using Dalamud.Interface.Internal;
using Dalamud.Utility;
using ImGuiScene;
using Lumina.Data.Files;
@ -38,7 +38,7 @@ public class UldWrapper : IDisposable
/// <param name="texturePath">The path of the requested texture.</param>
/// <param name="part">The index of the desired icon.</param>
/// <returns>A TextureWrap containing the requested part if it exists and null otherwise.</returns>
public TextureWrap? LoadTexturePart(string texturePath, int part)
public IDalamudTextureWrap? LoadTexturePart(string texturePath, int part)
{
if (!this.Valid)
{
@ -67,7 +67,7 @@ public class UldWrapper : IDisposable
this.Uld = null;
}
private TextureWrap? CreateTexture(uint id, int width, int height, bool hd, byte[] rgbaData, int partIdx)
private IDalamudTextureWrap? CreateTexture(uint id, int width, int height, bool hd, byte[] rgbaData, int partIdx)
{
var idx = 0;
UldRoot.PartData? partData = null;
@ -105,7 +105,7 @@ public class UldWrapper : IDisposable
return this.CopyRect(width, height, rgbaData, d);
}
private TextureWrap? CopyRect(int width, int height, byte[] rgbaData, UldRoot.PartData part)
private IDalamudTextureWrap? CopyRect(int width, int height, byte[] rgbaData, UldRoot.PartData part)
{
if (part.V + part.W > width || part.U + part.H > height)
{

View file

@ -1,6 +1,7 @@
using System.Collections.Generic;
using Dalamud.Interface;
using Dalamud.Interface.Internal;
using ImGuiScene;
namespace Dalamud.Plugin.Services;
@ -23,7 +24,7 @@ public interface ITitleScreenMenu
/// <param name="onTriggered">The action to execute when the option is selected.</param>
/// <returns>A <see cref="TitleScreenMenu"/> object that can be used to manage the entry.</returns>
/// <exception cref="ArgumentException">Thrown when the texture provided does not match the required resolution(64x64).</exception>
public TitleScreenMenuEntry AddEntry(string text, TextureWrap texture, Action onTriggered);
public TitleScreenMenuEntry AddEntry(string text, IDalamudTextureWrap texture, Action onTriggered);
/// <summary>
/// Adds a new entry to the title screen menu.
@ -34,7 +35,7 @@ public interface ITitleScreenMenu
/// <param name="onTriggered">The action to execute when the option is selected.</param>
/// <returns>A <see cref="TitleScreenMenu"/> object that can be used to manage the entry.</returns>
/// <exception cref="ArgumentException">Thrown when the texture provided does not match the required resolution(64x64).</exception>
public TitleScreenMenuEntry AddEntry(ulong priority, string text, TextureWrap texture, Action onTriggered);
public TitleScreenMenuEntry AddEntry(ulong priority, string text, IDalamudTextureWrap texture, Action onTriggered);
/// <summary>
/// Remove an entry from the title screen menu.