Search: Show number of results, limit shown results due to performance

This commit is contained in:
Liza 2023-11-27 00:02:28 +01:00
parent 9bf199e91b
commit b86935dc56
Signed by: liza
GPG Key ID: 7199F8D727D55F67

View File

@ -16,6 +16,8 @@ namespace ARDiscard.Windows;
internal sealed class ConfigWindow : LImGui.LWindow
{
private const int ResultLimit = 200;
private readonly DalamudPluginInterface _pluginInterface;
private readonly Configuration _configuration;
private readonly ItemCache _itemCache;
@ -95,7 +97,16 @@ internal sealed class ConfigWindow : LImGui.LWindow
var ws = ImGui.GetWindowSize();
if (ImGui.BeginChild("Left", new Vector2(Math.Max(10, ws.X / 2), -1), true))
{
if (!string.IsNullOrEmpty(_itemName))
{
if (_searchResults.Count > ResultLimit)
ImGui.Text($"Search ({ResultLimit:N0} out of {_searchResults.Count:N0} matches)");
else
ImGui.Text($"Search ({_searchResults.Count:N0} matches)");
}
else
ImGui.Text("Search");
ImGui.SetNextItemWidth(ws.X / 2 - 20);
if (_resetKeyboardFocus)
{
@ -133,7 +144,7 @@ internal sealed class ConfigWindow : LImGui.LWindow
ImGui.Text("Type item name...");
}
foreach (var (id, name) in _searchResults)
foreach (var (id, name) in _searchResults.Take(ResultLimit))
{
bool selected = _discarding.Any(x => x.Item1 == id);
if (ImGui.Selectable(name, selected))