From 32f1168f1571fdff72fa4c3add29d3673c651ae5 Mon Sep 17 00:00:00 2001 From: Raymond Date: Wed, 6 Oct 2021 09:25:57 -0400 Subject: [PATCH] Implement assemblyLocation and assemblyDirectory in DPI --- Dalamud/Plugin/DalamudPluginInterface.cs | 15 ++++++++++++++- Dalamud/Plugin/Internal/LocalPlugin.cs | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index d3f416404..fb1741f87 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -35,9 +35,10 @@ namespace Dalamud.Plugin /// Set up the interface and populate all fields needed. /// /// The internal name of the plugin. + /// Location of the assembly. /// The reason the plugin was loaded. /// A value indicating whether this is a dev plugin. - internal DalamudPluginInterface(string pluginName, PluginLoadReason reason, bool isDev) + internal DalamudPluginInterface(string pluginName, FileInfo assemblyLocation, PluginLoadReason reason, bool isDev) { var configuration = Service.Get(); var dataManager = Service.Get(); @@ -46,6 +47,8 @@ namespace Dalamud.Plugin this.UiBuilder = new UiBuilder(pluginName); this.pluginName = pluginName; + this.AssemblyLocation = assemblyLocation; + this.AssemblyDirectory = new DirectoryInfo(assemblyLocation.DirectoryName!); this.configs = Service.Get().PluginConfigs; this.Reason = reason; this.IsDev = isDev; @@ -113,6 +116,16 @@ namespace Dalamud.Plugin /// public DirectoryInfo DalamudAssetDirectory => Service.Get().AssetDirectory; + /// + /// Gets the location of your plugin assembly. + /// + public FileInfo AssemblyLocation { get; } + + /// + /// Gets the directory your plugin assembly and bundled files are stored in. + /// + public DirectoryInfo AssemblyDirectory { get; } + /// /// Gets the directory your plugin configurations are stored in. /// diff --git a/Dalamud/Plugin/Internal/LocalPlugin.cs b/Dalamud/Plugin/Internal/LocalPlugin.cs index a0d49e434..8207b08e6 100644 --- a/Dalamud/Plugin/Internal/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalPlugin.cs @@ -309,7 +309,7 @@ namespace Dalamud.Plugin.Internal // Update the location for the Location and CodeBase patches PluginManager.PluginLocations[this.pluginType.Assembly.FullName] = new(this.DllFile); - this.DalamudInterface = new DalamudPluginInterface(this.pluginAssembly.GetName().Name!, reason, this.IsDev); + this.DalamudInterface = new DalamudPluginInterface(this.pluginAssembly.GetName().Name!, this.DllFile, reason, this.IsDev); var ioc = Service.Get(); this.instance = ioc.Create(this.pluginType, this.DalamudInterface) as IDalamudPlugin;