mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-21 15:27:43 +01:00
Load services asynchronously whenever possible (#893)
This commit is contained in:
parent
fba8c7163c
commit
8e7f370ddd
66 changed files with 959 additions and 899 deletions
|
|
@ -21,6 +21,7 @@ namespace Dalamud.Game.Gui
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed class ChatGui : IDisposable
|
||||
{
|
||||
private readonly ChatGuiAddressResolver address;
|
||||
|
|
@ -34,14 +35,11 @@ namespace Dalamud.Game.Gui
|
|||
|
||||
private IntPtr baseAddress = IntPtr.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChatGui"/> class.
|
||||
/// </summary>
|
||||
/// <param name="baseAddress">The base address of the ChatManager.</param>
|
||||
internal ChatGui()
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private ChatGui(SigScanner sigScanner)
|
||||
{
|
||||
this.address = new ChatGuiAddressResolver();
|
||||
this.address.Setup();
|
||||
this.address.Setup(sigScanner);
|
||||
|
||||
this.printMessageHook = new Hook<PrintMessageDelegate>(this.address.PrintMessage, this.HandlePrintMessageDetour);
|
||||
this.populateItemLinkHook = new Hook<PopulateItemLinkDelegate>(this.address.PopulateItemLinkObject, this.HandlePopulateItemLinkDetour);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ namespace Dalamud.Game.Gui.ContextMenus
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed class ContextMenu : IDisposable
|
||||
{
|
||||
private const int MaxContextMenuItemsPerContextMenu = 32;
|
||||
|
|
@ -47,13 +48,11 @@ namespace Dalamud.Game.Gui.ContextMenus
|
|||
private OpenSubContextMenuItem? selectedOpenSubContextMenuItem;
|
||||
private ContextMenuOpenedArgs? currentContextMenuOpenedArgs;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContextMenu"/> class.
|
||||
/// </summary>
|
||||
public ContextMenu()
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private ContextMenu(SigScanner sigScanner)
|
||||
{
|
||||
this.Address = new ContextMenuAddressResolver();
|
||||
this.Address.Setup();
|
||||
this.Address.Setup(sigScanner);
|
||||
|
||||
unsafe
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace Dalamud.Game.Gui.Dtr
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed unsafe class DtrBar : IDisposable
|
||||
{
|
||||
private const uint BaseNodeId = 1000;
|
||||
|
|
@ -24,13 +25,10 @@ namespace Dalamud.Game.Gui.Dtr
|
|||
private List<DtrBarEntry> entries = new();
|
||||
private uint runningNodeIds = BaseNodeId;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DtrBar"/> class.
|
||||
/// </summary>
|
||||
internal DtrBar()
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private DtrBar(DalamudConfiguration configuration)
|
||||
{
|
||||
Service<Framework>.Get().Update += this.Update;
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
|
||||
configuration.DtrOrder ??= new List<string>();
|
||||
configuration.DtrIgnore ??= new List<string>();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ namespace Dalamud.Game.Gui.FlyText
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed class FlyTextGui : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -28,13 +29,11 @@ namespace Dalamud.Game.Gui.FlyText
|
|||
/// </summary>
|
||||
private readonly Hook<CreateFlyTextDelegate> createFlyTextHook;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FlyTextGui"/> class.
|
||||
/// </summary>
|
||||
internal FlyTextGui()
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private FlyTextGui(SigScanner sigScanner)
|
||||
{
|
||||
this.Address = new FlyTextGuiAddressResolver();
|
||||
this.Address.Setup();
|
||||
this.Address.Setup(sigScanner);
|
||||
|
||||
this.addFlyTextNative = Marshal.GetDelegateForFunctionPointer<AddFlyTextDelegate>(this.Address.AddFlyText);
|
||||
this.createFlyTextHook = new Hook<CreateFlyTextDelegate>(this.Address.CreateFlyText, this.CreateFlyTextDetour);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ namespace Dalamud.Game.Gui
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed unsafe class GameGui : IDisposable
|
||||
{
|
||||
private readonly GameGuiAddressResolver address;
|
||||
|
|
@ -46,14 +47,11 @@ namespace Dalamud.Game.Gui
|
|||
private GetUIMapObjectDelegate getUIMapObject;
|
||||
private OpenMapWithFlagDelegate openMapWithFlag;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GameGui"/> class.
|
||||
/// This class is responsible for many aspects of interacting with the native game UI.
|
||||
/// </summary>
|
||||
internal GameGui()
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private GameGui(SigScanner sigScanner)
|
||||
{
|
||||
this.address = new GameGuiAddressResolver();
|
||||
this.address.Setup();
|
||||
this.address.Setup(sigScanner);
|
||||
|
||||
Log.Verbose("===== G A M E G U I =====");
|
||||
Log.Verbose($"GameGuiManager address 0x{this.address.BaseAddress.ToInt64():X}");
|
||||
|
|
@ -62,13 +60,6 @@ namespace Dalamud.Game.Gui
|
|||
Log.Verbose($"HandleItemOut address 0x{this.address.HandleItemOut.ToInt64():X}");
|
||||
Log.Verbose($"HandleImm address 0x{this.address.HandleImm.ToInt64():X}");
|
||||
|
||||
Service<ChatGui>.Set();
|
||||
Service<PartyFinderGui>.Set();
|
||||
Service<ToastGui>.Set();
|
||||
Service<FlyTextGui>.Set();
|
||||
Service<ContextMenu>.Set();
|
||||
Service<DtrBar>.Set();
|
||||
|
||||
this.setGlobalBgmHook = new Hook<SetGlobalBgmDelegate>(this.address.SetGlobalBgm, this.HandleSetGlobalBgmDetour);
|
||||
|
||||
this.handleItemHoverHook = new Hook<HandleItemHoverDelegate>(this.address.HandleItemHover, this.HandleItemHoverDetour);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ namespace Dalamud.Game.Gui.Internal
|
|||
/// <summary>
|
||||
/// This class handles IME for non-English users.
|
||||
/// </summary>
|
||||
[ServiceManager.EarlyLoadedService]
|
||||
internal unsafe class DalamudIME : IDisposable
|
||||
{
|
||||
private static readonly ModuleLog Log = new("IME");
|
||||
|
|
@ -32,7 +33,9 @@ namespace Dalamud.Game.Gui.Internal
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DalamudIME"/> class.
|
||||
/// </summary>
|
||||
internal DalamudIME()
|
||||
/// <param name="tag">Tag.</param>
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private DalamudIME()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace Dalamud.Game.Gui.PartyFinder
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed class PartyFinderGui : IDisposable
|
||||
{
|
||||
private readonly PartyFinderAddressResolver address;
|
||||
|
|
@ -25,10 +26,12 @@ namespace Dalamud.Game.Gui.PartyFinder
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PartyFinderGui"/> class.
|
||||
/// </summary>
|
||||
internal PartyFinderGui()
|
||||
/// <param name="tag">Tag.</param>
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private PartyFinderGui(SigScanner sigScanner)
|
||||
{
|
||||
this.address = new PartyFinderAddressResolver();
|
||||
this.address.Setup();
|
||||
this.address.Setup(sigScanner);
|
||||
|
||||
this.memory = Marshal.AllocHGlobal(PartyFinderPacket.PacketSize);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Dalamud.Game.Gui.Toast
|
|||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public sealed partial class ToastGui : IDisposable
|
||||
{
|
||||
private const uint QuestToastCheckmarkMagic = 60081;
|
||||
|
|
@ -31,10 +32,12 @@ namespace Dalamud.Game.Gui.Toast
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToastGui"/> class.
|
||||
/// </summary>
|
||||
internal ToastGui()
|
||||
/// <param name="tag">Tag.</param>
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private ToastGui(SigScanner sigScanner)
|
||||
{
|
||||
this.address = new ToastGuiAddressResolver();
|
||||
this.address.Setup();
|
||||
this.address.Setup(sigScanner);
|
||||
|
||||
this.showNormalToastHook = new Hook<ShowNormalToastDelegate>(this.address.ShowNormalToast, new ShowNormalToastDelegate(this.HandleNormalToastDetour));
|
||||
this.showQuestToastHook = new Hook<ShowQuestToastDelegate>(this.address.ShowQuestToast, new ShowQuestToastDelegate(this.HandleQuestToastDetour));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue