Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Search bar for Supported Bosses #598

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions BossMod/Config/ModuleViewer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BossMod.Autorotation;
using Dalamud.Interface;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.Sheets;
using Lumina.Text.ReadOnly;
Expand Down Expand Up @@ -29,6 +30,8 @@ private record struct ModuleGroup(ModuleGroupInfo Info, List<ModuleInfo> Modules
private readonly List<ModuleGroup>[,] _groups;
private readonly Vector2 _iconSize = new(30, 30);

private string _searchText = "";

public ModuleViewer(PlanDatabase? planDB, WorldState ws)
{
_planDB = planDB;
Expand Down Expand Up @@ -132,6 +135,15 @@ private void DrawFilters()
if (!table)
return;

ImGui.TableNextColumn();
ImGui.TableNextColumn(); //spacing with only one seemed to be a bit small on certain window sizes
ImGui.AlignTextToFramePadding();
ImGui.Text("Search:");
ImGui.SameLine();
ImGui.SetNextItemWidth(-1);
DrawSearchBar();
ImGui.TableNextColumn();

ImGui.TableNextColumn();
ImGui.TableHeader("Expansion");
ImGui.TableNextRow(ImGuiTableRowFlags.None);
Expand All @@ -147,6 +159,18 @@ private void DrawFilters()
DrawContentTypeFilters();
}

private void DrawSearchBar()
{
ImGui.InputTextWithHint("##search", "e.g. \"Ultimate\"", ref _searchText, 100, ImGuiInputTextFlags.CallbackCompletion);

if (ImGui.IsItemHovered() && !ImGui.IsItemFocused())
{
ImGui.BeginTooltip();
ImGui.Text("Type here to search for any specific instance by its respective title.");
ImGui.EndTooltip();
}
}

private void DrawExpansionFilters()
{
for (var e = BossModuleInfo.Expansion.RealmReborn; e < BossModuleInfo.Expansion.Count; ++e)
Expand Down Expand Up @@ -200,6 +224,9 @@ private void DrawModules(UITree tree, WorldState ws)

foreach (var group in _groups[i, j])
{
if (!_searchText.IsNullOrEmpty() && !group.Info.Name.Contains(_searchText, StringComparison.OrdinalIgnoreCase))
continue;

ImGui.TableNextRow();
ImGui.TableNextColumn();
UIMisc.Image(Service.Texture?.GetFromGameIcon(_expansions[i].icon), new(36));
Expand Down