From 58df62161196564fd6d2ba2929240232e6b73d62 Mon Sep 17 00:00:00 2001 From: Shawrkie Williams Date: Wed, 4 Feb 2026 18:09:10 -0500 Subject: [PATCH] Improves inventory window management. Addresses an issue where the inventory window doesn't always open correctly when the game inventory is opened. Adds logic to ensure the inventory window closes when the inventory addon is hidden. Updates the inventory opening logic to check for visibility using RaptureAtkUnitManager instead of AtkValues. --- AetherBags/Monitoring/InventoryMonitor.cs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/AetherBags/Monitoring/InventoryMonitor.cs b/AetherBags/Monitoring/InventoryMonitor.cs index aaf0d68..39de8ca 100644 --- a/AetherBags/Monitoring/InventoryMonitor.cs +++ b/AetherBags/Monitoring/InventoryMonitor.cs @@ -28,7 +28,6 @@ public static unsafe class DragDropState public class InventoryMonitor : IDisposable { - public InventoryMonitor() { var bags = new[] { "Inventory", "InventoryLarge", "InventoryExpansion" }; @@ -42,6 +41,8 @@ public class InventoryMonitor : IDisposable Services.AddonLifecycle.RegisterListener(AddonEvent.PreFinalize, retainer, OnPreFinalize); Services.AddonLifecycle.RegisterListener(AddonEvent.PreFinalize, bags, OnInventoryPreFinalize); + Services.AddonLifecycle.RegisterListener(AddonEvent.PreHide, bags, OnInventoryPreHide); + // PreRefresh Handlers Services.AddonLifecycle.RegisterListener(AddonEvent.PreRefresh, bags, InventoryPreRefreshHandler); @@ -71,6 +72,14 @@ public class InventoryMonitor : IDisposable System.AddonInventoryWindow.Close(); } + private void OnInventoryPreHide(AddonEvent type, AddonArgs args) + { + if (System.Config.General.OpenWithGameInventory) + { + System.AddonInventoryWindow.Close(); + } + } + private unsafe void OpenInventories(string name) { GeneralSettings config = System.Config.General; @@ -192,14 +201,10 @@ public class InventoryMonitor : IDisposable if (config.OpenWithGameInventory) { - AtkValue* value1 = (AtkValue*)atkValues[1].Address; - int openTitleId = value1->Int; + var addon = RaptureAtkUnitManager.Instance()->GetAddonByName(args.AddonName); + bool isCurrentlyVisible = addon != null && addon->IsVisible; - if (openTitleId == 0) - { - System.AddonInventoryWindow.Toggle(); - } - else + if (!isCurrentlyVisible) { System.AddonInventoryWindow.Open(); } @@ -245,6 +250,6 @@ public class InventoryMonitor : IDisposable public void Dispose() { Services.GameInventory.InventoryChangedRaw -= OnInventoryChangedRaw; - Services.AddonLifecycle.UnregisterListener(OnPostSetup, OnPreFinalize, OnInventoryUpdate, OnSaddleBagUpdate, OnRetainerInventoryUpdate, OnInventoryPreFinalize, InventoryPreRefreshHandler); + Services.AddonLifecycle.UnregisterListener(OnPostSetup, OnPreFinalize, OnInventoryUpdate, OnSaddleBagUpdate, OnRetainerInventoryUpdate, OnInventoryPreFinalize, OnInventoryPreHide, InventoryPreRefreshHandler); } } \ No newline at end of file