From 8035e68ee0dbc5e83e6af7ea09421987260c82d6 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Sat, 22 Jun 2024 15:33:01 -0700 Subject: [PATCH] Don't break macro editor when font atlas isn't built yet --- Craftimizer/Windows/MacroEditor.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Craftimizer/Windows/MacroEditor.cs b/Craftimizer/Windows/MacroEditor.cs index 25d29d2..23e6ef9 100644 --- a/Craftimizer/Windows/MacroEditor.cs +++ b/Craftimizer/Windows/MacroEditor.cs @@ -726,12 +726,13 @@ public sealed class MacroEditor : Window, IDisposable ushort? newRecipe = null; { var recipe = RecipeData.Recipe; - using var fontHandle = AxisFont.Lock(); + using var lockedFontHandle = AxisFont.Available ? AxisFont.Lock() : null; + var fontHandle = lockedFontHandle?.ImFont ?? ImGui.GetFont(); if (ImGuiUtils.SearchableCombo( "combo", ref recipe, LuminaSheets.RecipeSheet.Where(r => r.RecipeLevelTable.Row != 0 && r.ItemResult.Row != 0), - fontHandle.ImFont, + fontHandle, ImGui.GetContentRegionAvail().X - rightSideWidth, r => r.ItemResult.Value!.Name.ToDalamudString().ToString(), r => r.RowId.ToString(), @@ -744,7 +745,7 @@ public sealed class MacroEditor : Window, IDisposable var textLevelSize = ImGui.CalcTextSize(textLevel); ImGui.SameLine(); - var imageSize = fontHandle.ImFont.FontSize; + var imageSize = fontHandle.FontSize; ImGuiUtils.AlignRight( imageSize + 5 + textLevelSize.X, @@ -758,7 +759,7 @@ public sealed class MacroEditor : Window, IDisposable ImGui.SetCursorPosY(ImGui.GetCursorPosY() + ImGui.GetStyle().FramePadding.Y / 2); ImGui.Image(Service.IconManager.GetIcon(classJob.GetIconId()).ImGuiHandle, new Vector2(imageSize), uv0, uv1); ImGui.SameLine(0, 5); - ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (fontHandle.ImFont.FontSize - textLevelSize.Y) / 2); + ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (fontHandle.FontSize - textLevelSize.Y) / 2); ImGui.TextUnformatted(textLevel); })) {