mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: let users delete policy-blocked and orphaned plugins
This commit is contained in:
parent
098607cca8
commit
2c011b6bcd
3 changed files with 44 additions and 20 deletions
|
|
@ -1724,7 +1724,6 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
}
|
||||
else if (plugin.State == PluginState.Loaded || plugin.State == PluginState.LoadError || plugin.State == PluginState.DependencyResolutionFailed)
|
||||
{
|
||||
// TODO: We should draw the trash can button for policy-blocked plugins in safe mode, so plugins can be deleted
|
||||
if (pluginManager.SafeMode)
|
||||
{
|
||||
ImGuiComponents.DisabledButton(Locs.PluginButton_SafeMode);
|
||||
|
|
@ -1932,8 +1931,10 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
|
||||
private void DrawDeletePluginButton(LocalPlugin plugin)
|
||||
{
|
||||
var unloaded = plugin.State == PluginState.Unloaded;
|
||||
var showButton = unloaded && (plugin.IsDev || plugin.IsOutdated || plugin.IsBanned || plugin.IsOrphaned);
|
||||
var unloaded = plugin.State == PluginState.Unloaded || plugin.State == PluginState.LoadError;
|
||||
|
||||
// When policy check fails, the plugin is never loaded
|
||||
var showButton = unloaded && (plugin.IsDev || plugin.IsOutdated || plugin.IsBanned || plugin.IsOrphaned || !plugin.CheckPolicy());
|
||||
|
||||
if (!showButton)
|
||||
return;
|
||||
|
|
@ -1941,6 +1942,19 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
var pluginManager = Service<PluginManager>.Get();
|
||||
|
||||
ImGui.SameLine();
|
||||
if (plugin.HasEverStartedLoad)
|
||||
{
|
||||
ImGui.PushFont(InterfaceManager.IconFont);
|
||||
ImGuiComponents.DisabledButton(FontAwesomeIcon.TrashAlt.ToIconString());
|
||||
ImGui.PopFont();
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip(Locs.PluginButtonToolTip_DeletePluginRestricted);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.TrashAlt))
|
||||
{
|
||||
try
|
||||
|
|
@ -1963,6 +1977,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
ImGui.SetTooltip(Locs.PluginButtonToolTip_DeletePlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawVisitRepoUrlButton(string? repoUrl)
|
||||
{
|
||||
|
|
@ -2369,6 +2384,8 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
|
|||
|
||||
public static string PluginButtonToolTip_DeletePlugin => Loc.Localize("InstallerDeletePlugin ", "Delete plugin");
|
||||
|
||||
public static string PluginButtonToolTip_DeletePluginRestricted => Loc.Localize("InstallerDeletePluginRestricted", "Cannot delete - please try restarting the game.");
|
||||
|
||||
public static string PluginButtonToolTip_VisitPluginUrl => Loc.Localize("InstallerVisitPluginUrl", "Visit plugin URL");
|
||||
|
||||
public static string PluginButtonToolTip_UpdateSingle(string version) => Loc.Localize("InstallerUpdateSingle", "Update to {0}").Format(version);
|
||||
|
|
|
|||
|
|
@ -771,8 +771,8 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
/// <param name="plugin">Plugin to remove.</param>
|
||||
public void RemovePlugin(LocalPlugin plugin)
|
||||
{
|
||||
if (plugin.State != PluginState.Unloaded)
|
||||
throw new InvalidPluginOperationException($"Unable to remove {plugin.Name}, not unloaded");
|
||||
if (plugin.State != PluginState.Unloaded && plugin.HasEverStartedLoad)
|
||||
throw new InvalidPluginOperationException($"Unable to remove {plugin.Name}, not unloaded and had loaded before");
|
||||
|
||||
lock (this.pluginListLock)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -189,6 +189,11 @@ internal class LocalPlugin : IDisposable
|
|||
/// </summary>
|
||||
public string BanReason { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the plugin has ever started to load.
|
||||
/// </summary>
|
||||
public bool HasEverStartedLoad { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the plugin is loaded and running.
|
||||
/// </summary>
|
||||
|
|
@ -335,6 +340,8 @@ internal class LocalPlugin : IDisposable
|
|||
"Please refer to https://github.com/goatcorp/Dalamud/discussions/603 for more information.");
|
||||
}
|
||||
|
||||
this.HasEverStartedLoad = true;
|
||||
|
||||
this.loader ??= PluginLoader.CreateFromAssemblyFile(this.DllFile.FullName, SetupLoaderConfig);
|
||||
|
||||
if (reloading || this.IsDev)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue