From 6fbcd0e0e4d7715494d4c2d319524a3362682d45 Mon Sep 17 00:00:00 2001 From: goat Date: Sat, 23 Sep 2023 13:05:19 +0200 Subject: [PATCH] chore: don't use ImGuiScene.TextureWrap for any external API, IDalamudTextureWrap does not inherit from ImGuiScene.TextureWrap any longer --- .../AddonArgTypes/AddonRefreshArgs.cs | 1 - Dalamud/Interface/ColorHelpers.cs | 2 +- .../Interface/Internal/DalamudInterface.cs | 4 +- .../Interface/Internal/DalamudTextureWrap.cs | 20 ++++-- .../Interface/Internal/InterfaceManager.cs | 6 +- Dalamud/Interface/Internal/TextureManager.cs | 6 +- .../Internal/Windows/ChangelogWindow.cs | 2 +- .../Windows/Data/Widgets/TexWidget.cs | 4 +- .../Internal/Windows/PluginImageCache.cs | 66 +++++++++---------- .../PluginInstaller/PluginInstallerWindow.cs | 10 +-- .../Windows/Settings/Tabs/SettingsTabAbout.cs | 2 +- .../Internal/Windows/TitleScreenMenuWindow.cs | 2 +- .../TitleScreenMenu/TitleScreenMenu.cs | 13 ++-- .../TitleScreenMenu/TitleScreenMenuEntry.cs | 6 +- Dalamud/Interface/UiBuilder.cs | 12 ++-- Dalamud/Interface/UldWrapper.cs | 8 +-- Dalamud/Plugin/Services/ITitleScreenMenu.cs | 5 +- 17 files changed, 91 insertions(+), 78 deletions(-) diff --git a/Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonRefreshArgs.cs b/Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonRefreshArgs.cs index 60ccaf8ea..6376c16b0 100644 --- a/Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonRefreshArgs.cs +++ b/Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonRefreshArgs.cs @@ -1,4 +1,3 @@ -using System; using FFXIVClientStructs.FFXIV.Component.GUI; namespace Dalamud.Game.Addon; diff --git a/Dalamud/Interface/ColorHelpers.cs b/Dalamud/Interface/ColorHelpers.cs index dd9ab08f7..b2b489004 100644 --- a/Dalamud/Interface/ColorHelpers.cs +++ b/Dalamud/Interface/ColorHelpers.cs @@ -270,7 +270,7 @@ public static class ColorHelpers => RgbaVector4ToUint(Fade(RgbaUintToVector4(color), amount)); /// - /// 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. /// /// Known Color to convert. /// RGBA Vector with values between 0.0f and 1.0f. diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs index 4de73adc7..cfaae485a 100644 --- a/Dalamud/Interface/Internal/DalamudInterface.cs +++ b/Dalamud/Interface/Internal/DalamudInterface.cs @@ -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)); diff --git a/Dalamud/Interface/Internal/DalamudTextureWrap.cs b/Dalamud/Interface/Internal/DalamudTextureWrap.cs index 039873f1f..036686c29 100644 --- a/Dalamud/Interface/Internal/DalamudTextureWrap.cs +++ b/Dalamud/Interface/Internal/DalamudTextureWrap.cs @@ -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. /// -public interface IDalamudTextureWrap : TextureWrap +public interface IDalamudTextureWrap : IDisposable { + /// + /// Gets a texture handle suitable for direct use with ImGui functions. + /// + IntPtr ImGuiHandle { get; } + + /// + /// Gets the width of the texture. + /// + int Width { get; } + + /// + /// Gets the height of the texture. + /// + int Height { get; } } /// diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index 6a3256a7f..be6ca3528 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -241,7 +241,7 @@ internal class InterfaceManager : IDisposable, IServiceType /// /// The filepath to load. /// A texture, ready to use in ImGui. - 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 /// /// The data to load. /// A texture, ready to use in ImGui. - 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 /// The height in pixels. /// The number of channels. /// A texture, ready to use in ImGui. - 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."); diff --git a/Dalamud/Interface/Internal/TextureManager.cs b/Dalamud/Interface/Internal/TextureManager.cs index 78af0ebb7..ce08e6cc7 100644 --- a/Dalamud/Interface/Internal/TextureManager.cs +++ b/Dalamud/Interface/Internal/TextureManager.cs @@ -43,7 +43,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP private readonly Dictionary activeTextures = new(); - private TextureWrap? fallbackTextureWrap; + private IDalamudTextureWrap? fallbackTextureWrap; /// /// Initializes a new instance of the 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 /// /// Gets or sets the actual texture wrap. May be unpopulated. /// - public TextureWrap? Wrap { get; set; } + public IDalamudTextureWrap? Wrap { get; set; } /// /// Gets or sets the time the texture was last accessed. diff --git a/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs b/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs index e61cb400b..61010ce0c 100644 --- a/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs @@ -36,7 +36,7 @@ Thanks and have fun!"; private readonly string assemblyVersion = Util.AssemblyVersion; - private readonly TextureWrap logoTexture; + private readonly IDalamudTextureWrap logoTexture; /// /// Initializes a new instance of the class. diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs index 9f7f69ca2..0cbc401e7 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs @@ -15,7 +15,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets; /// internal class TexWidget : IDataWindowWidget { - private readonly List addedTextures = new(); + private readonly List 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}")) diff --git a/Dalamud/Interface/Internal/Windows/PluginImageCache.cs b/Dalamud/Interface/Internal/Windows/PluginImageCache.cs index 766f80b23..c334cd4bd 100644 --- a/Dalamud/Interface/Internal/Windows/PluginImageCache.cs +++ b/Dalamud/Interface/Internal/Windows/PluginImageCache.cs @@ -59,24 +59,24 @@ internal class PluginImageCache : IDisposable, IServiceType private readonly Task downloadTask; private readonly Task loadTask; - private readonly ConcurrentDictionary pluginIconMap = new(); - private readonly ConcurrentDictionary pluginImagesMap = new(); + private readonly ConcurrentDictionary pluginIconMap = new(); + private readonly ConcurrentDictionary pluginImagesMap = new(); - private readonly Task emptyTextureTask; - private readonly Task disabledIconTask; - private readonly Task outdatedInstallableIconTask; - private readonly Task defaultIconTask; - private readonly Task troubleIconTask; - private readonly Task updateIconTask; - private readonly Task installedIconTask; - private readonly Task thirdIconTask; - private readonly Task thirdInstalledIconTask; - private readonly Task corePluginIconTask; + private readonly Task emptyTextureTask; + private readonly Task disabledIconTask; + private readonly Task outdatedInstallableIconTask; + private readonly Task defaultIconTask; + private readonly Task troubleIconTask; + private readonly Task updateIconTask; + private readonly Task installedIconTask; + private readonly Task thirdIconTask; + private readonly Task thirdInstalledIconTask; + private readonly Task corePluginIconTask; [ServiceManager.ServiceConstructor] private PluginImageCache(Dalamud dalamud) { - Task? TaskWrapIfNonNull(TextureWrap? tw) => tw == null ? null : Task.FromResult(tw!); + Task? 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 /// /// Gets the fallback empty texture. /// - public TextureWrap EmptyTexture => this.emptyTextureTask.IsCompleted - ? this.emptyTextureTask.Result - : this.emptyTextureTask.GetAwaiter().GetResult(); + public IDalamudTextureWrap EmptyTexture => this.emptyTextureTask.IsCompleted + ? this.emptyTextureTask.Result + : this.emptyTextureTask.GetAwaiter().GetResult(); /// /// Gets the disabled plugin icon. /// - public TextureWrap DisabledIcon => this.disabledIconTask.IsCompleted + public IDalamudTextureWrap DisabledIcon => this.disabledIconTask.IsCompleted ? this.disabledIconTask.Result : this.disabledIconTask.GetAwaiter().GetResult(); /// /// Gets the outdated installable plugin icon. /// - public TextureWrap OutdatedInstallableIcon => this.outdatedInstallableIconTask.IsCompleted + public IDalamudTextureWrap OutdatedInstallableIcon => this.outdatedInstallableIconTask.IsCompleted ? this.outdatedInstallableIconTask.Result : this.outdatedInstallableIconTask.GetAwaiter().GetResult(); /// /// Gets the default plugin icon. /// - public TextureWrap DefaultIcon => this.defaultIconTask.IsCompleted + public IDalamudTextureWrap DefaultIcon => this.defaultIconTask.IsCompleted ? this.defaultIconTask.Result : this.defaultIconTask.GetAwaiter().GetResult(); /// /// Gets the plugin trouble icon overlay. /// - public TextureWrap TroubleIcon => this.troubleIconTask.IsCompleted + public IDalamudTextureWrap TroubleIcon => this.troubleIconTask.IsCompleted ? this.troubleIconTask.Result : this.troubleIconTask.GetAwaiter().GetResult(); /// /// Gets the plugin update icon overlay. /// - public TextureWrap UpdateIcon => this.updateIconTask.IsCompleted + public IDalamudTextureWrap UpdateIcon => this.updateIconTask.IsCompleted ? this.updateIconTask.Result : this.updateIconTask.GetAwaiter().GetResult(); /// /// Gets the plugin installed icon overlay. /// - public TextureWrap InstalledIcon => this.installedIconTask.IsCompleted + public IDalamudTextureWrap InstalledIcon => this.installedIconTask.IsCompleted ? this.installedIconTask.Result : this.installedIconTask.GetAwaiter().GetResult(); /// /// Gets the third party plugin icon overlay. /// - public TextureWrap ThirdIcon => this.thirdIconTask.IsCompleted + public IDalamudTextureWrap ThirdIcon => this.thirdIconTask.IsCompleted ? this.thirdIconTask.Result : this.thirdIconTask.GetAwaiter().GetResult(); /// /// Gets the installed third party plugin icon overlay. /// - public TextureWrap ThirdInstalledIcon => this.thirdInstalledIconTask.IsCompleted + public IDalamudTextureWrap ThirdInstalledIcon => this.thirdInstalledIconTask.IsCompleted ? this.thirdInstalledIconTask.Result : this.thirdInstalledIconTask.GetAwaiter().GetResult(); /// /// Gets the core plugin icon. /// - 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 /// If the plugin was third party sourced. /// Cached image textures, or an empty array. /// True if an entry exists, may be null if currently downloading. - 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 /// If the plugin was third party sourced. /// Cached image textures, or an empty array. /// True if the image array exists, may be empty if currently downloading. - 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(); + imageTextures = found ?? Array.Empty(); 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 TryLoadImage( + private async Task 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.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 DownloadPluginIconAsync(LocalPlugin? plugin, IPluginManifest manifest, bool isThirdParty, ulong requestedFrame) + private async Task 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 }) { diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index dcbdced28..6e2ad862c 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -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; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs index 9a7236f2f..ec9833b78 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs @@ -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; diff --git a/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs b/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs index 20d260704..e77a3db4e 100644 --- a/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs +++ b/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs @@ -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 shadeEasings = new(); private readonly Dictionary moveEasings = new(); diff --git a/Dalamud/Interface/TitleScreenMenu/TitleScreenMenu.cs b/Dalamud/Interface/TitleScreenMenu/TitleScreenMenu.cs index 3123ffbb8..6665bbafb 100644 --- a/Dalamud/Interface/TitleScreenMenu/TitleScreenMenu.cs +++ b/Dalamud/Interface/TitleScreenMenu/TitleScreenMenu.cs @@ -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 Entries => this.entries; /// - 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 } /// - 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 /// The action to execute when the option is selected. /// A object that can be used to manage the entry. /// Thrown when the texture provided does not match the required resolution(64x64). - 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 /// The action to execute when the option is selected. /// A object that can be used to manage the entry. /// Thrown when the texture provided does not match the required resolution(64x64). - 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 } /// - 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 } /// - 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); diff --git a/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs b/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs index 18acc4f47..76382ace2 100644 --- a/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs +++ b/Dalamud/Interface/TitleScreenMenu/TitleScreenMenuEntry.cs @@ -1,6 +1,6 @@ using System.Reflection; -using ImGuiScene; +using Dalamud.Interface.Internal; namespace Dalamud.Interface; @@ -19,7 +19,7 @@ public class TitleScreenMenuEntry : IComparable /// The text to show. /// The texture to show. /// The action to execute when the option is selected. - 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 /// /// Gets or sets the texture of this entry. /// - public TextureWrap Texture { get; set; } + public IDalamudTextureWrap Texture { get; set; } /// /// Gets or sets a value indicating whether or not this entry is internal. diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 95ee28f56..dd2e5bad3 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -235,7 +235,7 @@ public sealed class UiBuilder : IDisposable /// /// The full filepath to the image. /// A object wrapping the created image. Use inside ImGui.Image(). - 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 /// /// A byte array containing the raw image data. /// A object wrapping the created image. Use inside ImGui.Image(). - 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 /// The height of the image contained in . /// The number of channels (bytes per pixel) of the image contained in . This should usually be 4. /// A object wrapping the created image. Use inside ImGui.Image(). - 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 /// /// The full filepath to the image. /// A object wrapping the created image. Use inside ImGui.Image(). - public Task LoadImageAsync(string filePath) => Task.Run( + public Task 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 /// /// A byte array containing the raw image data. /// A object wrapping the created image. Use inside ImGui.Image(). - public Task LoadImageAsync(byte[] imageData) => Task.Run( + public Task 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 /// The height of the image contained in . /// The number of channels (bytes per pixel) of the image contained in . This should usually be 4. /// A object wrapping the created image. Use inside ImGui.Image(). - public Task LoadImageRawAsync(byte[] imageData, int width, int height, int numChannels) => Task.Run( + public Task 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.")); diff --git a/Dalamud/Interface/UldWrapper.cs b/Dalamud/Interface/UldWrapper.cs index d41256fa2..e78546ed9 100644 --- a/Dalamud/Interface/UldWrapper.cs +++ b/Dalamud/Interface/UldWrapper.cs @@ -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 /// The path of the requested texture. /// The index of the desired icon. /// A TextureWrap containing the requested part if it exists and null otherwise. - 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) { diff --git a/Dalamud/Plugin/Services/ITitleScreenMenu.cs b/Dalamud/Plugin/Services/ITitleScreenMenu.cs index 2094dc435..b4af06e71 100644 --- a/Dalamud/Plugin/Services/ITitleScreenMenu.cs +++ b/Dalamud/Plugin/Services/ITitleScreenMenu.cs @@ -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 /// The action to execute when the option is selected. /// A object that can be used to manage the entry. /// Thrown when the texture provided does not match the required resolution(64x64). - public TitleScreenMenuEntry AddEntry(string text, TextureWrap texture, Action onTriggered); + public TitleScreenMenuEntry AddEntry(string text, IDalamudTextureWrap texture, Action onTriggered); /// /// Adds a new entry to the title screen menu. @@ -34,7 +35,7 @@ public interface ITitleScreenMenu /// The action to execute when the option is selected. /// A object that can be used to manage the entry. /// Thrown when the texture provided does not match the required resolution(64x64). - public TitleScreenMenuEntry AddEntry(ulong priority, string text, TextureWrap texture, Action onTriggered); + public TitleScreenMenuEntry AddEntry(ulong priority, string text, IDalamudTextureWrap texture, Action onTriggered); /// /// Remove an entry from the title screen menu.