diff --git a/Dalamud/Interface/Internal/PluginCategoryManager.cs b/Dalamud/Interface/Internal/PluginCategoryManager.cs index 71c869ede..d3aea7f57 100644 --- a/Dalamud/Interface/Internal/PluginCategoryManager.cs +++ b/Dalamud/Interface/Internal/PluginCategoryManager.cs @@ -294,7 +294,7 @@ internal class PluginCategoryManager } } - if (PluginManager.HasTestingVersion(manifest) || manifest.IsTestingExclusive) + if (manifest.IsTestingExclusive || manifest.IsAvailableForTesting) categoryList.Add(CategoryKind.AvailableForTesting); // always add, even if empty diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 946a5f19a..b203b3894 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -2454,10 +2454,11 @@ internal class PluginInstallerWindow : Window, IDisposable var configuration = Service.Get(); var pluginManager = Service.Get(); + var canUseTesting = pluginManager.CanUseTesting(manifest); var useTesting = pluginManager.UseTesting(manifest); var wasSeen = this.WasPluginSeen(manifest.InternalName); - var effectiveApiLevel = useTesting && manifest.TestingDalamudApiLevel != null ? manifest.TestingDalamudApiLevel.Value : manifest.DalamudApiLevel; + var effectiveApiLevel = useTesting ? manifest.TestingDalamudApiLevel.Value : manifest.DalamudApiLevel; var isOutdated = effectiveApiLevel < PluginManager.DalamudApiLevel; var isIncompatible = manifest.MinimumDalamudVersion != null && @@ -2487,7 +2488,7 @@ internal class PluginInstallerWindow : Window, IDisposable { label += Locs.PluginTitleMod_TestingExclusive; } - else if (configuration.DoPluginTest && PluginManager.HasTestingVersion(manifest)) + else if (canUseTesting) { label += Locs.PluginTitleMod_TestingAvailable; } @@ -2593,8 +2594,7 @@ internal class PluginInstallerWindow : Window, IDisposable var configuration = Service.Get(); var pluginManager = Service.Get(); - var hasTestingVersionAvailable = configuration.DoPluginTest && - PluginManager.HasTestingVersion(manifest); + var hasTestingVersionAvailable = configuration.DoPluginTest && manifest.IsAvailableForTesting; if (ImGui.BeginPopupContextItem("ItemContextMenu"u8)) { @@ -2689,8 +2689,7 @@ internal class PluginInstallerWindow : Window, IDisposable label += Locs.PluginTitleMod_TestingVersion; } - var hasTestingAvailable = this.pluginListAvailable.Any(x => x.InternalName == plugin.InternalName && - x.IsAvailableForTesting); + var hasTestingAvailable = this.pluginListAvailable.Any(x => x.InternalName == plugin.InternalName && x.IsAvailableForTesting); if (hasTestingAvailable && configuration.DoPluginTest && testingOptIn == null) { label += Locs.PluginTitleMod_TestingAvailable; @@ -3784,16 +3783,7 @@ internal class PluginInstallerWindow : Window, IDisposable private bool IsManifestFiltered(IPluginManifest manifest) { - var hasSearchString = !string.IsNullOrWhiteSpace(this.searchText); - var oldApi = (manifest.TestingDalamudApiLevel == null - || manifest.TestingDalamudApiLevel < PluginManager.DalamudApiLevel) - && manifest.DalamudApiLevel < PluginManager.DalamudApiLevel; - var installed = this.IsManifestInstalled(manifest).IsInstalled; - - if (oldApi && !hasSearchString && !installed) - return true; - - if (!hasSearchString) + if (string.IsNullOrWhiteSpace(this.searchText)) return false; return this.GetManifestSearchScore(manifest) < 1; diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 4dee52b7e..fd5c048c7 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -278,26 +278,6 @@ internal class PluginManager : IInternalDisposableService return !manifest.IsHide; } - /// - /// Check if a manifest even has an available testing version. - /// - /// The manifest to test. - /// Whether a testing version is available. - public static bool HasTestingVersion(IPluginManifest manifest) - { - var av = manifest.AssemblyVersion; - var tv = manifest.TestingAssemblyVersion; - var hasTv = tv != null; - - if (hasTv) - { - return tv > av && - manifest.TestingDalamudApiLevel == DalamudApiLevel; - } - - return false; - } - /// /// Get a disposable that will lock plugin lists while it is not disposed. /// You must NEVER use this in async code. @@ -371,6 +351,20 @@ internal class PluginManager : IInternalDisposableService return this.configuration.PluginTestingOptIns!.Any(x => x.InternalName == manifest.InternalName); } + /// + /// For a given manifest, determine if the testing version can be used over the normal version. + /// The higher of the two versions is calculated after checking other settings. + /// + /// Manifest to check. + /// A value indicating whether testing can be used. + public bool CanUseTesting(IPluginManifest manifest) + { + if (!this.configuration.DoPluginTest) + return false; + + return manifest.IsTestingExclusive || manifest.IsAvailableForTesting; + } + /// /// For a given manifest, determine if the testing version should be used over the normal version. /// The higher of the two versions is calculated after checking other settings. @@ -379,16 +373,7 @@ internal class PluginManager : IInternalDisposableService /// A value indicating whether testing should be used. public bool UseTesting(IPluginManifest manifest) { - if (!this.configuration.DoPluginTest) - return false; - - if (!this.HasTestingOptIn(manifest)) - return false; - - if (manifest.IsTestingExclusive) - return true; - - return HasTestingVersion(manifest); + return this.CanUseTesting(manifest) && this.HasTestingOptIn(manifest); } /// @@ -1208,9 +1193,18 @@ internal class PluginManager : IInternalDisposableService return false; // API level - we keep the API before this in the installer to show as "outdated" - var effectiveApiLevel = this.UseTesting(manifest) && manifest.TestingDalamudApiLevel != null ? manifest.TestingDalamudApiLevel.Value : manifest.DalamudApiLevel; - if (effectiveApiLevel < DalamudApiLevel - 1 && !this.LoadAllApiLevels) - return false; + if (!this.LoadAllApiLevels) + { + var effectiveDalamudApiLevel = + this.CanUseTesting(manifest) && + manifest.TestingDalamudApiLevel.HasValue && + manifest.TestingDalamudApiLevel.Value > manifest.DalamudApiLevel + ? manifest.TestingDalamudApiLevel.Value + : manifest.DalamudApiLevel; + + if (effectiveDalamudApiLevel < PluginManager.DalamudApiLevel - 1) + return false; + } // Banned if (this.IsManifestBanned(manifest)) diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs index 70b1db872..da8ec8ff9 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs @@ -301,7 +301,7 @@ internal class LocalPlugin : IAsyncDisposable throw new PluginPreconditionFailedException($"Unable to load {this.Name}, game is newer than applicable version {this.manifest.ApplicableVersion}"); // We want to allow loading dev plugins with a lower API level than the current Dalamud API level, for ease of development - if (this.manifest.EffectiveApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels && !this.IsDev) + if (!pluginManager.LoadAllApiLevels && !this.IsDev && this.manifest.EffectiveApiLevel < PluginManager.DalamudApiLevel) throw new PluginPreconditionFailedException($"Unable to load {this.Name}, incompatible API level {this.manifest.EffectiveApiLevel}"); // We might want to throw here? diff --git a/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs b/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs index 5ab5abbc1..c770c80be 100644 --- a/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs +++ b/Dalamud/Plugin/Internal/Types/Manifest/IPluginManifest.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Dalamud.Plugin.Internal.Types.Manifest; @@ -118,4 +118,9 @@ public interface IPluginManifest /// Gets an URL for the plugin's icon. /// public string? IconUrl { get; } + + /// + /// Gets a value indicating whether this plugin is eligible for testing. + /// + public bool IsAvailableForTesting { get; } } diff --git a/Dalamud/Plugin/Internal/Types/Manifest/RemotePluginManifest.cs b/Dalamud/Plugin/Internal/Types/Manifest/RemotePluginManifest.cs index e3d99a85a..47e92cd84 100644 --- a/Dalamud/Plugin/Internal/Types/Manifest/RemotePluginManifest.cs +++ b/Dalamud/Plugin/Internal/Types/Manifest/RemotePluginManifest.cs @@ -21,9 +21,4 @@ internal record RemotePluginManifest : PluginManifest /// Gets or sets the changelog to be shown when obtaining the testing version of the plugin. /// public string? TestingChangelog { get; set; } - - /// - /// Gets a value indicating whether this plugin is eligible for testing. - /// - public bool IsAvailableForTesting => this.TestingAssemblyVersion != null && this.TestingAssemblyVersion > this.AssemblyVersion; } diff --git a/Dalamud/Plugin/Internal/Types/PluginManifest.cs b/Dalamud/Plugin/Internal/Types/PluginManifest.cs index 57001d63b..cbf69bb5e 100644 --- a/Dalamud/Plugin/Internal/Types/PluginManifest.cs +++ b/Dalamud/Plugin/Internal/Types/PluginManifest.cs @@ -160,4 +160,11 @@ internal record PluginManifest : IPluginManifest /// [JsonProperty("_Dip17Channel")] public string? Dip17Channel { get; init; } + + /// + [JsonIgnore] + public bool IsAvailableForTesting + => this.TestingAssemblyVersion != null && + this.TestingAssemblyVersion > this.AssemblyVersion && + this.TestingDalamudApiLevel == PluginManager.DalamudApiLevel; }