diff --git a/Dalamud/Interface/Internal/PluginCategoryManager.cs b/Dalamud/Interface/Internal/PluginCategoryManager.cs index 152e2e7f3..b1c8204b2 100644 --- a/Dalamud/Interface/Internal/PluginCategoryManager.cs +++ b/Dalamud/Interface/Internal/PluginCategoryManager.cs @@ -48,9 +48,23 @@ namespace Dalamud.Interface.Internal private Dictionary mapPluginCategories = new(); private List highlightedCategoryIds = new(); + /// + /// Forces plugin category tags, overrides settings from manifest. + /// key: PluginManifest.InternalName (lowercase, no spaces), + /// value: list of category tags, . + /// + private Dictionary mapPluginCategoryTagOverrides = new(); + + /// + /// Fallback plugin category tags, used only when manifest doesn't contain any. + /// key: PluginManifest.InternalName (lowercase, no spaces), + /// value: list of category tags, . + /// + private Dictionary mapPluginCategoryTagFallbacks = new(); + #if DEBUG // temp - hardcode some tag values for testing, idk what most of them does so it's probably not very accurate :D - private Dictionary mapPluginTagTesting = new() + private Dictionary mapPluginCategoryTagFallbacksHACK = new() { ["accuratecountdown"] = new string[] { "UI" }, ["adventurerinneed"] = new string[] { "UI" }, @@ -136,7 +150,7 @@ namespace Dalamud.Interface.Internal ["xivchat"] = new string[] { "social" }, ["xivcombo"] = new string[] { "jobs" }, }; - #endif // DEBUG +#endif // DEBUG /// /// Type of category group. @@ -231,25 +245,10 @@ namespace Dalamud.Interface.Internal foreach (var plugin in availablePlugins) { categoryList.Clear(); - if (plugin.Tags != null) + + var pluginCategoryTags = this.GetCategoryTagsForManifest(plugin); + if (pluginCategoryTags != null) { - IEnumerable pluginCategoryTags = plugin.CategoryTags; -#if DEBUG - if (pluginCategoryTags == null) - { - var nameKey = plugin.InternalName.ToLowerInvariant().Replace(" ", string.Empty); - - if (this.mapPluginTagTesting.TryGetValue(nameKey, out var dummyTags)) - { - pluginCategoryTags = dummyTags; - } - } -#endif // DEBUG - if (pluginCategoryTags == null) - { - continue; - } - foreach (var tag in pluginCategoryTags) { // only tags from whitelist can be accepted @@ -366,6 +365,34 @@ namespace Dalamud.Interface.Internal /// true if highlight is needed. public bool IsCategoryHighlighted(int categoryId) => this.highlightedCategoryIds.Contains(categoryId); + private IEnumerable GetCategoryTagsForManifest(PluginManifest pluginManifest) + { + var nameKey = pluginManifest.InternalName.ToLowerInvariant().Replace(" ", string.Empty); + if (this.mapPluginCategoryTagOverrides.TryGetValue(nameKey, out var overrideTags)) + { + return overrideTags; + } + + if (pluginManifest.CategoryTags != null) + { + return pluginManifest.CategoryTags; + } + + if (this.mapPluginCategoryTagFallbacks.TryGetValue(nameKey, out var fallbackTags)) + { + return fallbackTags; + } + +#if DEBUG + if (this.mapPluginCategoryTagFallbacksHACK.TryGetValue(nameKey, out var dummyTags)) + { + return dummyTags; + } +#endif // DEBUG + + return null; + } + /// /// Plugin installer category info. /// diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs index 2849cd891..cc6f9d323 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs @@ -611,26 +611,40 @@ namespace Dalamud.Interface.Internal.Windows private void DrawPluginCategories() { float useContentHeight = -40; // button height + spacing - float useMenuWidth = 180; // make dynamic? + float useMenuWidth = 180; // works fine as static value, table can be resized by user - if (ImGui.BeginChild($"ScrollingCategorySelectors", ImGuiHelpers.ScaledVector2(useMenuWidth, useContentHeight), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground)) + float useContentWidth = ImGui.GetContentRegionAvail().X; + + if (ImGui.BeginChild("InstallerCategories", new Vector2(useContentWidth, useContentHeight * ImGuiHelpers.GlobalScale))) { - this.DrawPluginCategorySelectors(); - ImGui.EndChild(); - } + ImGui.PushStyleVar(ImGuiStyleVar.CellPadding, ImGuiHelpers.ScaledVector2(5, 0)); + if (ImGui.BeginTable("##InstallerCategoriesCont", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersInnerV)) + { + ImGui.TableSetupColumn("##InstallerCategoriesSelector", ImGuiTableColumnFlags.WidthFixed, useMenuWidth * ImGuiHelpers.GlobalScale); + ImGui.TableSetupColumn("##InstallerCategoriesBody", ImGuiTableColumnFlags.WidthStretch); + ImGui.TableNextRow(); - ImGui.SameLine((useMenuWidth + 20) * ImGuiHelpers.GlobalScale); + ImGui.TableNextColumn(); + this.DrawPluginCategorySelectors(); - if (ImGui.BeginChild($"ScrollingCategoryContent", new Vector2(ImGui.GetContentRegionAvail().X, useContentHeight * ImGuiHelpers.GlobalScale), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground)) - { - this.DrawPluginCategoryContent(); + ImGui.TableNextColumn(); + if (ImGui.BeginChild($"ScrollingPlugins", new Vector2(useContentWidth, 0), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground)) + { + this.DrawPluginCategoryContent(); + ImGui.EndChild(); + } + + ImGui.EndTable(); + } + + ImGui.PopStyleVar(); ImGui.EndChild(); } } private void DrawPluginCategorySelectors() { - Vector4 colorSearchHighlight = Vector4.One; + var colorSearchHighlight = Vector4.One; unsafe { var colorPtr = ImGui.GetStyleColorVec4(ImGuiCol.NavHighlight); @@ -658,6 +672,7 @@ namespace Dalamud.Interface.Internal.Windows } ImGui.Indent(); + var categoryItemSize = new Vector2(ImGui.GetContentRegionAvail().X - (5 * ImGuiHelpers.GlobalScale), ImGui.GetTextLineHeight()); for (int categoryIdx = 0; categoryIdx < groupInfo.Categories.Count; categoryIdx++) { var categoryInfo = Array.Find(this.categoryManager.CategoryList, x => x.CategoryId == groupInfo.Categories[categoryIdx]); @@ -668,7 +683,7 @@ namespace Dalamud.Interface.Internal.Windows ImGui.PushStyleColor(ImGuiCol.Text, colorSearchHighlight); } - if (ImGui.Selectable(categoryInfo.Name, this.categoryManager.CurrentCategoryIdx == categoryIdx)) + if (ImGui.Selectable(categoryInfo.Name, this.categoryManager.CurrentCategoryIdx == categoryIdx, ImGuiSelectableFlags.None, categoryItemSize)) { this.categoryManager.CurrentCategoryIdx = categoryIdx; }