Change to actively inject WithScene.

This commit is contained in:
Ottermandias 2023-06-13 21:22:12 +02:00
parent 20186afa49
commit 90722fcfbe

View file

@ -16,11 +16,11 @@ namespace Dalamud.Interface.DragDrop;
/// </summary> /// </summary>
[PluginInterface] [PluginInterface]
[ServiceManager.EarlyLoadedService] [ServiceManager.EarlyLoadedService]
[InherentDependency<InterfaceManager.InterfaceManagerWithScene>]
[ResolveVia<IDragDropManager>] [ResolveVia<IDragDropManager>]
internal partial class DragDropManager : IDisposable, IDragDropManager, IServiceType internal partial class DragDropManager : IDisposable, IDragDropManager, IServiceType
{ {
private readonly InterfaceManager interfaceManager = Service<InterfaceManager>.Get(); [ServiceManager.ServiceDependency]
private readonly InterfaceManager.InterfaceManagerWithScene interfaceManager = Service<InterfaceManager.InterfaceManagerWithScene>.Get();
private int lastDropFrame = -2; private int lastDropFrame = -2;
private int lastTooltipFrame = -1; private int lastTooltipFrame = -1;
@ -58,14 +58,14 @@ internal partial class DragDropManager : IDisposable, IDragDropManager, IService
try try
{ {
var ret = DragDropInterop.RegisterDragDrop(this.interfaceManager.WindowHandlePtr, this); var ret = DragDropInterop.RegisterDragDrop(this.interfaceManager.Manager.WindowHandlePtr, this);
Log.Information($"[DragDrop] Registered window {this.interfaceManager.WindowHandlePtr} for external drag and drop operations. ({ret})"); Log.Information($"[DragDrop] Registered window 0x{this.interfaceManager.Manager.WindowHandlePtr:X} for external drag and drop operations. ({ret})");
Marshal.ThrowExceptionForHR(ret); Marshal.ThrowExceptionForHR(ret);
this.ServiceAvailable = true; this.ServiceAvailable = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Could not create windows drag and drop utility:\n{ex}"); Log.Error($"Could not create windows drag and drop utility for window 0x{this.interfaceManager.Manager.WindowHandlePtr:X}:\n{ex}");
} }
} }
@ -79,13 +79,13 @@ internal partial class DragDropManager : IDisposable, IDragDropManager, IService
try try
{ {
var ret = DragDropInterop.RevokeDragDrop(this.interfaceManager!.WindowHandlePtr); var ret = DragDropInterop.RevokeDragDrop(this.interfaceManager.Manager.WindowHandlePtr);
Log.Information($"[DragDrop] Disabled external drag and drop operations for window {this.interfaceManager.WindowHandlePtr}. ({ret})"); Log.Information($"[DragDrop] Disabled external drag and drop operations for window 0x{this.interfaceManager.Manager.WindowHandlePtr:X}. ({ret})");
Marshal.ThrowExceptionForHR(ret); Marshal.ThrowExceptionForHR(ret);
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Could not disable windows drag and drop utility:\n{ex}"); Log.Error($"Could not disable windows drag and drop utility for window 0x{this.interfaceManager.Manager.WindowHandlePtr:X}:\n{ex}");
} }
this.ServiceAvailable = false; this.ServiceAvailable = false;