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 => new Vector4(0.5f, 1f, 0.6f, 1f), EChangeCategory.Changed => new Vector4(0.6f, 0.85f, 1f, 1f), EChangeCategory.Fixed => new Vector4(1f, 0.85f, 0.5f, 1f), EChangeCategory.Removed => new Vector4(1f, 0.5f, 0.5f, 1f), EChangeCategory.QuestUpdates => new Vector4(1f, 1f, 0.6f, 1f), _ => new Vector4(0.9f, 0.9f, 0.9f, 1f), }, 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(new Vector4(0.95f, 0.95f, 1f, 1f), FontAwesomeIcon.CaretRight.ToIconString()); } ImGui.SameLine(); ImGui.SetCursorPosY(cursorPosY); float num = ImGui.GetContentRegionAvail().X - 8f; ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + num); ImGui.TextColored(new Vector4(0.95f, 0.95f, 1f, 1f), 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(new Vector4(0.85f, 0.85f, 0.92f, 1f), FontAwesomeIcon.AngleRight.ToIconString()); } ImGui.SameLine(); ImGui.SetCursorPosY(cursorPosY); float num2 = ImGui.GetContentRegionAvail().X - 8f; ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + num2); ImGui.TextColored(new Vector4(0.85f, 0.85f, 0.92f, 1f), subItem); ImGui.PopTextWrapPos(); } } }