Unify body notice drawing logic, clear search when switching groups

This commit is contained in:
goaaats 2025-04-01 23:15:31 +02:00
parent 34ca8b8f99
commit 5eee678899

View file

@ -1262,7 +1262,6 @@ internal class PluginInstallerWindow : Window, IDisposable
if (filteredAvailableManifests.Count == 0)
{
ImGui.TextColored(ImGuiColors.DalamudGrey2, Locs.TabBody_SearchNoMatching);
return proxies;
}
@ -1314,6 +1313,23 @@ internal class PluginInstallerWindow : Window, IDisposable
}
#pragma warning restore SA1201
#pragma warning disable SA1204
private static void DrawMutedBodyText(string text, float paddingBefore, float paddingAfter)
#pragma warning restore SA1204
{
ImGuiHelpers.ScaledDummy(paddingBefore);
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
{
foreach (var line in text.Split('\n'))
{
ImGuiHelpers.CenteredText(line);
}
}
ImGuiHelpers.ScaledDummy(paddingAfter);
}
private void DrawAvailablePluginList()
{
var i = 0;
@ -1344,6 +1360,24 @@ internal class PluginInstallerWindow : Window, IDisposable
{
this.categoryManager.CurrentCategoryKind = PluginCategoryManager.CategoryKind.All;
}
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
{
var hasSearch = !this.searchText.IsNullOrEmpty();
if (i == 0 && !hasSearch)
{
DrawMutedBodyText(Locs.TabBody_NoPluginsAvailable, 60, 20);
}
else if (i == 0 && hasSearch)
{
DrawMutedBodyText(Locs.TabBody_SearchNoMatching, 60, 20);
}
else if (hasSearch)
{
DrawMutedBodyText(Locs.TabBody_NoMoreResultsFor(this.searchText), 20, 20);
}
}
}
private void DrawInstalledPluginList(InstalledPluginListFilter filter)
@ -1353,7 +1387,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (pluginList.Count == 0)
{
ImGui.TextColored(ImGuiColors.DalamudGrey, Locs.TabBody_SearchNoInstalled);
DrawMutedBodyText(Locs.TabBody_SearchNoInstalled, 60, 20);
return;
}
@ -1363,7 +1397,7 @@ internal class PluginInstallerWindow : Window, IDisposable
if (filteredList.Count == 0)
{
ImGui.TextColored(ImGuiColors.DalamudGrey2, Locs.TabBody_SearchNoMatching);
DrawMutedBodyText(Locs.TabBody_SearchNoMatching, 60, 20);
return;
}
@ -1419,6 +1453,11 @@ internal class PluginInstallerWindow : Window, IDisposable
}
}
}
else if (!this.searchText.IsNullOrEmpty())
{
DrawMutedBodyText(Locs.TabBody_NoMoreResultsFor(this.searchText), 20, 20);
ImGuiHelpers.ScaledDummy(20);
}
}
private void DrawPluginCategories()
@ -1493,6 +1532,9 @@ internal class PluginInstallerWindow : Window, IDisposable
if (!isCurrent)
{
this.categoryManager.CurrentGroupKind = groupInfo.GroupKind;
// Reset search text when switching groups
this.searchText = string.Empty;
}
ImGui.Indent();
@ -3978,6 +4020,8 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string TabBody_NoPluginsInstalled =>
string.Format(Loc.Localize("InstallerNoPluginsInstalled", "You don't have any plugins installed yet!\nYou can install them from the \"{0}\" tab."), PluginCategoryManager.Locs.Category_All);
public static string TabBody_NoPluginsAvailable => Loc.Localize("InstallerNoPluginsAvailable", "No plugins are available at the moment.");
public static string TabBody_NoPluginsUpdateable => Loc.Localize("InstallerNoPluginsUpdate", "No plugins have updates available at the moment.");
public static string TabBody_NoPluginsDev => Loc.Localize("InstallerNoPluginsDev", "You don't have any dev plugins. Add them from the settings.");
@ -3992,6 +4036,8 @@ internal class PluginInstallerWindow : Window, IDisposable
public static string TabBody_SearchNoInstalled => Loc.Localize("InstallerNoInstalled", "No plugins are currently installed. You can install them from the \"All Plugins\" tab.");
public static string TabBody_NoMoreResultsFor(string query) => Loc.Localize("InstallerNoMoreResultsForQuery", "No more search results for \"{0}\".").Format(query);
public static string TabBody_ChangelogNone => Loc.Localize("InstallerNoChangelog", "None of your installed plugins have a changelog.");
public static string TabBody_ChangelogError => Loc.Localize("InstallerChangelogError", "Could not download changelogs.");