diff --git a/Dalamud/Interface/ISharedImmediateTexture.cs b/Dalamud/Interface/ISharedImmediateTexture.cs index d2b22b877..f6c63ee10 100644 --- a/Dalamud/Interface/ISharedImmediateTexture.cs +++ b/Dalamud/Interface/ISharedImmediateTexture.cs @@ -11,12 +11,12 @@ namespace Dalamud.Interface; /// requesters. /// /// Calling on this interface is a no-op. -/// and may stop returning the intended texture at any point. +/// and may stop returning the intended texture at any point. /// Use to lock the texture for use in any thread for any duration. /// public interface ISharedImmediateTexture { - /// Gets the texture for use with the current frame. + /// Gets the texture for use with the current frame, or an empty texture if unavailable. /// An instance of that is guaranteed to be available for the current /// frame being drawn. /// @@ -26,9 +26,10 @@ public interface ISharedImmediateTexture /// If the texture is unavailable for any reason, then the returned instance of /// will point to an empty texture instead. /// - IDalamudTextureWrap GetWrap(); + IDalamudTextureWrap GetWrapOrEmpty(); - /// Gets the texture for use with the current frame. + /// Gets the texture for use with the current frame, or a default value specified via + /// if unavailable. /// The default wrap to return if the requested texture was not immediately available. /// /// An instance of that is guaranteed to be available for the current @@ -40,7 +41,7 @@ public interface ISharedImmediateTexture /// If the texture is unavailable for any reason, then will be returned. /// [return: NotNullIfNotNull(nameof(defaultWrap))] - IDalamudTextureWrap? GetWrap(IDalamudTextureWrap? defaultWrap); + IDalamudTextureWrap? GetWrapOrDefault(IDalamudTextureWrap? defaultWrap = null); /// Attempts to get the texture for use with the current frame. /// An instance of that is guaranteed to be available for diff --git a/Dalamud/Interface/Internal/DisposedDalamudTextureWrap.cs b/Dalamud/Interface/Internal/DisposedDalamudTextureWrap.cs deleted file mode 100644 index 904a2ccb8..000000000 --- a/Dalamud/Interface/Internal/DisposedDalamudTextureWrap.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Dalamud.Interface.Internal; - -/// -/// A disposed texture wrap. -/// -internal sealed class DisposedDalamudTextureWrap : IDalamudTextureWrap -{ - /// - /// Gets the singleton instance. - /// - public static readonly DisposedDalamudTextureWrap Instance = new(); - - private DisposedDalamudTextureWrap() - { - } - - /// - public IntPtr ImGuiHandle => throw new ObjectDisposedException(nameof(DisposedDalamudTextureWrap)); - - /// - public int Width => throw new ObjectDisposedException(nameof(DisposedDalamudTextureWrap)); - - /// - public int Height => throw new ObjectDisposedException(nameof(DisposedDalamudTextureWrap)); - - /// - public void Dispose() - { - // suppressed - } -} diff --git a/Dalamud/Interface/Internal/SharedImmediateTextures/SharedImmediateTexture.cs b/Dalamud/Interface/Internal/SharedImmediateTextures/SharedImmediateTexture.cs index d4df6a85b..426c61b2c 100644 --- a/Dalamud/Interface/Internal/SharedImmediateTextures/SharedImmediateTexture.cs +++ b/Dalamud/Interface/Internal/SharedImmediateTextures/SharedImmediateTexture.cs @@ -174,12 +174,12 @@ internal abstract class SharedImmediateTexture /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public IDalamudTextureWrap GetWrap() => this.GetWrap(Service.Get().Empty4X4); + public IDalamudTextureWrap GetWrapOrEmpty() => this.GetWrapOrDefault(Service.Get().Empty4X4); /// [return: NotNullIfNotNull(nameof(defaultWrap))] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public IDalamudTextureWrap? GetWrap(IDalamudTextureWrap? defaultWrap) + public IDalamudTextureWrap? GetWrapOrDefault(IDalamudTextureWrap? defaultWrap) { if (!this.TryGetWrap(out var texture, out _)) texture = null; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs index 3fdf72cda..4254b9082 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs @@ -273,7 +273,7 @@ internal class TexWidget : IDataWindowWidget ImGui.TableNextColumn(); ImGuiComponents.IconButton(FontAwesomeIcon.Image); - if (ImGui.IsItemHovered() && texture.GetWrap(null) is { } immediate) + if (ImGui.IsItemHovered() && texture.GetWrapOrDefault(null) is { } immediate) { ImGui.BeginTooltip(); ImGui.Image(immediate.ImGuiHandle, immediate.Size); @@ -556,16 +556,16 @@ internal class TexWidget : IDataWindowWidget if (this.Api10 is not null) return this.Api10.IsCompletedSuccessfully ? this.Api10.Result : null; if (this.Api10ImmGameIcon is not null) - return tp.GetFromGameIcon(this.Api10ImmGameIcon.Value).GetWrap(); + return tp.GetFromGameIcon(this.Api10ImmGameIcon.Value).GetWrapOrEmpty(); if (this.Api10ImmGamePath is not null) - return tp.GetFromGame(this.Api10ImmGamePath).GetWrap(); + return tp.GetFromGame(this.Api10ImmGamePath).GetWrapOrEmpty(); if (this.Api10ImmFile is not null) - return tp.GetFromFile(this.Api10ImmFile).GetWrap(); + return tp.GetFromFile(this.Api10ImmFile).GetWrapOrEmpty(); if (this.Api10ImmManifestResource is not null) { return tp.GetFromManifestResource( this.Api10ImmManifestResource.Value.Assembly, - this.Api10ImmManifestResource.Value.Name).GetWrap(); + this.Api10ImmManifestResource.Value.Name).GetWrapOrEmpty(); } return null;