mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
added override and fallback tags for plugins
This commit is contained in:
parent
677c713cff
commit
6eb0953e38
2 changed files with 73 additions and 31 deletions
|
|
@ -48,9 +48,23 @@ namespace Dalamud.Interface.Internal
|
|||
private Dictionary<PluginManifest, int[]> mapPluginCategories = new();
|
||||
private List<int> highlightedCategoryIds = new();
|
||||
|
||||
/// <summary>
|
||||
/// Forces plugin category tags, overrides settings from manifest.
|
||||
/// key: PluginManifest.InternalName (lowercase, no spaces),
|
||||
/// value: list of category tags, <see cref="categoryList"/>.
|
||||
/// </summary>
|
||||
private Dictionary<string, string[]> mapPluginCategoryTagOverrides = new();
|
||||
|
||||
/// <summary>
|
||||
/// Fallback plugin category tags, used only when manifest doesn't contain any.
|
||||
/// key: PluginManifest.InternalName (lowercase, no spaces),
|
||||
/// value: list of category tags, <see cref="categoryList"/>.
|
||||
/// </summary>
|
||||
private Dictionary<string, string[]> 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<string, string[]> mapPluginTagTesting = new()
|
||||
private Dictionary<string, string[]> 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
|
||||
|
||||
/// <summary>
|
||||
/// 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<string> 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
|
|||
/// <returns>true if highlight is needed.</returns>
|
||||
public bool IsCategoryHighlighted(int categoryId) => this.highlightedCategoryIds.Contains(categoryId);
|
||||
|
||||
private IEnumerable<string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plugin installer category info.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue