mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-21 16:09:19 +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 Dictionary<PluginManifest, int[]> mapPluginCategories = new();
|
||||||
private List<int> highlightedCategoryIds = 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
|
#if DEBUG
|
||||||
// temp - hardcode some tag values for testing, idk what most of them does so it's probably not very accurate :D
|
// 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" },
|
["accuratecountdown"] = new string[] { "UI" },
|
||||||
["adventurerinneed"] = new string[] { "UI" },
|
["adventurerinneed"] = new string[] { "UI" },
|
||||||
|
|
@ -136,7 +150,7 @@ namespace Dalamud.Interface.Internal
|
||||||
["xivchat"] = new string[] { "social" },
|
["xivchat"] = new string[] { "social" },
|
||||||
["xivcombo"] = new string[] { "jobs" },
|
["xivcombo"] = new string[] { "jobs" },
|
||||||
};
|
};
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type of category group.
|
/// Type of category group.
|
||||||
|
|
@ -231,25 +245,10 @@ namespace Dalamud.Interface.Internal
|
||||||
foreach (var plugin in availablePlugins)
|
foreach (var plugin in availablePlugins)
|
||||||
{
|
{
|
||||||
categoryList.Clear();
|
categoryList.Clear();
|
||||||
if (plugin.Tags != 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))
|
var pluginCategoryTags = this.GetCategoryTagsForManifest(plugin);
|
||||||
|
if (pluginCategoryTags != null)
|
||||||
{
|
{
|
||||||
pluginCategoryTags = dummyTags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
|
||||||
if (pluginCategoryTags == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var tag in pluginCategoryTags)
|
foreach (var tag in pluginCategoryTags)
|
||||||
{
|
{
|
||||||
// only tags from whitelist can be accepted
|
// only tags from whitelist can be accepted
|
||||||
|
|
@ -366,6 +365,34 @@ namespace Dalamud.Interface.Internal
|
||||||
/// <returns>true if highlight is needed.</returns>
|
/// <returns>true if highlight is needed.</returns>
|
||||||
public bool IsCategoryHighlighted(int categoryId) => this.highlightedCategoryIds.Contains(categoryId);
|
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>
|
/// <summary>
|
||||||
/// Plugin installer category info.
|
/// Plugin installer category info.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -611,26 +611,40 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
private void DrawPluginCategories()
|
private void DrawPluginCategories()
|
||||||
{
|
{
|
||||||
float useContentHeight = -40; // button height + spacing
|
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)))
|
||||||
{
|
{
|
||||||
|
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.TableNextColumn();
|
||||||
this.DrawPluginCategorySelectors();
|
this.DrawPluginCategorySelectors();
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
if (ImGui.BeginChild($"ScrollingPlugins", new Vector2(useContentWidth, 0), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground))
|
||||||
|
{
|
||||||
|
this.DrawPluginCategoryContent();
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine((useMenuWidth + 20) * ImGuiHelpers.GlobalScale);
|
ImGui.EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui.BeginChild($"ScrollingCategoryContent", new Vector2(ImGui.GetContentRegionAvail().X, useContentHeight * ImGuiHelpers.GlobalScale), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground))
|
ImGui.PopStyleVar();
|
||||||
{
|
|
||||||
this.DrawPluginCategoryContent();
|
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawPluginCategorySelectors()
|
private void DrawPluginCategorySelectors()
|
||||||
{
|
{
|
||||||
Vector4 colorSearchHighlight = Vector4.One;
|
var colorSearchHighlight = Vector4.One;
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
var colorPtr = ImGui.GetStyleColorVec4(ImGuiCol.NavHighlight);
|
var colorPtr = ImGui.GetStyleColorVec4(ImGuiCol.NavHighlight);
|
||||||
|
|
@ -658,6 +672,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Indent();
|
ImGui.Indent();
|
||||||
|
var categoryItemSize = new Vector2(ImGui.GetContentRegionAvail().X - (5 * ImGuiHelpers.GlobalScale), ImGui.GetTextLineHeight());
|
||||||
for (int categoryIdx = 0; categoryIdx < groupInfo.Categories.Count; categoryIdx++)
|
for (int categoryIdx = 0; categoryIdx < groupInfo.Categories.Count; categoryIdx++)
|
||||||
{
|
{
|
||||||
var categoryInfo = Array.Find(this.categoryManager.CategoryList, x => x.CategoryId == groupInfo.Categories[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);
|
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;
|
this.categoryManager.CurrentCategoryIdx = categoryIdx;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue