mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-27 02:49:18 +01:00
Rename ISharedImmediateTexture methods
This commit is contained in:
parent
c9f613931f
commit
8fa8ca43b6
4 changed files with 13 additions and 43 deletions
|
|
@ -11,12 +11,12 @@ namespace Dalamud.Interface;
|
|||
/// requesters.</summary>
|
||||
/// <remarks>
|
||||
/// <para>Calling <see cref="IDisposable.Dispose"/> on this interface is a no-op.</para>
|
||||
/// <para><see cref="GetWrap()"/> and <see cref="TryGetWrap"/> may stop returning the intended texture at any point.
|
||||
/// <para><see cref="GetWrapOrEmpty"/> and <see cref="TryGetWrap"/> may stop returning the intended texture at any point.
|
||||
/// Use <see cref="RentAsync"/> to lock the texture for use in any thread for any duration.</para>
|
||||
/// </remarks>
|
||||
public interface ISharedImmediateTexture
|
||||
{
|
||||
/// <summary>Gets the texture for use with the current frame.</summary>
|
||||
/// <summary>Gets the texture for use with the current frame, or an empty texture if unavailable.</summary>
|
||||
/// <returns>An instance of <see cref="IDalamudTextureWrap"/> that is guaranteed to be available for the current
|
||||
/// frame being drawn.</returns>
|
||||
/// <remarks>
|
||||
|
|
@ -26,9 +26,10 @@ public interface ISharedImmediateTexture
|
|||
/// <para>If the texture is unavailable for any reason, then the returned instance of
|
||||
/// <see cref="IDalamudTextureWrap"/> will point to an empty texture instead.</para>
|
||||
/// </remarks>
|
||||
IDalamudTextureWrap GetWrap();
|
||||
IDalamudTextureWrap GetWrapOrEmpty();
|
||||
|
||||
/// <summary>Gets the texture for use with the current frame.</summary>
|
||||
/// <summary>Gets the texture for use with the current frame, or a default value specified via
|
||||
/// <paramref name="defaultWrap"/> if unavailable.</summary>
|
||||
/// <param name="defaultWrap">The default wrap to return if the requested texture was not immediately available.
|
||||
/// </param>
|
||||
/// <returns>An instance of <see cref="IDalamudTextureWrap"/> that is guaranteed to be available for the current
|
||||
|
|
@ -40,7 +41,7 @@ public interface ISharedImmediateTexture
|
|||
/// <para>If the texture is unavailable for any reason, then <paramref name="defaultWrap"/> will be returned.</para>
|
||||
/// </remarks>
|
||||
[return: NotNullIfNotNull(nameof(defaultWrap))]
|
||||
IDalamudTextureWrap? GetWrap(IDalamudTextureWrap? defaultWrap);
|
||||
IDalamudTextureWrap? GetWrapOrDefault(IDalamudTextureWrap? defaultWrap = null);
|
||||
|
||||
/// <summary>Attempts to get the texture for use with the current frame.</summary>
|
||||
/// <param name="texture">An instance of <see cref="IDalamudTextureWrap"/> that is guaranteed to be available for
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
namespace Dalamud.Interface.Internal;
|
||||
|
||||
/// <summary>
|
||||
/// A disposed texture wrap.
|
||||
/// </summary>
|
||||
internal sealed class DisposedDalamudTextureWrap : IDalamudTextureWrap
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the singleton instance.
|
||||
/// </summary>
|
||||
public static readonly DisposedDalamudTextureWrap Instance = new();
|
||||
|
||||
private DisposedDalamudTextureWrap()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IntPtr ImGuiHandle => throw new ObjectDisposedException(nameof(DisposedDalamudTextureWrap));
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Width => throw new ObjectDisposedException(nameof(DisposedDalamudTextureWrap));
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Height => throw new ObjectDisposedException(nameof(DisposedDalamudTextureWrap));
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
// suppressed
|
||||
}
|
||||
}
|
||||
|
|
@ -174,12 +174,12 @@ internal abstract class SharedImmediateTexture
|
|||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public IDalamudTextureWrap GetWrap() => this.GetWrap(Service<DalamudAssetManager>.Get().Empty4X4);
|
||||
public IDalamudTextureWrap GetWrapOrEmpty() => this.GetWrapOrDefault(Service<DalamudAssetManager>.Get().Empty4X4);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue