mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 13:14:17 +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>
|
/// <summary>
|
||||||
/// Dispatch the active plugins changed event.
|
/// Dispatch the active plugins changed event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="kind">What action caused this event to be fired.</param>
|
/// <param name="args">The event arguments containing information about the change.</param>
|
||||||
/// <param name="affectedThisPlugin">If this plugin was affected by the change.</param>
|
internal void NotifyActivePluginsChanged(ActivePluginsChangedEventArgs args)
|
||||||
internal void NotifyActivePluginsChanged(PluginListInvalidationKind kind, bool affectedThisPlugin)
|
|
||||||
{
|
{
|
||||||
foreach (var action in Delegate.EnumerateInvocationList(this.ActivePluginsChanged))
|
foreach (var action in Delegate.EnumerateInvocationList(this.ActivePluginsChanged))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
action(kind, affectedThisPlugin);
|
action(args);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -32,9 +32,8 @@ public interface IDalamudPluginInterface
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delegate for events that listen to changes to the list of active plugins.
|
/// Delegate for events that listen to changes to the list of active plugins.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="kind">What action caused this event to be fired.</param>
|
/// <param name="args">The event arguments containing information about the change.</param>
|
||||||
/// <param name="affectedThisPlugin">If this plugin was affected by the change.</param>
|
public delegate void ActivePluginsChangedDelegate(ActivePluginsChangedEventArgs args);
|
||||||
public delegate void ActivePluginsChangedDelegate(PluginListInvalidationKind kind, bool affectedThisPlugin);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event that gets fired when loc is changed
|
/// Event that gets fired when loc is changed
|
||||||
|
|
|
||||||
|
|
@ -1307,9 +1307,7 @@ internal class PluginManager : IInternalDisposableService
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
installedPlugin.DalamudInterface.NotifyActivePluginsChanged(
|
installedPlugin.DalamudInterface.NotifyActivePluginsChanged(
|
||||||
kind,
|
new ActivePluginsChangedEventArgs(kind, affectedInternalNames));
|
||||||
// ReSharper disable once PossibleMultipleEnumeration
|
|
||||||
affectedInternalNames.Contains(installedPlugin.Manifest.InternalName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue