mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
added plugin categories
This commit is contained in:
parent
a9a7ac85c9
commit
677c713cff
3 changed files with 662 additions and 2 deletions
|
|
@ -53,6 +53,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
private readonly TextureWrap updateIcon;
|
||||
|
||||
private readonly HttpClient httpClient = new();
|
||||
private readonly PluginCategoryManager categoryManager = new();
|
||||
|
||||
#region Image Tester State
|
||||
|
||||
|
|
@ -194,7 +195,8 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
public override void Draw()
|
||||
{
|
||||
this.DrawHeader();
|
||||
this.DrawPluginTabBar();
|
||||
// this.DrawPluginTabBar();
|
||||
this.DrawPluginCategories();
|
||||
this.DrawFooter();
|
||||
this.DrawErrorModal();
|
||||
this.DrawFeedbackModal();
|
||||
|
|
@ -242,7 +244,10 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
|
||||
ImGui.SetCursorPosX(windowSize.X - sortSelectWidth - style.ItemSpacing.X - searchInputWidth);
|
||||
ImGui.SetNextItemWidth(searchInputWidth);
|
||||
ImGui.InputTextWithHint("###XlPluginInstaller_Search", Locs.Header_SearchPlaceholder, ref this.searchText, 100);
|
||||
if (ImGui.InputTextWithHint("###XlPluginInstaller_Search", Locs.Header_SearchPlaceholder, ref this.searchText, 100))
|
||||
{
|
||||
this.UpdateCategoriesOnSearchChange();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosX(windowSize.X - sortSelectWidth);
|
||||
|
|
@ -603,6 +608,152 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawPluginCategories()
|
||||
{
|
||||
float useContentHeight = -40; // button height + spacing
|
||||
float useMenuWidth = 180; // make dynamic?
|
||||
|
||||
if (ImGui.BeginChild($"ScrollingCategorySelectors", ImGuiHelpers.ScaledVector2(useMenuWidth, useContentHeight), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground))
|
||||
{
|
||||
this.DrawPluginCategorySelectors();
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
ImGui.SameLine((useMenuWidth + 20) * ImGuiHelpers.GlobalScale);
|
||||
|
||||
if (ImGui.BeginChild($"ScrollingCategoryContent", new Vector2(ImGui.GetContentRegionAvail().X, useContentHeight * ImGuiHelpers.GlobalScale), false, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground))
|
||||
{
|
||||
this.DrawPluginCategoryContent();
|
||||
ImGui.EndChild();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPluginCategorySelectors()
|
||||
{
|
||||
Vector4 colorSearchHighlight = Vector4.One;
|
||||
unsafe
|
||||
{
|
||||
var colorPtr = ImGui.GetStyleColorVec4(ImGuiCol.NavHighlight);
|
||||
if (colorPtr != null)
|
||||
{
|
||||
colorSearchHighlight = *colorPtr;
|
||||
}
|
||||
}
|
||||
|
||||
for (int groupIdx = 0; groupIdx < this.categoryManager.GroupList.Length; groupIdx++)
|
||||
{
|
||||
var groupInfo = this.categoryManager.GroupList[groupIdx];
|
||||
var canShowGroup = (groupInfo.GroupKind != PluginCategoryManager.GroupKind.DevTools) || this.hasDevPlugins;
|
||||
if (!canShowGroup)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui.SetNextItemOpen(groupIdx == this.categoryManager.CurrentGroupIdx);
|
||||
if (ImGui.CollapsingHeader(groupInfo.Name))
|
||||
{
|
||||
if (this.categoryManager.CurrentGroupIdx != groupIdx)
|
||||
{
|
||||
this.categoryManager.CurrentGroupIdx = groupIdx;
|
||||
}
|
||||
|
||||
ImGui.Indent();
|
||||
for (int categoryIdx = 0; categoryIdx < groupInfo.Categories.Count; categoryIdx++)
|
||||
{
|
||||
var categoryInfo = Array.Find(this.categoryManager.CategoryList, x => x.CategoryId == groupInfo.Categories[categoryIdx]);
|
||||
|
||||
bool hasSearchHighlight = this.categoryManager.IsCategoryHighlighted(categoryInfo.CategoryId);
|
||||
if (hasSearchHighlight)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, colorSearchHighlight);
|
||||
}
|
||||
|
||||
if (ImGui.Selectable(categoryInfo.Name, this.categoryManager.CurrentCategoryIdx == categoryIdx))
|
||||
{
|
||||
this.categoryManager.CurrentCategoryIdx = categoryIdx;
|
||||
}
|
||||
|
||||
if (hasSearchHighlight)
|
||||
{
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Unindent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPluginCategoryContent()
|
||||
{
|
||||
if (!this.categoryManager.IsSelectionValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var groupInfo = this.categoryManager.GroupList[this.categoryManager.CurrentGroupIdx];
|
||||
if (groupInfo.GroupKind == PluginCategoryManager.GroupKind.DevTools)
|
||||
{
|
||||
// this one is never sorted and remains in hardcoded order from group ctor
|
||||
switch (this.categoryManager.CurrentCategoryIdx)
|
||||
{
|
||||
case 0:
|
||||
this.DrawInstalledDevPluginList();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
this.DrawImageTester();
|
||||
break;
|
||||
|
||||
default:
|
||||
// umm, there's nothing else, keep handled set and just skip drawing...
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (groupInfo.GroupKind == PluginCategoryManager.GroupKind.Installed)
|
||||
{
|
||||
this.DrawInstalledPluginList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var pluginList = this.pluginListAvailable;
|
||||
if (pluginList.Count > 0)
|
||||
{
|
||||
// reset opened list of collapsibles when switching between categories
|
||||
if (this.categoryManager.IsContentDirty)
|
||||
{
|
||||
this.openPluginCollapsibles.Clear();
|
||||
}
|
||||
|
||||
var filteredManifests = pluginList.Where(rm => !this.IsManifestFiltered(rm));
|
||||
var categoryManifestsList = this.categoryManager.GetCurrentCategoryContent(filteredManifests);
|
||||
|
||||
if (categoryManifestsList.Count > 0)
|
||||
{
|
||||
var i = 0;
|
||||
foreach (var manifest in categoryManifestsList)
|
||||
{
|
||||
var rmManifest = manifest as RemotePluginManifest;
|
||||
if (rmManifest != null)
|
||||
{
|
||||
ImGui.PushID($"{rmManifest.InternalName}{rmManifest.AssemblyVersion}");
|
||||
this.DrawAvailablePlugin(rmManifest, i++);
|
||||
ImGui.PopID();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text(Locs.TabBody_SearchNoMatching);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text(Locs.TabBody_SearchNoCompatible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawImageTester()
|
||||
{
|
||||
var sectionSize = ImGuiHelpers.GlobalScale * 66;
|
||||
|
|
@ -1763,6 +1914,8 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
.ToList();
|
||||
this.pluginListUpdatable = pluginManager.UpdatablePlugins.ToList();
|
||||
this.ResortPlugins();
|
||||
|
||||
this.UpdateCategoriesOnPluginsChange();
|
||||
}
|
||||
|
||||
private void OnInstalledPluginsChanged()
|
||||
|
|
@ -1773,6 +1926,8 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
this.pluginListUpdatable = pluginManager.UpdatablePlugins.ToList();
|
||||
this.hasDevPlugins = this.pluginListInstalled.Any(plugin => plugin.IsDev);
|
||||
this.ResortPlugins();
|
||||
|
||||
this.UpdateCategoriesOnPluginsChange();
|
||||
}
|
||||
|
||||
private void ResortPlugins()
|
||||
|
|
@ -2111,6 +2266,25 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
return output;
|
||||
}
|
||||
|
||||
private void UpdateCategoriesOnSearchChange()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.searchText))
|
||||
{
|
||||
this.categoryManager.SetCategoryHighlightsForPlugins(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var pluginsMatchingSearch = this.pluginListAvailable.Where(rm => !this.IsManifestFiltered(rm));
|
||||
this.categoryManager.SetCategoryHighlightsForPlugins(pluginsMatchingSearch);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCategoriesOnPluginsChange()
|
||||
{
|
||||
this.categoryManager.BuildCategories(this.pluginListAvailable);
|
||||
this.UpdateCategoriesOnSearchChange();
|
||||
}
|
||||
|
||||
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "Disregard here")]
|
||||
private static class Locs
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue