mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
track internal name nonetheless
This commit is contained in:
parent
256f4989f7
commit
9024c9b00c
6 changed files with 21 additions and 18 deletions
|
|
@ -2579,7 +2579,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
if (inProfile)
|
if (inProfile)
|
||||||
{
|
{
|
||||||
Task.Run(() => profile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, true))
|
Task.Run(() => profile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true))
|
||||||
.ContinueWith(this.DisplayErrorContinuation, Locs.Profiles_CouldNotAdd);
|
.ContinueWith(this.DisplayErrorContinuation, Locs.Profiles_CouldNotAdd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -2604,7 +2604,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Times))
|
if (ImGuiComponents.IconButton(FontAwesomeIcon.Times))
|
||||||
{
|
{
|
||||||
// TODO: Work this out
|
// TODO: Work this out
|
||||||
Task.Run(() => profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.IsLoaded, false))
|
Task.Run(() => profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, plugin.IsLoaded, false))
|
||||||
.GetAwaiter().GetResult();
|
.GetAwaiter().GetResult();
|
||||||
foreach (var profile in profileManager.Profiles.Where(x => !x.IsDefaultProfile && x.Plugins.Any(y => y.InternalName == plugin.Manifest.InternalName)))
|
foreach (var profile in profileManager.Profiles.Where(x => !x.IsDefaultProfile && x.Plugins.Any(y => y.InternalName == plugin.Manifest.InternalName)))
|
||||||
{
|
{
|
||||||
|
|
@ -2682,7 +2682,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
await plugin.UnloadAsync();
|
await plugin.UnloadAsync();
|
||||||
await applicableProfile.AddOrUpdateAsync(
|
await applicableProfile.AddOrUpdateAsync(
|
||||||
plugin.Manifest.WorkingPluginId, false, false);
|
plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
|
||||||
|
|
||||||
notifications.AddNotification(Locs.Notifications_PluginDisabled(plugin.Manifest.Name), Locs.Notifications_PluginDisabledTitle, NotificationType.Success);
|
notifications.AddNotification(Locs.Notifications_PluginDisabled(plugin.Manifest.Name), Locs.Notifications_PluginDisabledTitle, NotificationType.Success);
|
||||||
}).ContinueWith(t =>
|
}).ContinueWith(t =>
|
||||||
|
|
@ -2699,7 +2699,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
this.loadingIndicatorKind = LoadingIndicatorKind.EnablingSingle;
|
this.loadingIndicatorKind = LoadingIndicatorKind.EnablingSingle;
|
||||||
this.enableDisableWorkingPluginId = plugin.Manifest.WorkingPluginId;
|
this.enableDisableWorkingPluginId = plugin.Manifest.WorkingPluginId;
|
||||||
|
|
||||||
await applicableProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, true, false);
|
await applicableProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false);
|
||||||
await plugin.LoadAsync(PluginLoadReason.Installer);
|
await plugin.LoadAsync(PluginLoadReason.Installer);
|
||||||
|
|
||||||
notifications.AddNotification(Locs.Notifications_PluginEnabled(plugin.Manifest.Name), Locs.Notifications_PluginEnabledTitle, NotificationType.Success);
|
notifications.AddNotification(Locs.Notifications_PluginEnabled(plugin.Manifest.Name), Locs.Notifications_PluginEnabledTitle, NotificationType.Success);
|
||||||
|
|
@ -2720,7 +2720,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
if (shouldUpdate)
|
if (shouldUpdate)
|
||||||
{
|
{
|
||||||
// We need to update the profile right here, because PM will not enable the plugin otherwise
|
// We need to update the profile right here, because PM will not enable the plugin otherwise
|
||||||
await applicableProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, true, false);
|
await applicableProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false);
|
||||||
await this.UpdateSinglePlugin(availableUpdate);
|
await this.UpdateSinglePlugin(availableUpdate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ internal class ProfileManagerWidget
|
||||||
|
|
||||||
if (ImGui.Selectable($"{plugin.Manifest.Name}{(plugin is LocalDevPlugin ? "(dev plugin)" : string.Empty)}###selector{plugin.Manifest.InternalName}"))
|
if (ImGui.Selectable($"{plugin.Manifest.Name}{(plugin is LocalDevPlugin ? "(dev plugin)" : string.Empty)}###selector{plugin.Manifest.InternalName}"))
|
||||||
{
|
{
|
||||||
Task.Run(() => profile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, true, false))
|
Task.Run(() => profile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false))
|
||||||
.ContinueWith(this.installer.DisplayErrorContinuation, Locs.ErrorCouldNotChangeState);
|
.ContinueWith(this.installer.DisplayErrorContinuation, Locs.ErrorCouldNotChangeState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -508,7 +508,7 @@ internal class ProfileManagerWidget
|
||||||
var enabled = profileEntry.IsEnabled;
|
var enabled = profileEntry.IsEnabled;
|
||||||
if (ImGui.Checkbox($"###{this.editingProfileGuid}-{profileEntry.InternalName}", ref enabled))
|
if (ImGui.Checkbox($"###{this.editingProfileGuid}-{profileEntry.InternalName}", ref enabled))
|
||||||
{
|
{
|
||||||
Task.Run(() => profile.AddOrUpdateAsync(profileEntry.WorkingPluginId, enabled))
|
Task.Run(() => profile.AddOrUpdateAsync(profileEntry.WorkingPluginId, profileEntry.InternalName, enabled))
|
||||||
.ContinueWith(this.installer.DisplayErrorContinuation, Locs.ErrorCouldNotChangeState);
|
.ContinueWith(this.installer.DisplayErrorContinuation, Locs.ErrorCouldNotChangeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1511,28 +1511,28 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
{
|
{
|
||||||
// We didn't want this plugin, and StartOnBoot is on. That means we don't want it and it should stay off until manually enabled.
|
// We didn't want this plugin, and StartOnBoot is on. That means we don't want it and it should stay off until manually enabled.
|
||||||
Log.Verbose("DevPlugin {Name} disabled and StartOnBoot => disable", plugin.Manifest.InternalName);
|
Log.Verbose("DevPlugin {Name} disabled and StartOnBoot => disable", plugin.Manifest.InternalName);
|
||||||
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, false, false);
|
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
|
||||||
loadPlugin = false;
|
loadPlugin = false;
|
||||||
}
|
}
|
||||||
else if (wantsInDefaultProfile == true && devPlugin.StartOnBoot)
|
else if (wantsInDefaultProfile == true && devPlugin.StartOnBoot)
|
||||||
{
|
{
|
||||||
// We wanted this plugin, and StartOnBoot is on. That means we actually do want it.
|
// We wanted this plugin, and StartOnBoot is on. That means we actually do want it.
|
||||||
Log.Verbose("DevPlugin {Name} enabled and StartOnBoot => enable", plugin.Manifest.InternalName);
|
Log.Verbose("DevPlugin {Name} enabled and StartOnBoot => enable", plugin.Manifest.InternalName);
|
||||||
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, true, false);
|
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false);
|
||||||
loadPlugin = !doNotLoad;
|
loadPlugin = !doNotLoad;
|
||||||
}
|
}
|
||||||
else if (wantsInDefaultProfile == true && !devPlugin.StartOnBoot)
|
else if (wantsInDefaultProfile == true && !devPlugin.StartOnBoot)
|
||||||
{
|
{
|
||||||
// We wanted this plugin, but StartOnBoot is off. This means we don't want it anymore.
|
// We wanted this plugin, but StartOnBoot is off. This means we don't want it anymore.
|
||||||
Log.Verbose("DevPlugin {Name} enabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
|
Log.Verbose("DevPlugin {Name} enabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
|
||||||
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, false, false);
|
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
|
||||||
loadPlugin = false;
|
loadPlugin = false;
|
||||||
}
|
}
|
||||||
else if (wantsInDefaultProfile == false && !devPlugin.StartOnBoot)
|
else if (wantsInDefaultProfile == false && !devPlugin.StartOnBoot)
|
||||||
{
|
{
|
||||||
// We didn't want this plugin, and StartOnBoot is off. We don't want it.
|
// We didn't want this plugin, and StartOnBoot is off. We don't want it.
|
||||||
Log.Verbose("DevPlugin {Name} disabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
|
Log.Verbose("DevPlugin {Name} disabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
|
||||||
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, false, false);
|
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
|
||||||
loadPlugin = false;
|
loadPlugin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1544,7 +1544,7 @@ internal partial class PluginManager : IDisposable, IServiceType
|
||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
|
|
||||||
// Need to do this here, so plugins that don't load are still added to the default profile
|
// Need to do this here, so plugins that don't load are still added to the default profile
|
||||||
var wantToLoad = await this.profileManager.GetWantStateAsync(plugin.Manifest.WorkingPluginId, defaultState);
|
var wantToLoad = await this.profileManager.GetWantStateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, defaultState);
|
||||||
|
|
||||||
if (loadPlugin)
|
if (loadPlugin)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -158,10 +158,11 @@ internal class Profile
|
||||||
/// This will block until all states have been applied.
|
/// This will block until all states have been applied.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="workingPluginId">The ID of the plugin.</param>
|
/// <param name="workingPluginId">The ID of the plugin.</param>
|
||||||
|
/// <param name="internalName">The internal name of the plugin, if available.</param>
|
||||||
/// <param name="state">Whether or not the plugin should be enabled.</param>
|
/// <param name="state">Whether or not the plugin should be enabled.</param>
|
||||||
/// <param name="apply">Whether or not the current state should immediately be applied.</param>
|
/// <param name="apply">Whether or not the current state should immediately be applied.</param>
|
||||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||||
public async Task AddOrUpdateAsync(Guid workingPluginId, bool state, bool apply = true)
|
public async Task AddOrUpdateAsync(Guid workingPluginId, string? internalName, bool state, bool apply = true)
|
||||||
{
|
{
|
||||||
Debug.Assert(workingPluginId != Guid.Empty, "Trying to add plugin with empty guid");
|
Debug.Assert(workingPluginId != Guid.Empty, "Trying to add plugin with empty guid");
|
||||||
|
|
||||||
|
|
@ -176,6 +177,7 @@ internal class Profile
|
||||||
{
|
{
|
||||||
this.modelV1.Plugins.Add(new ProfileModelV1.ProfileModelV1Plugin
|
this.modelV1.Plugins.Add(new ProfileModelV1.ProfileModelV1Plugin
|
||||||
{
|
{
|
||||||
|
InternalName = internalName,
|
||||||
WorkingPluginId = workingPluginId,
|
WorkingPluginId = workingPluginId,
|
||||||
IsEnabled = state,
|
IsEnabled = state,
|
||||||
});
|
});
|
||||||
|
|
@ -219,7 +221,7 @@ internal class Profile
|
||||||
{
|
{
|
||||||
if (!this.IsDefaultProfile)
|
if (!this.IsDefaultProfile)
|
||||||
{
|
{
|
||||||
await this.manager.DefaultProfile.AddOrUpdateAsync(workingPluginId, this.IsEnabled && entry.IsEnabled, false);
|
await this.manager.DefaultProfile.AddOrUpdateAsync(workingPluginId, entry.InternalName, this.IsEnabled && entry.IsEnabled, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,11 @@ internal class ProfileManager : IServiceType
|
||||||
/// Check if any enabled profile wants a specific plugin enabled.
|
/// Check if any enabled profile wants a specific plugin enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="workingPluginId">The ID of the plugin.</param>
|
/// <param name="workingPluginId">The ID of the plugin.</param>
|
||||||
|
/// <param name="internalName">The internal name of the plugin, if available.</param>
|
||||||
/// <param name="defaultState">The state the plugin shall be in, if it needs to be added.</param>
|
/// <param name="defaultState">The state the plugin shall be in, if it needs to be added.</param>
|
||||||
/// <param name="addIfNotDeclared">Whether or not the plugin should be added to the default preset, if it's not present in any preset.</param>
|
/// <param name="addIfNotDeclared">Whether or not the plugin should be added to the default preset, if it's not present in any preset.</param>
|
||||||
/// <returns>Whether or not the plugin shall be enabled.</returns>
|
/// <returns>Whether or not the plugin shall be enabled.</returns>
|
||||||
public async Task<bool> GetWantStateAsync(Guid workingPluginId, bool defaultState, bool addIfNotDeclared = true)
|
public async Task<bool> GetWantStateAsync(Guid workingPluginId, string? internalName, bool defaultState, bool addIfNotDeclared = true)
|
||||||
{
|
{
|
||||||
var want = false;
|
var want = false;
|
||||||
var wasInAnyProfile = false;
|
var wasInAnyProfile = false;
|
||||||
|
|
@ -93,8 +94,8 @@ internal class ProfileManager : IServiceType
|
||||||
|
|
||||||
if (!wasInAnyProfile && addIfNotDeclared)
|
if (!wasInAnyProfile && addIfNotDeclared)
|
||||||
{
|
{
|
||||||
Log.Warning("{Guid} was not in any profile, adding to default with {Default}", workingPluginId, defaultState);
|
Log.Warning("'{Guid}'('{InternalName}') was not in any profile, adding to default with {Default}", workingPluginId, internalName, defaultState);
|
||||||
await this.DefaultProfile.AddOrUpdateAsync(workingPluginId, defaultState, false);
|
await this.DefaultProfile.AddOrUpdateAsync(workingPluginId, internalName, defaultState, false);
|
||||||
|
|
||||||
return defaultState;
|
return defaultState;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ internal class LocalPlugin : IDisposable
|
||||||
/// INCLUDES the default profile.
|
/// INCLUDES the default profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsWantedByAnyProfile =>
|
public bool IsWantedByAnyProfile =>
|
||||||
Service<ProfileManager>.Get().GetWantStateAsync(this.manifest.WorkingPluginId, false, false).GetAwaiter().GetResult();
|
Service<ProfileManager>.Get().GetWantStateAsync(this.manifest.WorkingPluginId, this.Manifest.InternalName, false, false).GetAwaiter().GetResult();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this plugin's API level is out of date.
|
/// Gets a value indicating whether this plugin's API level is out of date.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue