From 1e1166b6079ccc11ba0d75b9407e0a3f89af95c5 Mon Sep 17 00:00:00 2001 From: Caraxi Date: Mon, 17 Aug 2020 17:24:06 +0930 Subject: [PATCH 1/4] Add search to plugin installer Partial match for plugin names Full match for plugin author name --- Dalamud/Plugin/PluginInstallerWindow.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs index 1e31d9fc9..9bbdf4e09 100644 --- a/Dalamud/Plugin/PluginInstallerWindow.cs +++ b/Dalamud/Plugin/PluginInstallerWindow.cs @@ -29,6 +29,8 @@ namespace Dalamud.Plugin private int updatePluginCount = 0; private List updatedPlugins; + private string searchText = ""; + private enum PluginInstallStatus { None, InProgress, @@ -55,6 +57,8 @@ namespace Dalamud.Plugin ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar); ImGui.Text(Loc.Localize("InstallerHint", "This window allows you install and remove in-game plugins.\nThey are made by third-party developers.")); + ImGui.SameLine(); + ImGui.InputText("###XPlPluginInstaller_Search", ref this.searchText, 100); ImGui.Separator(); ImGui.BeginChild("scrolling", new Vector2(0, 400), true, ImGuiWindowFlags.HorizontalScrollbar); @@ -68,6 +72,7 @@ namespace Dalamud.Plugin } else { var didAny = false; + var hasSearchString = !string.IsNullOrWhiteSpace(this.searchText); foreach (var pluginDefinition in this.dalamud.PluginRepository.PluginMaster) { if (pluginDefinition.ApplicableVersion != this.gameVersion && @@ -80,6 +85,12 @@ namespace Dalamud.Plugin if (pluginDefinition.DalamudApiLevel != PluginManager.DALAMUD_API_LEVEL) continue; + if (hasSearchString && + !(pluginDefinition.Name.ToLowerInvariant().Contains(this.searchText.ToLowerInvariant()) || + string.Equals(pluginDefinition.Author, this.searchText, StringComparison.InvariantCultureIgnoreCase))) { + continue; + } + didAny = true; ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion); From 5dd1e98c709c9b824bb861c4b27582fbc58420fa Mon Sep 17 00:00:00 2001 From: Caraxi Date: Fri, 21 Aug 2020 10:13:50 +0930 Subject: [PATCH 2/4] Add searching by tags --- Dalamud/Plugin/PluginDefinition.cs | 5 +++++ Dalamud/Plugin/PluginInstallerWindow.cs | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Dalamud/Plugin/PluginDefinition.cs b/Dalamud/Plugin/PluginDefinition.cs index be3ccd2fe..2c3346c89 100644 --- a/Dalamud/Plugin/PluginDefinition.cs +++ b/Dalamud/Plugin/PluginDefinition.cs @@ -43,6 +43,11 @@ namespace Dalamud.Plugin /// public string RepoUrl { get; set; } + /// + /// List of tanks defined on the plugin. + /// + public List Tags { get; set; } + /// /// Whether or not the plugin is hidden in the plugin installer. /// diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs index 9bbdf4e09..db7fa089a 100644 --- a/Dalamud/Plugin/PluginInstallerWindow.cs +++ b/Dalamud/Plugin/PluginInstallerWindow.cs @@ -72,6 +72,7 @@ namespace Dalamud.Plugin } else { var didAny = false; + var didAnyWithSearch = false; var hasSearchString = !string.IsNullOrWhiteSpace(this.searchText); foreach (var pluginDefinition in this.dalamud.PluginRepository.PluginMaster) { @@ -85,13 +86,18 @@ namespace Dalamud.Plugin if (pluginDefinition.DalamudApiLevel != PluginManager.DALAMUD_API_LEVEL) continue; + didAny = true; + if (hasSearchString && !(pluginDefinition.Name.ToLowerInvariant().Contains(this.searchText.ToLowerInvariant()) || - string.Equals(pluginDefinition.Author, this.searchText, StringComparison.InvariantCultureIgnoreCase))) { + string.Equals(pluginDefinition.Author, this.searchText, StringComparison.InvariantCultureIgnoreCase) || + pluginDefinition.Tags != null && + pluginDefinition.Tags.Contains(this.searchText.ToLowerInvariant(), StringComparer.InvariantCultureIgnoreCase) + )) { continue; } - didAny = true; + didAnyWithSearch = true; ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion); @@ -190,6 +196,8 @@ namespace Dalamud.Plugin if (!didAny) ImGui.TextColored(new Vector4(0.70f, 0.70f, 0.70f, 1.00f), Loc.Localize("InstallerNoCompatible", "No compatible plugins were found :( Please restart your game and try again.")); + else if (!didAnyWithSearch) + ImGui.TextColored(new Vector4(0.7f, 0.7f, 0.7f, 1.0f), Loc.Localize("InstallNoMatching", "No plugins were found matching your search.")); } ImGui.PopStyleVar(); From 19605e385f67c5a1ee9ab5f0df7a8135bcaf09e1 Mon Sep 17 00:00:00 2001 From: Caraxi Date: Fri, 21 Aug 2020 10:19:53 +0930 Subject: [PATCH 3/4] Use InputTextWithHint --- Dalamud/Plugin/PluginInstallerWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Plugin/PluginInstallerWindow.cs b/Dalamud/Plugin/PluginInstallerWindow.cs index db7fa089a..6f4dfcf8b 100644 --- a/Dalamud/Plugin/PluginInstallerWindow.cs +++ b/Dalamud/Plugin/PluginInstallerWindow.cs @@ -58,7 +58,7 @@ namespace Dalamud.Plugin ImGui.Text(Loc.Localize("InstallerHint", "This window allows you install and remove in-game plugins.\nThey are made by third-party developers.")); ImGui.SameLine(); - ImGui.InputText("###XPlPluginInstaller_Search", ref this.searchText, 100); + ImGui.InputTextWithHint("###XPlPluginInstaller_Search", Loc.Localize("InstallerSearch", "Search"), ref this.searchText, 100); ImGui.Separator(); ImGui.BeginChild("scrolling", new Vector2(0, 400), true, ImGuiWindowFlags.HorizontalScrollbar); From fdd749b89f12b9e9668508666700d547221d9bae Mon Sep 17 00:00:00 2001 From: Caraxi Date: Fri, 21 Aug 2020 10:25:21 +0930 Subject: [PATCH 4/4] Update PluginDefinition.cs --- Dalamud/Plugin/PluginDefinition.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Plugin/PluginDefinition.cs b/Dalamud/Plugin/PluginDefinition.cs index 2c3346c89..86b9149e7 100644 --- a/Dalamud/Plugin/PluginDefinition.cs +++ b/Dalamud/Plugin/PluginDefinition.cs @@ -44,7 +44,7 @@ namespace Dalamud.Plugin public string RepoUrl { get; set; } /// - /// List of tanks defined on the plugin. + /// List of tags defined on the plugin. /// public List Tags { get; set; }