mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Move IsAvailableForTesting to IPluginManifest
This commit is contained in:
parent
0bc44154aa
commit
191aa8d696
6 changed files with 30 additions and 41 deletions
|
|
@ -294,7 +294,7 @@ internal class PluginCategoryManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PluginManager.HasTestingVersion(manifest) || manifest.IsTestingExclusive)
|
if (manifest.IsTestingExclusive || manifest.IsAvailableForTesting)
|
||||||
categoryList.Add(CategoryKind.AvailableForTesting);
|
categoryList.Add(CategoryKind.AvailableForTesting);
|
||||||
|
|
||||||
// always add, even if empty
|
// always add, even if empty
|
||||||
|
|
|
||||||
|
|
@ -2593,8 +2593,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
var pluginManager = Service<PluginManager>.Get();
|
var pluginManager = Service<PluginManager>.Get();
|
||||||
|
|
||||||
var hasTestingVersionAvailable = configuration.DoPluginTest &&
|
var hasTestingVersionAvailable = configuration.DoPluginTest && manifest.IsAvailableForTesting;
|
||||||
PluginManager.HasTestingVersion(manifest);
|
|
||||||
|
|
||||||
if (ImGui.BeginPopupContextItem("ItemContextMenu"u8))
|
if (ImGui.BeginPopupContextItem("ItemContextMenu"u8))
|
||||||
{
|
{
|
||||||
|
|
@ -2689,8 +2688,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
label += Locs.PluginTitleMod_TestingVersion;
|
label += Locs.PluginTitleMod_TestingVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasTestingAvailable = this.pluginListAvailable.Any(x => x.InternalName == plugin.InternalName &&
|
var hasTestingAvailable = this.pluginListAvailable.Any(x => x.InternalName == plugin.InternalName && x.IsAvailableForTesting);
|
||||||
x.IsAvailableForTesting);
|
|
||||||
if (hasTestingAvailable && configuration.DoPluginTest && testingOptIn == null)
|
if (hasTestingAvailable && configuration.DoPluginTest && testingOptIn == null)
|
||||||
{
|
{
|
||||||
label += Locs.PluginTitleMod_TestingAvailable;
|
label += Locs.PluginTitleMod_TestingAvailable;
|
||||||
|
|
|
||||||
|
|
@ -278,26 +278,6 @@ internal class PluginManager : IInternalDisposableService
|
||||||
return !manifest.IsHide;
|
return !manifest.IsHide;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if a manifest even has an available testing version.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="manifest">The manifest to test.</param>
|
|
||||||
/// <returns>Whether a testing version is available.</returns>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a disposable that will lock plugin lists while it is not disposed.
|
/// Get a disposable that will lock plugin lists while it is not disposed.
|
||||||
/// You must NEVER use this in async code.
|
/// 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);
|
return this.configuration.PluginTestingOptIns!.Any(x => x.InternalName == manifest.InternalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="manifest">Manifest to check.</param>
|
||||||
|
/// <returns>A value indicating whether testing can be used.</returns>
|
||||||
|
public bool CanUseTesting(IPluginManifest manifest)
|
||||||
|
{
|
||||||
|
if (!this.configuration.DoPluginTest)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return manifest.IsTestingExclusive || manifest.IsAvailableForTesting;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For a given manifest, determine if the testing version should be used over the normal version.
|
/// 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.
|
/// The higher of the two versions is calculated after checking other settings.
|
||||||
|
|
@ -379,16 +373,7 @@ internal class PluginManager : IInternalDisposableService
|
||||||
/// <returns>A value indicating whether testing should be used.</returns>
|
/// <returns>A value indicating whether testing should be used.</returns>
|
||||||
public bool UseTesting(IPluginManifest manifest)
|
public bool UseTesting(IPluginManifest manifest)
|
||||||
{
|
{
|
||||||
if (!this.configuration.DoPluginTest)
|
return this.CanUseTesting(manifest) && this.HasTestingOptIn(manifest);
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!this.HasTestingOptIn(manifest))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (manifest.IsTestingExclusive)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return HasTestingVersion(manifest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Dalamud.Plugin.Internal.Types.Manifest;
|
namespace Dalamud.Plugin.Internal.Types.Manifest;
|
||||||
|
|
||||||
|
|
@ -118,4 +118,9 @@ public interface IPluginManifest
|
||||||
/// Gets an URL for the plugin's icon.
|
/// Gets an URL for the plugin's icon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? IconUrl { get; }
|
public string? IconUrl { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this plugin is eligible for testing.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsAvailableForTesting { get; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,4 @@ internal record RemotePluginManifest : PluginManifest
|
||||||
/// Gets or sets the changelog to be shown when obtaining the testing version of the plugin.
|
/// Gets or sets the changelog to be shown when obtaining the testing version of the plugin.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? TestingChangelog { get; set; }
|
public string? TestingChangelog { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a value indicating whether this plugin is eligible for testing.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsAvailableForTesting => this.TestingAssemblyVersion != null && this.TestingAssemblyVersion > this.AssemblyVersion;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,4 +160,10 @@ internal record PluginManifest : IPluginManifest
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
[JsonProperty("_Dip17Channel")]
|
[JsonProperty("_Dip17Channel")]
|
||||||
public string? Dip17Channel { get; init; }
|
public string? Dip17Channel { get; init; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool IsAvailableForTesting
|
||||||
|
=> this.TestingAssemblyVersion != null &&
|
||||||
|
this.TestingAssemblyVersion > this.AssemblyVersion &&
|
||||||
|
this.TestingDalamudApiLevel == PluginManager.DalamudApiLevel;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue