mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
clean up commented out code
This commit is contained in:
parent
3f112376eb
commit
75bf135978
2 changed files with 2 additions and 160 deletions
|
|
@ -268,21 +268,9 @@ internal class ProfileManager : IServiceType
|
||||||
|
|
||||||
private void LoadProfilesFromConfigInitially()
|
private void LoadProfilesFromConfigInitially()
|
||||||
{
|
{
|
||||||
var needMigration = false;
|
this.config.DefaultProfile ??= new ProfileModelV1();
|
||||||
if (this.config.DefaultProfile == null)
|
|
||||||
{
|
|
||||||
this.config.DefaultProfile = new ProfileModelV1();
|
|
||||||
needMigration = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.profiles.Add(new Profile(this, this.config.DefaultProfile, true, true));
|
this.profiles.Add(new Profile(this, this.config.DefaultProfile, true, true));
|
||||||
|
|
||||||
if (needMigration)
|
|
||||||
{
|
|
||||||
// Don't think we need this here with the migration logic in GetWantState
|
|
||||||
//this.MigratePluginsIntoDefaultProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.config.SavedProfiles ??= new List<ProfileModel>();
|
this.config.SavedProfiles ??= new List<ProfileModel>();
|
||||||
foreach (var profileModel in this.config.SavedProfiles)
|
foreach (var profileModel in this.config.SavedProfiles)
|
||||||
{
|
{
|
||||||
|
|
@ -291,72 +279,4 @@ internal class ProfileManager : IServiceType
|
||||||
|
|
||||||
this.config.QueueSave();
|
this.config.QueueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This duplicates some of the original handling in PM; don't care though
|
|
||||||
/*
|
|
||||||
private void MigratePluginsIntoDefaultProfile()
|
|
||||||
{
|
|
||||||
var pluginDirectory = new DirectoryInfo(Service<DalamudStartInfo>.Get().PluginDirectory!);
|
|
||||||
var pluginDefs = new List<PluginDef>();
|
|
||||||
|
|
||||||
Log.Information($"Now migrating plugins at {pluginDirectory} into profiles");
|
|
||||||
|
|
||||||
// Nothing to migrate
|
|
||||||
if (!pluginDirectory.Exists)
|
|
||||||
{
|
|
||||||
Log.Information("\t=> Plugin directory didn't exist, nothing to migrate");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add installed plugins. These are expected to be in a specific format so we can look for exactly that.
|
|
||||||
foreach (var pluginDir in pluginDirectory.GetDirectories())
|
|
||||||
{
|
|
||||||
var versionsDefs = new List<PluginDef>();
|
|
||||||
foreach (var versionDir in pluginDir.GetDirectories())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var dllFile = new FileInfo(Path.Combine(versionDir.FullName, $"{pluginDir.Name}.dll"));
|
|
||||||
var manifestFile = LocalPluginManifest.GetManifestFile(dllFile);
|
|
||||||
|
|
||||||
if (!manifestFile.Exists)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var manifest = LocalPluginManifest.Load(manifestFile);
|
|
||||||
versionsDefs.Add(new PluginDef(dllFile, manifest, false));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, "Could not load manifest for installed at {Directory}", versionDir.FullName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pluginDefs.Add(versionsDefs.MaxBy(x => x.Manifest!.EffectiveVersion));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex, "Couldn't choose best version for plugin: {Name}", pluginDir.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var defaultProfile = this.DefaultProfile;
|
|
||||||
foreach (var pluginDef in pluginDefs)
|
|
||||||
{
|
|
||||||
if (pluginDef.Manifest == null)
|
|
||||||
{
|
|
||||||
Log.Information($"\t=> Skipping DLL at {pluginDef.DllFile.FullName}, no valid manifest");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OK for migration code
|
|
||||||
#pragma warning disable CS0618
|
|
||||||
defaultProfile.AddOrUpdate(pluginDef.Manifest.InternalName, !pluginDef.Manifest.Disabled, false);
|
|
||||||
Log.Information(
|
|
||||||
$"\t=> Added {pluginDef.Manifest.InternalName} to default profile with {!pluginDef.Manifest.Disabled}");
|
|
||||||
#pragma warning restore CS0618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -200,14 +200,6 @@ internal class LocalPlugin : IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsLoaded => this.State == PluginState.Loaded;
|
public bool IsLoaded => this.State == PluginState.Loaded;
|
||||||
|
|
||||||
/*
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a value indicating whether the plugin is disabled.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("This is no longer accurate, use the profile manager instead.", true)]
|
|
||||||
public bool IsDisabled => this.Manifest.Disabled;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this plugin is wanted active by any profile.
|
/// Gets a value indicating whether this plugin is wanted active by any profile.
|
||||||
/// INCLUDES the default profile.
|
/// INCLUDES the default profile.
|
||||||
|
|
@ -349,7 +341,7 @@ internal class LocalPlugin : IDisposable
|
||||||
if (this.Manifest.DalamudApiLevel < PluginManager.DalamudApiLevel && !pluginManager.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");
|
||||||
|
|
||||||
// TODO: should we throw here?
|
// We might want to throw here?
|
||||||
if (!this.IsWantedByAnyProfile)
|
if (!this.IsWantedByAnyProfile)
|
||||||
Log.Warning("{Name} is loading, but isn't wanted by any profile", this.Name);
|
Log.Warning("{Name} is loading, but isn't wanted by any profile", this.Name);
|
||||||
|
|
||||||
|
|
@ -568,43 +560,6 @@ internal class LocalPlugin : IDisposable
|
||||||
await this.LoadAsync(PluginLoadReason.Reload, true);
|
await this.LoadAsync(PluginLoadReason.Reload, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
/// <summary>
|
|
||||||
/// Revert a disable. Must be unloaded first, does not load.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Profile API", true)]
|
|
||||||
public void Enable()
|
|
||||||
{
|
|
||||||
// Allowed: Unloaded, UnloadError
|
|
||||||
switch (this.State)
|
|
||||||
{
|
|
||||||
case PluginState.Loading:
|
|
||||||
case PluginState.Unloading:
|
|
||||||
case PluginState.Loaded:
|
|
||||||
case PluginState.LoadError:
|
|
||||||
throw new InvalidPluginOperationException($"Unable to enable {this.Name}, still loaded");
|
|
||||||
case PluginState.Unloaded:
|
|
||||||
break;
|
|
||||||
case PluginState.UnloadError:
|
|
||||||
break;
|
|
||||||
case PluginState.DependencyResolutionFailed:
|
|
||||||
throw new InvalidPluginOperationException($"Unable to enable {this.Name}, dependency resolution failed");
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(this.State.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE(goat): This is inconsequential, and we do have situations where a plugin can end up enabled but not loaded:
|
|
||||||
// Orphaned plugins can have their repo added back, but may not have been loaded at boot and may still be enabled.
|
|
||||||
// We don't want to disable orphaned plugins when they are orphaned so this is how it's going to be.
|
|
||||||
// if (!this.Manifest.Disabled)
|
|
||||||
// throw new InvalidPluginOperationException($"Unable to enable {this.Name}, not disabled");
|
|
||||||
|
|
||||||
this.Manifest.Disabled = false;
|
|
||||||
this.Manifest.ScheduledForDeletion = false;
|
|
||||||
this.SaveManifest();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if anything forbids this plugin from loading.
|
/// Check if anything forbids this plugin from loading.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -626,39 +581,6 @@ internal class LocalPlugin : IDisposable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
/// <summary>
|
|
||||||
/// Disable this plugin, must be unloaded first.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Profile API", true)]
|
|
||||||
public void Disable()
|
|
||||||
{
|
|
||||||
// Allowed: Unloaded, UnloadError
|
|
||||||
switch (this.State)
|
|
||||||
{
|
|
||||||
case PluginState.Loading:
|
|
||||||
case PluginState.Unloading:
|
|
||||||
case PluginState.Loaded:
|
|
||||||
case PluginState.LoadError:
|
|
||||||
throw new InvalidPluginOperationException($"Unable to disable {this.Name}, still loaded");
|
|
||||||
case PluginState.Unloaded:
|
|
||||||
break;
|
|
||||||
case PluginState.UnloadError:
|
|
||||||
break;
|
|
||||||
case PluginState.DependencyResolutionFailed:
|
|
||||||
return; // This is a no-op.
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(this.State.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.Manifest.Disabled)
|
|
||||||
throw new InvalidPluginOperationException($"Unable to disable {this.Name}, already disabled");
|
|
||||||
|
|
||||||
this.Manifest.Disabled = true;
|
|
||||||
this.SaveManifest();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Schedule the deletion of this plugin on next cleanup.
|
/// Schedule the deletion of this plugin on next cleanup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue