Add searching by tags

This commit is contained in:
Caraxi 2020-08-21 10:13:50 +09:30
parent 1e1166b607
commit 5dd1e98c70
2 changed files with 15 additions and 2 deletions

View file

@ -43,6 +43,11 @@ namespace Dalamud.Plugin
/// </summary> /// </summary>
public string RepoUrl { get; set; } public string RepoUrl { get; set; }
/// <summary>
/// List of tanks defined on the plugin.
/// </summary>
public List<string> Tags { get; set; }
/// <summary> /// <summary>
/// Whether or not the plugin is hidden in the plugin installer. /// Whether or not the plugin is hidden in the plugin installer.
/// </summary> /// </summary>

View file

@ -72,6 +72,7 @@ namespace Dalamud.Plugin
} }
else { else {
var didAny = false; var didAny = false;
var didAnyWithSearch = false;
var hasSearchString = !string.IsNullOrWhiteSpace(this.searchText); var hasSearchString = !string.IsNullOrWhiteSpace(this.searchText);
foreach (var pluginDefinition in this.dalamud.PluginRepository.PluginMaster) { foreach (var pluginDefinition in this.dalamud.PluginRepository.PluginMaster) {
@ -85,13 +86,18 @@ namespace Dalamud.Plugin
if (pluginDefinition.DalamudApiLevel != PluginManager.DALAMUD_API_LEVEL) if (pluginDefinition.DalamudApiLevel != PluginManager.DALAMUD_API_LEVEL)
continue; continue;
didAny = true;
if (hasSearchString && if (hasSearchString &&
!(pluginDefinition.Name.ToLowerInvariant().Contains(this.searchText.ToLowerInvariant()) || !(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; continue;
} }
didAny = true; didAnyWithSearch = true;
ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion); ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion);
@ -190,6 +196,8 @@ namespace Dalamud.Plugin
if (!didAny) 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.")); 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(); ImGui.PopStyleVar();