From a08d2b203282545326a2c33600cc8779740bc902 Mon Sep 17 00:00:00 2001 From: kalilistic <35899782+kalilistic@users.noreply.github.com> Date: Tue, 21 Feb 2023 22:57:11 -0500 Subject: [PATCH] feat: add new fa font tester data window --- .../Interface/Internal/Windows/DataWindow.cs | 59 ++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/DataWindow.cs b/Dalamud/Interface/Internal/Windows/DataWindow.cs index 1b594e34d..0bd96ac19 100644 --- a/Dalamud/Interface/Internal/Windows/DataWindow.cs +++ b/Dalamud/Interface/Internal/Windows/DataWindow.cs @@ -80,6 +80,14 @@ internal class DataWindow : Window private Hook? messageBoxMinHook; private bool hookUseMinHook = false; + // FontAwesome + private List? icons; + private List iconNames; + private string[]? iconCategories; + private int selectedIconCategory; + private string iconSearchInput = string.Empty; + private bool iconSearchChanged = true; + // IPC private ICallGateProvider ipcPub; private ICallGateSubscriber ipcSub; @@ -149,7 +157,8 @@ internal class DataWindow : Window Address, Object_Table, Fate_Table, - Font_Test, + SE_Font_Test, + FontAwesome_Test, Party_List, Buddy_List, Plugin_IPC, @@ -270,8 +279,12 @@ internal class DataWindow : Window this.DrawFateTable(); break; - case DataKind.Font_Test: - this.DrawFontTest(); + case DataKind.SE_Font_Test: + this.DrawSEFontTest(); + break; + + case DataKind.FontAwesome_Test: + this.DrawFontAwesomeTest(); break; case DataKind.Party_List: @@ -573,7 +586,7 @@ internal class DataWindow : Window } } - private void DrawFontTest() + private void DrawSEFontTest() { var specialChars = string.Empty; @@ -581,15 +594,45 @@ internal class DataWindow : Window specialChars += $"0x{i:X} - {(SeIconChar)i} - {(char)i}\n"; ImGui.TextUnformatted(specialChars); + } - foreach (var fontAwesomeIcon in Enum.GetValues(typeof(FontAwesomeIcon)).Cast()) + private void DrawFontAwesomeTest() + { + this.iconCategories ??= FontAwesomeHelpers.GetCategories(); + + if (this.iconSearchChanged) { - ImGui.Text(((int)fontAwesomeIcon.ToIconChar()).ToString("X") + " - "); - ImGui.SameLine(); + this.icons = FontAwesomeHelpers.SearchIcons(this.iconSearchInput, this.iconCategories[this.selectedIconCategory]); + this.iconNames = this.icons.Select(icon => Enum.GetName(icon)!).ToList(); + this.iconSearchChanged = false; + } + ImGui.SetNextItemWidth(160f); + var categoryIndex = this.selectedIconCategory; + if (ImGui.Combo("####FontAwesomeCategorySearch", ref categoryIndex, this.iconCategories, this.iconCategories.Length)) + { + this.selectedIconCategory = categoryIndex; + this.iconSearchChanged = true; + } + + ImGui.SameLine(170f); + ImGui.SetNextItemWidth(180f); + if (ImGui.InputTextWithHint($"###FontAwesomeInputSearch", "search icons", ref this.iconSearchInput, 50)) + { + this.iconSearchChanged = true; + } + + ImGuiHelpers.ScaledDummy(10f); + for (var i = 0; i < this.icons?.Count; i++) + { + ImGui.Text($"0x{(int)this.icons[i].ToIconChar():X}"); + ImGuiHelpers.ScaledRelativeSameLine(50f); + ImGui.Text($"{this.iconNames[i]}"); + ImGuiHelpers.ScaledRelativeSameLine(280f); ImGui.PushFont(UiBuilder.IconFont); - ImGui.Text(fontAwesomeIcon.ToIconString()); + ImGui.Text(this.icons[i].ToIconString()); ImGui.PopFont(); + ImGuiHelpers.ScaledDummy(2f); } }