mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
parent
7a5bdb6bde
commit
5650bf3ae0
1 changed files with 28 additions and 2 deletions
|
|
@ -76,6 +76,17 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
|||
this.configuration.QueueSave();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event type fired each time a DtrEntry was removed.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the bar entry.</param>
|
||||
internal delegate void DtrEntryRemovedDelegate(string title);
|
||||
|
||||
/// <summary>
|
||||
/// Event fired each time a DtrEntry was removed.
|
||||
/// </summary>
|
||||
internal event DtrEntryRemovedDelegate? DtrEntryRemoved;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IReadOnlyList<IReadOnlyDtrBarEntry> Entries => this.entries;
|
||||
|
||||
|
|
@ -136,6 +147,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
|||
if (data.ShouldBeRemoved)
|
||||
{
|
||||
this.RemoveEntry(data);
|
||||
this.DtrEntryRemoved?.Invoke(data.Title);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -525,7 +537,6 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
|||
/// Plugin-scoped version of a AddonEventManager service.
|
||||
/// </summary>
|
||||
[PluginInterface]
|
||||
|
||||
[ServiceManager.ScopedService]
|
||||
#pragma warning disable SA1015
|
||||
[ResolveVia<IDtrBar>]
|
||||
|
|
@ -536,13 +547,23 @@ internal class DtrBarPluginScoped : IInternalDisposableService, IDtrBar
|
|||
private readonly DtrBar dtrBarService = Service<DtrBar>.Get();
|
||||
|
||||
private readonly Dictionary<string, IDtrBarEntry> pluginEntries = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DtrBarPluginScoped"/> class.
|
||||
/// </summary>
|
||||
internal DtrBarPluginScoped()
|
||||
{
|
||||
this.dtrBarService.DtrEntryRemoved += this.OnDtrEntryRemoved;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IReadOnlyList<IReadOnlyDtrBarEntry> Entries => this.dtrBarService.Entries;
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IInternalDisposableService.DisposeService()
|
||||
{
|
||||
this.dtrBarService.DtrEntryRemoved -= this.OnDtrEntryRemoved;
|
||||
|
||||
foreach (var entry in this.pluginEntries)
|
||||
{
|
||||
entry.Value.Remove();
|
||||
|
|
@ -569,4 +590,9 @@ internal class DtrBarPluginScoped : IInternalDisposableService, IDtrBar
|
|||
this.pluginEntries.Remove(title);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDtrEntryRemoved(string title)
|
||||
{
|
||||
this.pluginEntries.Remove(title);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue