diff --git a/Dalamud/Interface/Internal/PluginCategoryManager.cs b/Dalamud/Interface/Internal/PluginCategoryManager.cs index 208e898f7..6854b887a 100644 --- a/Dalamud/Interface/Internal/PluginCategoryManager.cs +++ b/Dalamud/Interface/Internal/PluginCategoryManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using CheapLoc; +using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal.Types; namespace Dalamud.Interface.Internal; @@ -20,6 +21,8 @@ internal class PluginCategoryManager private readonly CategoryInfo[] categoryList = { new(0, "special.all", () => Locs.Category_All), + new(1, "special.isTesting", () => Locs.Category_IsTesting, CategoryInfo.AppearCondition.DoPluginTest), + new(2, "special.availableForTesting", () => Locs.Category_AvailableForTesting, CategoryInfo.AppearCondition.DoPluginTest), new(10, "special.devInstalled", () => Locs.Category_DevInstalled), new(11, "special.devIconTester", () => Locs.Category_IconTester), new(12, "special.dalamud", () => Locs.Category_Dalamud), @@ -39,7 +42,7 @@ internal class PluginCategoryManager private GroupInfo[] groupList = { new(GroupKind.DevTools, () => Locs.Group_DevTools, 10, 11), - new(GroupKind.Installed, () => Locs.Group_Installed, 0), + new(GroupKind.Installed, () => Locs.Group_Installed, 0, 1), new(GroupKind.Available, () => Locs.Group_Available, 0), new(GroupKind.Changelog, () => Locs.Group_Changelog, 0, 12, 13), @@ -153,11 +156,11 @@ internal class PluginCategoryManager var categoryList = new List(); var allCategoryIndices = new List(); - foreach (var plugin in availablePlugins) + foreach (var manifest in availablePlugins) { categoryList.Clear(); - var pluginCategoryTags = this.GetCategoryTagsForManifest(plugin); + var pluginCategoryTags = this.GetCategoryTagsForManifest(manifest); if (pluginCategoryTags != null) { foreach (var tag in pluginCategoryTags) @@ -180,12 +183,16 @@ internal class PluginCategoryManager } } + if (PluginManager.HasTestingVersion(manifest) || manifest.IsTestingExclusive) + categoryList.Add(2); + // always add, even if empty - this.mapPluginCategories.Add(plugin, categoryList.ToArray()); + this.mapPluginCategories.Add(manifest, categoryList.ToArray()); } // sort all categories by their loc name allCategoryIndices.Sort((idxX, idxY) => this.CategoryList[idxX].Name.CompareTo(this.CategoryList[idxY].Name)); + allCategoryIndices.Insert(0, 2); // "Available for testing" // rebuild all categories in group, leaving first entry = All intact and always on top if (groupAvail.Categories.Count > 1) @@ -321,13 +328,36 @@ internal class PluginCategoryManager /// Unique id of category. /// Tag to match. /// Function returning localized name of category. - public CategoryInfo(int categoryId, string tag, Func nameFunc) + /// Condition to be checked when deciding whether this category should be shown. + public CategoryInfo(int categoryId, string tag, Func nameFunc, AppearCondition condition = AppearCondition.None) { this.CategoryId = categoryId; this.Tag = tag; this.nameFunc = nameFunc; + this.Condition = condition; } + /// + /// Conditions for categories. + /// + public enum AppearCondition + { + /// + /// Check no conditions. + /// + None, + + /// + /// Check if plugin testing is enabled. + /// + DoPluginTest, + } + + /// + /// Gets or sets the condition to be checked when rendering. + /// + public AppearCondition Condition { get; set; } + /// /// Gets the name of category. /// @@ -390,6 +420,10 @@ internal class PluginCategoryManager public static string Category_All => Loc.Localize("InstallerCategoryAll", "All"); + public static string Category_IsTesting => Loc.Localize("InstallerCategoryIsTesting", "Currently Testing"); + + public static string Category_AvailableForTesting => Loc.Localize("InstallerCategoryAvailableForTesting", "Testing Available"); + public static string Category_DevInstalled => Loc.Localize("InstallerInstalledDevPlugins", "Installed Dev Plugins"); public static string Category_IconTester => "Image/Icon Tester"; diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 987038e73..59aec9893 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -918,9 +918,10 @@ internal class PluginInstallerWindow : Window, IDisposable } } - private void DrawInstalledPluginList() + private void DrawInstalledPluginList(bool filterTesting) { var pluginList = this.pluginListInstalled; + var manager = Service.Get(); if (pluginList.Count == 0) { @@ -941,6 +942,9 @@ internal class PluginInstallerWindow : Window, IDisposable var i = 0; foreach (var plugin in filteredList) { + if (filterTesting && !manager.HasTestingOptIn(plugin.Manifest)) + continue; + this.DrawInstalledPlugin(plugin, i++); } } @@ -1043,6 +1047,19 @@ internal class PluginInstallerWindow : Window, IDisposable { var categoryInfo = Array.Find(this.categoryManager.CategoryList, x => x.CategoryId == groupInfo.Categories[categoryIdx]); + switch (categoryInfo.Condition) + { + case PluginCategoryManager.CategoryInfo.AppearCondition.None: + // Do nothing + break; + case PluginCategoryManager.CategoryInfo.AppearCondition.DoPluginTest: + if (!Service.Get().DoPluginTest) + continue; + break; + default: + throw new ArgumentOutOfRangeException(); + } + var hasSearchHighlight = this.categoryManager.IsCategoryHighlighted(categoryInfo.CategoryId); if (hasSearchHighlight) { @@ -1135,7 +1152,17 @@ internal class PluginInstallerWindow : Window, IDisposable break; case PluginCategoryManager.GroupKind.Installed: - this.DrawInstalledPluginList(); + switch (this.categoryManager.CurrentCategoryIdx) + { + case 0: + this.DrawInstalledPluginList(false); + break; + + case 1: + this.DrawInstalledPluginList(true); + break; + } + break; case PluginCategoryManager.GroupKind.Changelog: switch (this.categoryManager.CurrentCategoryIdx) @@ -1677,7 +1704,6 @@ internal class PluginInstallerWindow : Window, IDisposable var pluginManager = Service.Get(); var useTesting = pluginManager.UseTesting(manifest); - var activelyTesting = useTesting || manifest.IsTestingExclusive; var wasSeen = this.WasPluginSeen(manifest.InternalName); var isOutdated = manifest.DalamudApiLevel < PluginManager.DalamudApiLevel; @@ -1693,10 +1719,14 @@ internal class PluginInstallerWindow : Window, IDisposable var label = manifest.Name; // Testing - if (activelyTesting) + if (useTesting) { label += Locs.PluginTitleMod_TestingVersion; } + else if (manifest.IsTestingExclusive) + { + label += Locs.PluginTitleMod_TestingExclusive; + } else if (configuration.DoPluginTest && PluginManager.HasTestingVersion(manifest)) { label += Locs.PluginTitleMod_TestingAvailable; @@ -2832,7 +2862,9 @@ internal class PluginInstallerWindow : Window, IDisposable public static string PluginTitleMod_TestingVersion => Loc.Localize("InstallerTestingVersion", " (testing version)"); - public static string PluginTitleMod_TestingAvailable => Loc.Localize("InstallerTestingAvailable", " (available for testing)"); + public static string PluginTitleMod_TestingExclusive => Loc.Localize("InstallerTestingExclusive", " (testing exclusive)"); + + public static string PluginTitleMod_TestingAvailable => Loc.Localize("InstallerTestingAvailable", " (has testing version)"); public static string PluginTitleMod_DevPlugin => Loc.Localize("InstallerDevPlugin", " (dev plugin)");