mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
pi: add "hidden" tab if there are any hidden plugins
This commit is contained in:
parent
3584f2cf3d
commit
21063217a5
3 changed files with 62 additions and 13 deletions
|
|
@ -23,6 +23,7 @@ internal class PluginCategoryManager
|
|||
new(CategoryKind.All, "special.all", () => Locs.Category_All),
|
||||
new(CategoryKind.IsTesting, "special.isTesting", () => Locs.Category_IsTesting, CategoryInfo.AppearCondition.DoPluginTest),
|
||||
new(CategoryKind.AvailableForTesting, "special.availableForTesting", () => Locs.Category_AvailableForTesting, CategoryInfo.AppearCondition.DoPluginTest),
|
||||
new(CategoryKind.Hidden, "special.hidden", () => Locs.Category_Hidden, CategoryInfo.AppearCondition.AnyHiddenPlugins),
|
||||
new(CategoryKind.DevInstalled, "special.devInstalled", () => Locs.Category_DevInstalled),
|
||||
new(CategoryKind.IconTester, "special.devIconTester", () => Locs.Category_IconTester),
|
||||
new(CategoryKind.DalamudChangelogs, "special.dalamud", () => Locs.Category_Dalamud),
|
||||
|
|
@ -106,6 +107,11 @@ internal class PluginCategoryManager
|
|||
/// </summary>
|
||||
AvailableForTesting = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Plugins that were hidden.
|
||||
/// </summary>
|
||||
Hidden = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Installed dev plugins.
|
||||
/// </summary>
|
||||
|
|
@ -309,6 +315,9 @@ internal class PluginCategoryManager
|
|||
{
|
||||
groupAvail.Categories.Add(this.CategoryList[categoryIdx].CategoryKind);
|
||||
}
|
||||
|
||||
// Hidden at the end
|
||||
groupAvail.Categories.Add(CategoryKind.Hidden);
|
||||
|
||||
// compare with prev state and mark as dirty if needed
|
||||
var noCategoryChanges = prevCategoryIds.SequenceEqual(groupAvail.Categories);
|
||||
|
|
@ -332,7 +341,10 @@ internal class PluginCategoryManager
|
|||
{
|
||||
var groupInfo = this.groupList[this.currentGroupIdx];
|
||||
|
||||
var includeAll = (this.currentCategoryKind == CategoryKind.All) || (groupInfo.GroupKind != GroupKind.Available);
|
||||
var includeAll = this.currentCategoryKind == CategoryKind.All ||
|
||||
this.currentCategoryKind == CategoryKind.Hidden ||
|
||||
groupInfo.GroupKind != GroupKind.Available;
|
||||
|
||||
if (includeAll)
|
||||
{
|
||||
result.AddRange(plugins);
|
||||
|
|
@ -455,6 +467,11 @@ internal class PluginCategoryManager
|
|||
/// Check if plugin testing is enabled.
|
||||
/// </summary>
|
||||
DoPluginTest,
|
||||
|
||||
/// <summary>
|
||||
/// Check if there are any hidden plugins.
|
||||
/// </summary>
|
||||
AnyHiddenPlugins,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -529,6 +546,8 @@ internal class PluginCategoryManager
|
|||
|
||||
public static string Category_AvailableForTesting => Loc.Localize("InstallerCategoryAvailableForTesting", "Testing Available");
|
||||
|
||||
public static string Category_Hidden => Loc.Localize("InstallerCategoryHidden", "Hidden");
|
||||
|
||||
public static string Category_DevInstalled => Loc.Localize("InstallerInstalledDevPlugins", "Installed Dev Plugins");
|
||||
|
||||
public static string Category_IconTester => "Image/Icon Tester";
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
private List<LocalPlugin> pluginListInstalled = new();
|
||||
private List<AvailablePluginUpdate> pluginListUpdatable = new();
|
||||
private bool hasDevPlugins = false;
|
||||
|
||||
private bool hasHiddenPlugins = false;
|
||||
|
||||
private string searchText = string.Empty;
|
||||
private bool isSearchTextPrefilled = false;
|
||||
|
||||
|
|
@ -1277,6 +1278,19 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
proxies.Add(new PluginInstallerAvailablePluginProxy(null, installedPlugin));
|
||||
}
|
||||
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
bool IsProxyHidden(PluginInstallerAvailablePluginProxy proxy)
|
||||
{
|
||||
var isHidden =
|
||||
configuration.HiddenPluginInternalName.Contains(proxy.RemoteManifest?.InternalName);
|
||||
if (this.categoryManager.CurrentCategoryKind == PluginCategoryManager.CategoryKind.Hidden)
|
||||
return isHidden;
|
||||
return !isHidden;
|
||||
}
|
||||
|
||||
// Filter out plugins that are not hidden
|
||||
proxies = proxies.Where(IsProxyHidden).ToList();
|
||||
|
||||
return proxies;
|
||||
}
|
||||
#pragma warning restore SA1201
|
||||
|
|
@ -1305,6 +1319,12 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
// Reset the category to "All" if we're on the "Hidden" category and there are no hidden plugins (we removed the last one)
|
||||
if (i == 0 && this.categoryManager.CurrentCategoryKind == PluginCategoryManager.CategoryKind.Hidden)
|
||||
{
|
||||
this.categoryManager.CurrentCategoryKind = PluginCategoryManager.CategoryKind.All;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawInstalledPluginList(InstalledPluginListFilter filter)
|
||||
|
|
@ -1471,6 +1491,10 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
if (!Service<DalamudConfiguration>.Get().DoPluginTest)
|
||||
continue;
|
||||
break;
|
||||
case PluginCategoryManager.CategoryInfo.AppearCondition.AnyHiddenPlugins:
|
||||
if (!this.hasHiddenPlugins)
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
|
@ -2456,12 +2480,19 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
pluginManager.RefilterPluginMasters();
|
||||
}
|
||||
|
||||
if (ImGui.Selectable(Locs.PluginContext_HidePlugin))
|
||||
var isHidden = configuration.HiddenPluginInternalName.Contains(manifest.InternalName);
|
||||
switch (isHidden)
|
||||
{
|
||||
Log.Debug($"Adding {manifest.InternalName} to hidden plugins");
|
||||
configuration.HiddenPluginInternalName.Add(manifest.InternalName);
|
||||
configuration.QueueSave();
|
||||
pluginManager.RefilterPluginMasters();
|
||||
case false when ImGui.Selectable(Locs.PluginContext_HidePlugin):
|
||||
configuration.HiddenPluginInternalName.Add(manifest.InternalName);
|
||||
configuration.QueueSave();
|
||||
pluginManager.RefilterPluginMasters();
|
||||
break;
|
||||
case true when ImGui.Selectable(Locs.PluginContext_UnhidePlugin):
|
||||
configuration.HiddenPluginInternalName.Remove(manifest.InternalName);
|
||||
configuration.QueueSave();
|
||||
pluginManager.RefilterPluginMasters();
|
||||
break;
|
||||
}
|
||||
|
||||
if (ImGui.Selectable(Locs.PluginContext_DeletePluginConfig))
|
||||
|
|
@ -3638,6 +3669,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
private void OnAvailablePluginsChanged()
|
||||
{
|
||||
var pluginManager = Service<PluginManager>.Get();
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
|
||||
lock (this.listLock)
|
||||
{
|
||||
|
|
@ -3647,6 +3679,8 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
this.pluginListUpdatable = pluginManager.UpdatablePlugins.ToList();
|
||||
this.ResortPlugins();
|
||||
}
|
||||
|
||||
this.hasHiddenPlugins = this.pluginListAvailable.Any(x => configuration.HiddenPluginInternalName.Contains(x.InternalName));
|
||||
|
||||
this.UpdateCategoriesOnPluginsChange();
|
||||
}
|
||||
|
|
@ -3974,6 +4008,8 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
public static string PluginContext_MarkAllSeen => Loc.Localize("InstallerMarkAllSeen", "Mark all as seen");
|
||||
|
||||
public static string PluginContext_HidePlugin => Loc.Localize("InstallerHidePlugin", "Hide from installer");
|
||||
|
||||
public static string PluginContext_UnhidePlugin => Loc.Localize("InstallerUnhidePlugin", "Unhide from installer");
|
||||
|
||||
public static string PluginContext_DeletePluginConfig => Loc.Localize("InstallerDeletePluginConfig", "Reset plugin data");
|
||||
|
||||
|
|
|
|||
|
|
@ -258,12 +258,6 @@ internal class PluginManager : IInternalDisposableService
|
|||
/// <returns>If the manifest is visible.</returns>
|
||||
public static bool IsManifestVisible(RemotePluginManifest manifest)
|
||||
{
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
|
||||
// Hidden by user
|
||||
if (configuration.HiddenPluginInternalName.Contains(manifest.InternalName))
|
||||
return false;
|
||||
|
||||
// Hidden by manifest
|
||||
return !manifest.IsHide;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue