Fix FontHandleWrapper and some docs

This commit is contained in:
Soreepeong 2024-01-23 19:30:09 +09:00
parent e20daed848
commit d1291364e0
2 changed files with 15 additions and 13 deletions

View file

@ -744,10 +744,12 @@ public sealed class UiBuilder : IDisposable
public event Action<IFontHandle>? ImFontChanged; public event Action<IFontHandle>? ImFontChanged;
public Exception? LoadException => public Exception? LoadException => this.WrappedNotDisposed.LoadException;
this.wrapped!.LoadException ?? new ObjectDisposedException(nameof(FontHandleWrapper));
public bool Available => this.wrapped?.Available ?? false; public bool Available => this.WrappedNotDisposed.Available;
private IFontHandle WrappedNotDisposed =>
this.wrapped ?? throw new ObjectDisposedException(nameof(FontHandleWrapper));
public void Dispose() public void Dispose()
{ {
@ -759,19 +761,17 @@ public sealed class UiBuilder : IDisposable
// Note: do not dispose w; we do not own it // Note: do not dispose w; we do not own it
} }
public IFontHandle.ImFontLocked Lock() => public IFontHandle.ImFontLocked Lock() => this.WrappedNotDisposed.Lock();
this.wrapped?.Lock() ?? throw new ObjectDisposedException(nameof(FontHandleWrapper));
public IDisposable Push() => public IDisposable Push() => this.WrappedNotDisposed.Push();
this.wrapped?.Push() ?? throw new ObjectDisposedException(nameof(FontHandleWrapper));
public void Pop() => this.wrapped?.Pop(); public void Pop() => this.WrappedNotDisposed.Pop();
public Task<IFontHandle> WaitAsync() => public Task<IFontHandle> WaitAsync() =>
this.wrapped?.WaitAsync().ContinueWith(_ => (IFontHandle)this) ?? this.WrappedNotDisposed.WaitAsync().ContinueWith(_ => (IFontHandle)this);
throw new ObjectDisposedException(nameof(FontHandleWrapper));
public override string ToString() => $"{nameof(FontHandleWrapper)}({this.wrapped})"; public override string ToString() =>
$"{nameof(FontHandleWrapper)}({this.wrapped?.ToString() ?? "disposed"})";
private void WrappedOnImFontChanged(IFontHandle obj) => this.ImFontChanged.InvokeSafely(this); private void WrappedOnImFontChanged(IFontHandle obj) => this.ImFontChanged.InvokeSafely(this);
} }

View file

@ -1,4 +1,5 @@
using System.Diagnostics.Contracts; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -64,8 +65,9 @@ internal interface IDalamudAssetManager
/// </summary> /// </summary>
/// <param name="asset">The texture asset.</param> /// <param name="asset">The texture asset.</param>
/// <param name="defaultWrap">The default return value, if the asset is not ready for whatever reason.</param> /// <param name="defaultWrap">The default return value, if the asset is not ready for whatever reason.</param>
/// <returns>The texture wrap.</returns> /// <returns>The texture wrap. Can be <c>null</c> only if <paramref name="defaultWrap"/> is <c>null</c>.</returns>
[Pure] [Pure]
[return: NotNullIfNotNull(nameof(defaultWrap))]
IDalamudTextureWrap? GetDalamudTextureWrap(DalamudAsset asset, IDalamudTextureWrap? defaultWrap); IDalamudTextureWrap? GetDalamudTextureWrap(DalamudAsset asset, IDalamudTextureWrap? defaultWrap);
/// <summary> /// <summary>