mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add ActivePluginsChangedEventArgs
This commit is contained in:
parent
6d69b74d0a
commit
089f0c9495
4 changed files with 26 additions and 11 deletions
19
Dalamud/Plugin/ActivePluginsChangedEventArgs.cs
Normal file
19
Dalamud/Plugin/ActivePluginsChangedEventArgs.cs
Normal 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;
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue