chore: don't persist load all api levels, banned plugins

This commit is contained in:
goat 2022-07-14 19:28:35 +02:00
parent bc348cf181
commit 33f7140b75
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
5 changed files with 20 additions and 44 deletions

View file

@ -228,16 +228,6 @@ namespace Dalamud.Configuration.Internal
/// </summary> /// </summary>
public string DalamudBetaKind { get; set; } public string DalamudBetaKind { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not all plugins, regardless of API level, should be loaded.
/// </summary>
public bool LoadAllApiLevels { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not banned plugins should be loaded.
/// </summary>
public bool LoadBannedPlugins { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether or not any plugin should be loaded when the game is started. /// Gets or sets a value indicating whether or not any plugin should be loaded when the game is started.
/// It is reset immediately when read. /// It is reset immediately when read.

View file

@ -764,16 +764,14 @@ namespace Dalamud.Interface.Internal
ImGui.Separator(); ImGui.Separator();
if (ImGui.MenuItem("Load all API levels (ONLY FOR DEVELOPERS!!!)", null, configuration.LoadAllApiLevels)) if (ImGui.MenuItem("Load all API levels (ONLY FOR DEVELOPERS!!!)", null, pluginManager.LoadAllApiLevels))
{ {
configuration.LoadAllApiLevels = !configuration.LoadAllApiLevels; pluginManager.LoadAllApiLevels = !pluginManager.LoadAllApiLevels;
configuration.Save();
} }
if (ImGui.MenuItem("Load blacklisted plugins", null, configuration.LoadBannedPlugins)) if (ImGui.MenuItem("Load blacklisted plugins", null, pluginManager.LoadBannedPlugins))
{ {
configuration.LoadBannedPlugins = !configuration.LoadBannedPlugins; pluginManager.LoadBannedPlugins = !pluginManager.LoadBannedPlugins;
configuration.Save();
} }
ImGui.Separator(); ImGui.Separator();

View file

@ -1710,7 +1710,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
var disabled = this.updateStatus == OperationStatus.InProgress || this.installStatus == OperationStatus.InProgress; var disabled = this.updateStatus == OperationStatus.InProgress || this.installStatus == OperationStatus.InProgress;
// Disable everything if the plugin is outdated // Disable everything if the plugin is outdated
disabled = disabled || (plugin.IsOutdated && !configuration.LoadAllApiLevels) || plugin.IsBanned; disabled = disabled || (plugin.IsOutdated && !pluginManager.LoadAllApiLevels) || plugin.IsBanned;
// Disable everything if the plugin is orphaned // Disable everything if the plugin is orphaned
disabled = disabled || plugin.IsOrphaned; disabled = disabled || plugin.IsOrphaned;

View file

@ -137,6 +137,16 @@ internal partial class PluginManager : IDisposable, IServiceType
/// </summary> /// </summary>
public PluginConfigurations PluginConfigs { get; } public PluginConfigurations PluginConfigs { get; }
/// <summary>
/// Gets or sets a value indicating whether plugins of all API levels will be loaded.
/// </summary>
public bool LoadAllApiLevels { get; set; }
/// <summary>
/// Gets or sets a value indicating whether banned plugins will be loaded.
/// </summary>
public bool LoadBannedPlugins { get; set; }
/// <summary> /// <summary>
/// Print to chat any plugin updates and whether they were successful. /// Print to chat any plugin updates and whether they were successful.
/// </summary> /// </summary>
@ -839,28 +849,6 @@ internal partial class PluginManager : IDisposable, IServiceType
{ {
Log.Information($"Missing manifest: cleaning up {versionDir.FullName}"); Log.Information($"Missing manifest: cleaning up {versionDir.FullName}");
versionDir.Delete(true); versionDir.Delete(true);
continue;
}
var manifest = LocalPluginManifest.Load(manifestFile);
if (manifest.Disabled)
{
Log.Information($"Disabled: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
continue;
}
if (manifest.DalamudApiLevel < DalamudApiLevel - 1 && !this.configuration.LoadAllApiLevels)
{
Log.Information($"Lower API: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
continue;
}
if (manifest.ApplicableVersion <this.startInfo.GameVersion)
{
Log.Information($"Inapplicable version: cleaning up {versionDir.FullName}");
versionDir.Delete(true);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -1042,15 +1030,15 @@ internal partial class PluginManager : IDisposable, IServiceType
public bool IsManifestEligible(PluginManifest manifest) public bool IsManifestEligible(PluginManifest manifest)
{ {
// Testing exclusive // Testing exclusive
if (manifest.IsTestingExclusive && !configuration.DoPluginTest) if (manifest.IsTestingExclusive && !this.configuration.DoPluginTest)
return false; return false;
// Applicable version // Applicable version
if (manifest.ApplicableVersion <this.startInfo.GameVersion) if (manifest.ApplicableVersion < this.startInfo.GameVersion)
return false; return false;
// API level // API level
if (manifest.DalamudApiLevel < DalamudApiLevel && !configuration.LoadAllApiLevels) if (manifest.DalamudApiLevel < DalamudApiLevel && !this.LoadAllApiLevels)
return false; return false;
// Banned // Banned
@ -1066,7 +1054,7 @@ internal partial class PluginManager : IDisposable, IServiceType
{ {
Debug.Assert(this.bannedPlugins != null, "this.bannedPlugins != null"); Debug.Assert(this.bannedPlugins != null, "this.bannedPlugins != null");
return !this.configuration.LoadBannedPlugins && this.bannedPlugins.Any(ban => (ban.Name == manifest.InternalName || ban.Name == Hash.GetStringSha256Hash(manifest.InternalName)) return !this.LoadBannedPlugins && this.bannedPlugins.Any(ban => (ban.Name == manifest.InternalName || ban.Name == Hash.GetStringSha256Hash(manifest.InternalName))
&& ban.AssemblyVersion >= manifest.AssemblyVersion); && ban.AssemblyVersion >= manifest.AssemblyVersion);
} }

View file

@ -307,7 +307,7 @@ internal class LocalPlugin : IDisposable
if (this.Manifest.ApplicableVersion < startInfo.GameVersion) if (this.Manifest.ApplicableVersion < startInfo.GameVersion)
throw new InvalidPluginOperationException($"Unable to load {this.Name}, no applicable version"); throw new InvalidPluginOperationException($"Unable to load {this.Name}, no applicable version");
if (this.Manifest.DalamudApiLevel < PluginManager.DalamudApiLevel && !configuration.LoadAllApiLevels) if (this.Manifest.DalamudApiLevel < PluginManager.DalamudApiLevel && !pluginManager.LoadAllApiLevels)
throw new InvalidPluginOperationException($"Unable to load {this.Name}, incompatible API level"); throw new InvalidPluginOperationException($"Unable to load {this.Name}, incompatible API level");
if (this.Manifest.Disabled) if (this.Manifest.Disabled)