Add ActivePluginsChangedEventArgs

This commit is contained in:
Haselnussbomber 2025-08-04 03:15:43 +02:00
parent 6d69b74d0a
commit 089f0c9495
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
4 changed files with 26 additions and 11 deletions

View file

@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace Dalamud.Plugin;
/// <summary>
/// Contains data about changes to the list of active plugins.
/// </summary>
public class ActivePluginsChangedEventArgs(PluginListInvalidationKind kind, IEnumerable<string> affectedInternalNames) : EventArgs
{
/// <summary>
/// Gets the invalidation kind that caused this event to be fired.
/// </summary>
public PluginListInvalidationKind Kind { get; } = kind;
/// <summary>
/// Gets the InternalNames of affected plugins.
/// </summary>
public IEnumerable<string> AffectedInternalNames { get; } = affectedInternalNames;
}

View file

@ -523,15 +523,14 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
/// <summary>
/// Dispatch the active plugins changed event.
/// </summary>
/// <param name="kind">What action caused this event to be fired.</param>
/// <param name="affectedThisPlugin">If this plugin was affected by the change.</param>
internal void NotifyActivePluginsChanged(PluginListInvalidationKind kind, bool affectedThisPlugin)
/// <param name="args">The event arguments containing information about the change.</param>
internal void NotifyActivePluginsChanged(ActivePluginsChangedEventArgs args)
{
foreach (var action in Delegate.EnumerateInvocationList(this.ActivePluginsChanged))
{
try
{
action(kind, affectedThisPlugin);
action(args);
}
catch (Exception ex)
{

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
@ -32,9 +32,8 @@ public interface IDalamudPluginInterface
/// <summary>
/// Delegate for events that listen to changes to the list of active plugins.
/// </summary>
/// <param name="kind">What action caused this event to be fired.</param>
/// <param name="affectedThisPlugin">If this plugin was affected by the change.</param>
public delegate void ActivePluginsChangedDelegate(PluginListInvalidationKind kind, bool affectedThisPlugin);
/// <param name="args">The event arguments containing information about the change.</param>
public delegate void ActivePluginsChangedDelegate(ActivePluginsChangedEventArgs args);
/// <summary>
/// Event that gets fired when loc is changed

View file

@ -1307,9 +1307,7 @@ internal class PluginManager : IInternalDisposableService
continue;
installedPlugin.DalamudInterface.NotifyActivePluginsChanged(
kind,
// ReSharper disable once PossibleMultipleEnumeration
affectedInternalNames.Contains(installedPlugin.Manifest.InternalName));
new ActivePluginsChangedEventArgs(kind, affectedInternalNames));
}
}