using System.Collections.Generic; using System.Numerics; using Dalamud.Bindings.ImGui; using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; using Questionable.Model.Changelog; namespace Questionable.Windows.ChangelogComponents; internal static class ChangelogCategoryComponent { public static void DrawCategoryGroup(EChangeCategory category, List changes, float baseX) { DrawCategoryHeader(category switch { EChangeCategory.Added => FontAwesomeIcon.Plus, EChangeCategory.Changed => FontAwesomeIcon.Edit, EChangeCategory.Fixed => FontAwesomeIcon.Wrench, EChangeCategory.Removed => FontAwesomeIcon.Minus, EChangeCategory.QuestUpdates => FontAwesomeIcon.Map, _ => FontAwesomeIcon.Circle, }, category switch { EChangeCategory.Added => UiThemeUtils.StatusComplete, EChangeCategory.Changed => UiThemeUtils.StatusActive, EChangeCategory.Fixed => UiThemeUtils.StatusAvailableComplete, EChangeCategory.Removed => UiThemeUtils.StatusLocked, EChangeCategory.QuestUpdates => UiThemeUtils.AccentColor, _ => UiThemeUtils.DimTextColor, }, category.ToDisplayString(), baseX); ImGui.Spacing(); float changeIndent = 28f; foreach (ChangeEntry change in changes) { DrawChange(change, baseX, changeIndent); } } private static void DrawCategoryHeader(FontAwesomeIcon icon, Vector4 color, string text, float baseX) { float cursorPosY = ImGui.GetCursorPosY(); ImGui.SetCursorPosX(baseX); using (ImRaii.PushFont(UiBuilder.IconFont)) { ImGui.TextColored(in color, icon.ToIconString()); } ImGui.SameLine(); ImGui.SetCursorPosY(cursorPosY); using (ImRaii.PushColor(ImGuiCol.Text, color)) { ImGui.TextUnformatted(text); } } private static void DrawChange(ChangeEntry change, float baseX, float changeIndent) { ImGui.SetCursorPosX(baseX + changeIndent); float cursorPosY = ImGui.GetCursorPosY(); using (ImRaii.PushFont(UiBuilder.IconFont)) { ImGui.TextColored(in UiThemeUtils.PrimaryTextColor, FontAwesomeIcon.CaretRight.ToIconString()); } ImGui.SameLine(); ImGui.SetCursorPosY(cursorPosY); float num = ImGui.GetContentRegionAvail().X - 8f; ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + num); ImGui.TextColored(in UiThemeUtils.PrimaryTextColor, change.Description); ImGui.PopTextWrapPos(); if (change.SubItems != null && change.SubItems.Count > 0) { DrawSubItems(change.SubItems, baseX, changeIndent); } } private static void DrawSubItems(List subItems, float baseX, float changeIndent) { float num = changeIndent + 20f; foreach (string subItem in subItems) { ImGui.SetCursorPosX(baseX + num); float cursorPosY = ImGui.GetCursorPosY(); using (ImRaii.PushFont(UiBuilder.IconFont)) { ImGui.TextColored(in UiThemeUtils.DimTextColor, FontAwesomeIcon.AngleRight.ToIconString()); } ImGui.SameLine(); ImGui.SetCursorPosY(cursorPosY); float num2 = ImGui.GetContentRegionAvail().X - 8f; ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + num2); ImGui.TextColored(in UiThemeUtils.DimTextColor, subItem); ImGui.PopTextWrapPos(); } } }