diff --git a/Blish HUD/GameServices/Modules/ModuleManager.cs b/Blish HUD/GameServices/Modules/ModuleManager.cs index efb637ba..6baa8217 100644 --- a/Blish HUD/GameServices/Modules/ModuleManager.cs +++ b/Blish HUD/GameServices/Modules/ModuleManager.cs @@ -18,6 +18,12 @@ public class ModuleManager : IDisposable { public event EventHandler ModuleEnabled; public event EventHandler ModuleDisabled; + public event EventHandler ModuleLoaded; + + public void OnModuleLoaded(object _, EventArgs e) { + this.ModuleLoaded?.Invoke(this, e); + } + private Assembly _moduleAssembly; private bool _forceAllowDependency = false; @@ -84,6 +90,8 @@ public bool TryEnable() { _dirtyNamespaces.Add(this.Manifest.Namespace); } + this.ModuleInstance.ModuleLoaded += OnModuleLoaded; + this.Enabled = true; try { @@ -113,6 +121,10 @@ public void Disable() { this.Enabled = false; + if (this.ModuleInstance != null) { + this.ModuleInstance.ModuleLoaded -= OnModuleLoaded; + } + try { this.ModuleInstance?.Dispose(); } catch (Exception ex) { @@ -246,7 +258,9 @@ public void Dispose() { GameService.Module.UnregisterModule(this); this.ModuleEnabled = null; - this.ModuleEnabled = null; + this.ModuleDisabled = null; + + this.ModuleLoaded = null; _moduleAssembly = null;