diff --git a/HellionChat/Ui/SettingsOverview.cs b/HellionChat/Ui/SettingsOverview.cs index 29b6eb8..be64b06 100644 --- a/HellionChat/Ui/SettingsOverview.cs +++ b/HellionChat/Ui/SettingsOverview.cs @@ -79,11 +79,13 @@ internal sealed class SettingsOverview // 110f accommodates two-line subtexts; wrap width is matched in DrawCard. var cardHeight = 110f; + // One draw-list lookup per frame instead of one per card. + var drawList = ImGui.GetWindowDrawList(); var cardDefs = BuildCardDefs(); for (var i = 0; i < cardDefs.Length; i++) { var (icon, title, subtext) = cardDefs[i]; - DrawCard(i, icon, title, subtext, cardWidth, cardHeight); + DrawCard(i, icon, title, subtext, cardWidth, cardHeight, drawList); if ((i + 1) % columns != 0 && i != cardDefs.Length - 1) ImGui.SameLine(); @@ -96,7 +98,8 @@ internal sealed class SettingsOverview string title, string subtext, float w, - float h + float h, + ImDrawListPtr drawList ) { // BeginGroup makes the card a single layout item so SameLine works @@ -108,8 +111,7 @@ internal sealed class SettingsOverview var hovered = ImGui.IsItemHovered(); var bgColor = hovered ? 0xFF22303Fu : 0xFF1A2538u; - var draw = ImGui.GetWindowDrawList(); - draw.AddRectFilled(cursorBefore, cursorBefore + new Vector2(w, h), bgColor, 4f); + drawList.AddRectFilled(cursorBefore, cursorBefore + new Vector2(w, h), bgColor, 4f); var iconPos = cursorBefore + new Vector2(16f, 12f); var titlePos = cursorBefore + new Vector2(16f, 40f); @@ -120,15 +122,15 @@ internal sealed class SettingsOverview using (_window.Plugin.FontManager.FontAwesome.Push()) { - draw.AddText(iconPos, titleColor, icon.ToIconString()); + drawList.AddText(iconPos, titleColor, icon.ToIconString()); } - draw.AddText(titlePos, titleColor, title); + drawList.AddText(titlePos, titleColor, title); // Subtext wraps at card inner width (16px padding each side) via DrawList // to avoid expanding the group bounds and breaking SameLine in the card row. var subtextWrapWidth = w - 32f; - draw.AddText( + drawList.AddText( ImGui.GetFont(), ImGui.GetFontSize(), subtextPos,