mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-27 19:09:18 +01:00
fix: find matching plugins when importing a profile
This commit is contained in:
parent
a9f6d6d104
commit
6e54c085fa
3 changed files with 27 additions and 0 deletions
|
|
@ -1299,6 +1299,9 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
}
|
||||
|
||||
// Perform a migration from InternalName to GUIDs. The plugin should definitely have a GUID here.
|
||||
// This will also happen if you are installing a plugin with the installer, and that's intended!
|
||||
// It means that, if you have a profile which has unsatisfied plugins, installing a matching plugin will
|
||||
// enter it into the profiles it can match.
|
||||
if (plugin.Manifest.WorkingPluginId == Guid.Empty)
|
||||
throw new Exception("Plugin should have a WorkingPluginId at this point");
|
||||
this.profileManager.MigrateProfilesToGuidsForPlugin(plugin.Manifest.InternalName, plugin.Manifest.WorkingPluginId);
|
||||
|
|
|
|||
|
|
@ -246,6 +246,10 @@ internal class Profile
|
|||
{
|
||||
foreach (var plugin in this.modelV1.Plugins)
|
||||
{
|
||||
// TODO: What should happen if a profile has a GUID locked in, but the plugin
|
||||
// is not installed anymore? That probably means that the user uninstalled the plugin
|
||||
// and is now reinstalling it. We should still satisfy that and update the ID.
|
||||
|
||||
if (plugin.InternalName == internalName && plugin.WorkingPluginId == Guid.Empty)
|
||||
{
|
||||
plugin.WorkingPluginId = newGuid;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,27 @@ internal class ProfileManager : IServiceType
|
|||
newModel.Guid = Guid.NewGuid();
|
||||
newModel.Name = this.GenerateUniqueProfileName(newModel.Name.IsNullOrEmpty() ? "Unknown Collection" : newModel.Name);
|
||||
if (newModel is ProfileModelV1 modelV1)
|
||||
{
|
||||
// Disable it
|
||||
modelV1.IsEnabled = false;
|
||||
|
||||
// Try to find matching plugins for all plugins in the profile
|
||||
var pm = Service<PluginManager>.Get();
|
||||
foreach (var plugin in modelV1.Plugins)
|
||||
{
|
||||
var installedPlugin = pm.InstalledPlugins.FirstOrDefault(x => x.Manifest.InternalName == plugin.InternalName);
|
||||
if (installedPlugin != null)
|
||||
{
|
||||
Log.Information("Satisfying plugin {InternalName} for profile {Name} with {Guid}", plugin.InternalName, newModel.Name, installedPlugin.Manifest.WorkingPluginId);
|
||||
plugin.WorkingPluginId = installedPlugin.Manifest.WorkingPluginId;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning("Couldn't find plugin {InternalName} for profile {Name}", plugin.InternalName, newModel.Name);
|
||||
plugin.WorkingPluginId = Guid.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.config.SavedProfiles!.Add(newModel);
|
||||
this.config.QueueSave();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue