mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Add IPartyFinderGui (v9) (#1279)
This commit is contained in:
parent
385c4b7a8b
commit
d378fe1dfc
2 changed files with 59 additions and 16 deletions
|
|
@ -6,6 +6,7 @@ using Dalamud.Game.Gui.PartyFinder.Types;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.Gui.PartyFinder;
|
namespace Dalamud.Game.Gui.PartyFinder;
|
||||||
|
|
@ -13,10 +14,9 @@ namespace Dalamud.Game.Gui.PartyFinder;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class handles interacting with the native PartyFinder window.
|
/// This class handles interacting with the native PartyFinder window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PluginInterface]
|
|
||||||
[InterfaceVersion("1.0")]
|
[InterfaceVersion("1.0")]
|
||||||
[ServiceManager.BlockingEarlyLoadedService]
|
[ServiceManager.BlockingEarlyLoadedService]
|
||||||
public sealed class PartyFinderGui : IDisposable, IServiceType
|
internal sealed class PartyFinderGui : IDisposable, IServiceType, IPartyFinderGui
|
||||||
{
|
{
|
||||||
private readonly PartyFinderAddressResolver address;
|
private readonly PartyFinderAddressResolver address;
|
||||||
private readonly IntPtr memory;
|
private readonly IntPtr memory;
|
||||||
|
|
@ -35,25 +35,14 @@ public sealed class PartyFinderGui : IDisposable, IServiceType
|
||||||
|
|
||||||
this.memory = Marshal.AllocHGlobal(PartyFinderPacket.PacketSize);
|
this.memory = Marshal.AllocHGlobal(PartyFinderPacket.PacketSize);
|
||||||
|
|
||||||
this.receiveListingHook = Hook<ReceiveListingDelegate>.FromAddress(this.address.ReceiveListing, new ReceiveListingDelegate(this.HandleReceiveListingDetour));
|
this.receiveListingHook = Hook<ReceiveListingDelegate>.FromAddress(this.address.ReceiveListing, this.HandleReceiveListingDetour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event type fired each time the game receives an individual Party Finder listing.
|
|
||||||
/// Cannot modify listings but can hide them.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="listing">The listings received.</param>
|
|
||||||
/// <param name="args">Additional arguments passed by the game.</param>
|
|
||||||
public delegate void PartyFinderListingEventDelegate(PartyFinderListing listing, PartyFinderListingEventArgs args);
|
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||||
private delegate void ReceiveListingDelegate(IntPtr managerPtr, IntPtr data);
|
private delegate void ReceiveListingDelegate(IntPtr managerPtr, IntPtr data);
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Event fired each time the game receives an individual Party Finder listing.
|
public event IPartyFinderGui.PartyFinderListingEventDelegate? ReceiveListing;
|
||||||
/// Cannot modify listings but can hide them.
|
|
||||||
/// </summary>
|
|
||||||
public event PartyFinderListingEventDelegate ReceiveListing;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of managed and unmanaged resources.
|
/// Dispose of managed and unmanaged resources.
|
||||||
|
|
@ -138,3 +127,34 @@ public sealed class PartyFinderGui : IDisposable, IServiceType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PluginInterface]
|
||||||
|
[InterfaceVersion("1.0")]
|
||||||
|
[ServiceManager.ScopedService]
|
||||||
|
#pragma warning disable SA1015
|
||||||
|
[ResolveVia<IPartyFinderGui>]
|
||||||
|
#pragma warning restore SA1015
|
||||||
|
internal class PartyFinderGuiPluginScoped : IDisposable, IServiceType, IPartyFinderGui
|
||||||
|
{
|
||||||
|
[ServiceManager.ServiceDependency]
|
||||||
|
private readonly PartyFinderGui partyFinderGuiService = Service<PartyFinderGui>.Get();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="PartyFinderGuiPluginScoped"/> class.
|
||||||
|
/// </summary>
|
||||||
|
internal PartyFinderGuiPluginScoped()
|
||||||
|
{
|
||||||
|
this.partyFinderGuiService.ReceiveListing += this.ReceiveListingForward;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public event IPartyFinderGui.PartyFinderListingEventDelegate? ReceiveListing;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
this.partyFinderGuiService.ReceiveListing -= this.ReceiveListingForward;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReceiveListingForward(PartyFinderListing listing, PartyFinderListingEventArgs args) => this.ReceiveListing?.Invoke(listing, args);
|
||||||
|
}
|
||||||
|
|
|
||||||
23
Dalamud/Plugin/Services/IPartyFinderGui.cs
Normal file
23
Dalamud/Plugin/Services/IPartyFinderGui.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Dalamud.Game.Gui.PartyFinder.Types;
|
||||||
|
|
||||||
|
namespace Dalamud.Plugin.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class handles interacting with the native PartyFinder window.
|
||||||
|
/// </summary>
|
||||||
|
public interface IPartyFinderGui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event type fired each time the game receives an individual Party Finder listing.
|
||||||
|
/// Cannot modify listings but can hide them.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="listing">The listings received.</param>
|
||||||
|
/// <param name="args">Additional arguments passed by the game.</param>
|
||||||
|
public delegate void PartyFinderListingEventDelegate(PartyFinderListing listing, PartyFinderListingEventArgs args);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event fired each time the game receives an individual Party Finder listing.
|
||||||
|
/// Cannot modify listings but can hide them.
|
||||||
|
/// </summary>
|
||||||
|
public event PartyFinderListingEventDelegate ReceiveListing;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue