feat: add new fa font tester data window

This commit is contained in:
kalilistic 2023-02-21 22:57:11 -05:00
parent b208124a28
commit a08d2b2032

View file

@ -80,6 +80,14 @@ internal class DataWindow : Window
private Hook<MessageBoxWDelegate>? messageBoxMinHook;
private bool hookUseMinHook = false;
// FontAwesome
private List<FontAwesomeIcon>? icons;
private List<string> iconNames;
private string[]? iconCategories;
private int selectedIconCategory;
private string iconSearchInput = string.Empty;
private bool iconSearchChanged = true;
// IPC
private ICallGateProvider<string, string> ipcPub;
private ICallGateSubscriber<string, string> 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<FontAwesomeIcon>())
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);
}
}