mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Remove unnecessary IsNull functions
This commit is contained in:
parent
54ec64e159
commit
9956424c13
5 changed files with 17 additions and 31 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
|
@ -158,7 +158,7 @@ internal sealed class DelegateFontHandle : FontHandle
|
|||
{
|
||||
toolkitPreBuild.Font = default;
|
||||
k.CallOnBuildStepChange(toolkitPreBuild);
|
||||
if (toolkitPreBuild.Font.IsNull())
|
||||
if (toolkitPreBuild.Font.IsNull)
|
||||
{
|
||||
if (fontCountPrevious == fontsVector.Length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ internal sealed partial class FontAtlasFactory
|
|||
foreach (var s in this.data.Substances)
|
||||
{
|
||||
var f = s.GetFontPtr(fontHandle);
|
||||
if (!f.IsNull())
|
||||
if (!f.IsNull)
|
||||
return f;
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
catch
|
||||
{
|
||||
if (!font.IsNull())
|
||||
if (!font.IsNull)
|
||||
{
|
||||
// Note that for both RemoveAt calls, corresponding destructors will be called.
|
||||
|
||||
|
|
@ -331,14 +331,14 @@ internal sealed partial class FontAtlasFactory
|
|||
}
|
||||
}
|
||||
|
||||
if (font.IsNull())
|
||||
if (font.IsNull)
|
||||
{
|
||||
// fall back to AXIS fonts
|
||||
font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default);
|
||||
}
|
||||
|
||||
this.AttachExtraGlyphsForDalamudLanguage(new() { SizePx = sizePx, MergeFont = font });
|
||||
if (this.Font.IsNull())
|
||||
if (this.Font.IsNull)
|
||||
this.Font = font;
|
||||
return font;
|
||||
}
|
||||
|
|
@ -413,9 +413,9 @@ internal sealed partial class FontAtlasFactory
|
|||
int style = (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL)
|
||||
{
|
||||
var targetFont = fontConfig.MergeFont;
|
||||
if (targetFont.IsNull())
|
||||
if (targetFont.IsNull)
|
||||
targetFont = this.Font;
|
||||
if (targetFont.IsNull())
|
||||
if (targetFont.IsNull)
|
||||
return;
|
||||
|
||||
// https://learn.microsoft.com/en-us/windows/apps/design/globalizing/loc-international-fonts
|
||||
|
|
@ -556,9 +556,9 @@ internal sealed partial class FontAtlasFactory
|
|||
public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig)
|
||||
{
|
||||
var targetFont = fontConfig.MergeFont;
|
||||
if (targetFont.IsNull())
|
||||
if (targetFont.IsNull)
|
||||
targetFont = this.Font;
|
||||
if (targetFont.IsNull())
|
||||
if (targetFont.IsNull)
|
||||
return;
|
||||
|
||||
var dalamudConfiguration = Service<DalamudConfiguration>.Get();
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ internal abstract class FontHandle : IFontHandle
|
|||
}
|
||||
|
||||
var fontPtr = substance.GetFontPtr(this);
|
||||
if (fontPtr.IsNull())
|
||||
if (fontPtr.IsNull)
|
||||
{
|
||||
// The font for the requested handle is unavailable. Release the reference and try again.
|
||||
substance.DataRoot.Release();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Buffers;
|
||||
using System.Buffers;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
|
@ -250,7 +250,7 @@ internal class GamePrebakedFontHandle : FontHandle
|
|||
GameFontStyle style,
|
||||
ushort[]? glyphRanges = null)
|
||||
{
|
||||
if (font.IsNull())
|
||||
if (font.IsNull)
|
||||
font = this.CreateTemplateFont(toolkitPreBuild, style.SizePx);
|
||||
this.attachments.Add((font, style, glyphRanges));
|
||||
return font;
|
||||
|
|
|
|||
|
|
@ -556,25 +556,11 @@ public static partial class ImGuiHelpers
|
|||
.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether <paramref name="ptr"/> is empty.
|
||||
/// Determines whether <paramref name="ptr"/> is not empty and loaded.
|
||||
/// </summary>
|
||||
/// <param name="ptr">The pointer.</param>
|
||||
/// <returns>Whether it is empty.</returns>
|
||||
public static unsafe bool IsNull(this ImFontPtr ptr) => ptr.Handle == null;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether <paramref name="ptr"/> is empty.
|
||||
/// </summary>
|
||||
/// <param name="ptr">The pointer.</param>
|
||||
/// <returns>Whether it is empty.</returns>
|
||||
public static unsafe bool IsNotNullAndLoaded(this ImFontPtr ptr) => ptr.Handle != null && ptr.IsLoaded();
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether <paramref name="ptr"/> is empty.
|
||||
/// </summary>
|
||||
/// <param name="ptr">The pointer.</param>
|
||||
/// <returns>Whether it is empty.</returns>
|
||||
public static unsafe bool IsNull(this ImFontAtlasPtr ptr) => ptr.Handle == null;
|
||||
/// <returns>Whether it is not null and loaded.</returns>
|
||||
public static unsafe bool IsNotNullAndLoaded(this ImFontPtr ptr) => !ptr.IsNull && ptr.IsLoaded();
|
||||
|
||||
/// <summary>
|
||||
/// If <paramref name="self"/> is default, then returns <paramref name="other"/>.
|
||||
|
|
@ -583,7 +569,7 @@ public static partial class ImGuiHelpers
|
|||
/// <param name="other">The other.</param>
|
||||
/// <returns><paramref name="self"/> if it is not default; otherwise, <paramref name="other"/>.</returns>
|
||||
public static unsafe ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other) =>
|
||||
self.Handle is null ? other : self;
|
||||
self.IsNull ? other : self;
|
||||
|
||||
/// <summary>
|
||||
/// Mark 4K page as used, after adding a codepoint to a font.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue